/* ============================================
   Walk Store Returns & Exchanges
   Design system matching iOS app dark theme
   ============================================ */

:root {
  /* Colors — matching ThemeManager.swift */
  --bg-primary: #0D0D0D;
  --bg-secondary: #1A1A1A;
  --bg-tertiary: #2A2A2A;
  --text-primary: #FFFFFF;
  --text-secondary: #AAAAAA;
  --text-tertiary: #666666;
  --accent: #007AFF;
  --accent-pressed: #0051D5;
  --danger: #FF3B30;
  --success: #34C759;
  --warning: #FF9500;
  --separator: rgba(255, 255, 255, 0.08);
  --card-bg: #1A1A1A;
  --input-bg: #2A2A2A;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* RTL support */
[dir="rtl"] {
  --rtl-flip: scaleX(-1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ============================================
   SCREENS
   ============================================ */

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--safe-top) 0 var(--safe-bottom);
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

[dir="rtl"] .screen.active {
  animation: fadeInRTL 0.25s ease;
}

@keyframes fadeInRTL {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.logo {
  text-align: center;
  margin-bottom: 48px;
}

.logo-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 36px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 4px;
}

/* ============================================
   FORMS
   ============================================ */

.form {
  width: 100%;
  max-width: 360px;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-group input,
.form-content input,
.form-content textarea,
.form-content select {
  width: 100%;
  padding: 16px;
  background: var(--input-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 17px;
  font-family: inherit;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.input-group input:focus,
.form-content input:focus,
.form-content textarea:focus,
.form-content select:focus {
  outline: none;
  border-color: var(--accent);
}

.input-group input::placeholder {
  color: var(--text-tertiary);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
}

.btn-primary:active {
  background: var(--accent-pressed);
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:active {
  background: var(--bg-secondary);
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 8px;
}

.text-btn:disabled {
  color: var(--text-tertiary);
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  transform: var(--rtl-flip, none);
}

/* Spinner */
.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-top-color: var(--bg-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   OTP SCREEN
   ============================================ */

.otp-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.otp-container .back-btn {
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: 16px;
  transform: var(--rtl-flip, none);
}

[dir="rtl"] .otp-container .back-btn {
  left: auto;
  right: 16px;
}

.otp-container h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.otp-inputs {
  display: flex;
  gap: 10px;
  margin: 32px 0;
}

.otp-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  background: var(--input-bg);
  border: 2px solid var(--separator);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  -webkit-appearance: none;
  appearance: none;
}

.otp-digit:focus {
  outline: none;
  border-color: var(--accent);
}

.otp-digit.filled {
  border-color: var(--accent);
}

/* ============================================
   NAV HEADER
   ============================================ */

.nav-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--separator);
}

.nav-header h2 {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.nav-header .back-btn {
  flex: 0 0 auto;
  margin-right: 8px;
}

[dir="rtl"] .nav-header .back-btn {
  margin-right: 0;
  margin-left: 8px;
}

/* ============================================
   ORDERS LIST
   ============================================ */

.orders-list {
  padding: 16px;
}

.order-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.15s;
  border: 1px solid var(--separator);
}

.order-card:active {
  transform: scale(0.98);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.order-card-title {
  font-size: 16px;
  font-weight: 700;
}

.order-card-date {
  font-size: 13px;
  color: var(--text-secondary);
}

.order-card-items {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.order-item-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  object-fit: cover;
}

.order-item-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-tertiary);
}

.order-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-card-price {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.return-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(0, 122, 255, 0.15);
  color: var(--accent);
}

.return-badge.expired {
  background: rgba(102, 102, 102, 0.15);
  color: var(--text-tertiary);
}

/* ============================================
   ORDER DETAIL
   ============================================ */

.order-detail-content {
  padding: 16px;
}

.detail-section {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--separator);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--separator);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--text-secondary);
  font-size: 15px;
}

.detail-value {
  font-size: 15px;
  font-weight: 500;
}

.detail-items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-item {
  display: flex;
  gap: 12px;
  align-items: center;
}

.detail-item-image {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  object-fit: cover;
  flex-shrink: 0;
}

.detail-item-placeholder {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.detail-item-info {
  flex: 1;
}

.detail-item-title {
  font-size: 15px;
  font-weight: 600;
}

.detail-item-variant {
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-item-price {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============================================
   ACTION CARDS
   ============================================ */

.action-container {
  padding: 24px 16px;
}

.action-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 20px;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  font-family: inherit;
  color: var(--text-primary);
  text-align: left;
}

[dir="rtl"] .action-card {
  text-align: right;
}

.action-card:active {
  transform: scale(0.98);
  border-color: var(--accent);
}

.action-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(0, 122, 255, 0.15);
  color: var(--accent);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-info {
  flex: 1;
}

.action-info h3 {
  font-size: 18px;
  font-weight: 700;
}

.action-info p {
  font-size: 14px;
  color: var(--text-secondary);
}

.action-arrow {
  font-size: 22px;
  color: var(--text-tertiary);
  transform: var(--rtl-flip, none);
}

/* ============================================
   SELECT ITEMS
   ============================================ */

.select-items-content {
  padding: 16px;
  padding-bottom: 100px;
}

.selectable-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.selectable-item.selected {
  border-color: var(--accent);
  background: rgba(0, 122, 255, 0.08);
}

.selectable-item:active {
  transform: scale(0.98);
}

.selectable-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--text-tertiary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.selectable-item.selected .selectable-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.selectable-checkbox::after {
  content: '\2713';
  color: var(--bg-primary);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
}

.selectable-item.selected .selectable-checkbox::after {
  opacity: 1;
}

.selectable-item-image {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  object-fit: cover;
  flex-shrink: 0;
}

.selectable-item-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.selectable-item-info {
  flex: 1;
}

.selectable-item-title {
  font-size: 15px;
  font-weight: 600;
}

.selectable-item-variant {
  font-size: 13px;
  color: var(--text-secondary);
}

.selectable-qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:disabled {
  opacity: 0.3;
}

.qty-value {
  font-size: 15px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

/* ============================================
   FORM CONTENT
   ============================================ */

.form-content {
  padding: 16px;
  padding-bottom: 120px;
}

.form-section {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--separator);
}

.form-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.reason-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reason-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s;
}

.reason-option.selected {
  border-color: var(--accent);
  background: rgba(0, 122, 255, 0.08);
}

.reason-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text-tertiary);
  flex-shrink: 0;
  transition: all 0.15s;
}

.reason-option.selected .reason-radio {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--bg-primary);
}

.reason-label {
  font-size: 15px;
}

.form-content textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

.form-content select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23AAAAAA' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

[dir="rtl"] .form-content select {
  background-position: left 16px center;
  padding-right: 16px;
  padding-left: 40px;
}

/* Exchange variant selector */
.exchange-item {
  background: var(--input-bg);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
}

.exchange-item-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.exchange-item-image {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  object-fit: cover;
}

.exchange-item-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-tertiary);
}

.exchange-item-title {
  font-size: 14px;
  font-weight: 600;
}

.exchange-item-current {
  font-size: 12px;
  color: var(--text-secondary);
}

.exchange-selector-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ============================================
   BOTTOM BAR
   ============================================ */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--separator);
  z-index: 100;
}

.delivery-fee-info {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.delivery-fee-info span:last-child {
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================
   SUCCESS SCREEN
   ============================================ */

.success-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success);
  color: var(--bg-primary);
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.success-container h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-container p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 24px;
  max-width: 320px;
}

.success-details {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--separator);
}

.success-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.success-detail-row .label {
  color: var(--text-secondary);
}

.success-detail-row .value {
  font-weight: 600;
}

.success-container .btn-primary {
  max-width: 360px;
}

/* ============================================
   REQUESTS LIST
   ============================================ */

.requests-list {
  padding: 16px;
}

.request-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--separator);
}

.request-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.request-type-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}

.request-type-badge.return {
  background: rgba(255, 59, 48, 0.15);
  color: var(--danger);
}

.request-type-badge.exchange {
  background: rgba(0, 122, 255, 0.15);
  color: var(--accent);
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.status-badge.pending, .status-badge.submitted {
  background: rgba(255, 149, 0, 0.15);
  color: var(--warning);
}

.status-badge.completed, .status-badge.approved {
  background: rgba(52, 199, 89, 0.15);
  color: var(--success);
}

.status-badge.rejected {
  background: rgba(255, 59, 48, 0.15);
  color: var(--danger);
}

.request-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.request-card-date {
  font-size: 13px;
  color: var(--text-secondary);
}

.request-card-items {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 0.5px solid var(--separator);
}

.request-item-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 4px 0;
}

.request-item-name {
  color: var(--text-secondary);
}

.request-item-reason {
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}

.loading-spinner.large {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 15px;
}

/* Processing screen */
.processing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.processing-container h2 {
  font-size: 22px;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 8px;
}

.processing-container p {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ============================================
   TOAST
   ============================================ */

.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow);
  max-width: 90%;
  text-align: center;
  animation: toastIn 0.3s ease;
  border: 1px solid var(--separator);
}

.toast.error {
  background: rgba(255, 59, 48, 0.9);
}

.toast.success {
  background: rgba(52, 199, 89, 0.9);
  color: var(--bg-primary);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================
   FOOTER NOTE
   ============================================ */

.footer-note {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  margin-top: 24px;
  max-width: 320px;
}
