/* ============================================================================
   Fr8Claims — Responsive PWA Styles
   Design: Fintech Clean (Option A) — deep navy, blue accents, Outfit font
   Breakpoints: mobile < 768px, tablet 768-1024px, desktop > 1024px
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ── Reset & Variables ─────────────────────────────────────────────────── */

:root {
  --navy-900: #0B1426;
  --navy-800: #0F1D32;
  --navy-700: #152238;
  --navy-600: #1E293B;
  --slate-700: #334155;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50: #F8FAFC;
  --white: #FFFFFF;
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-400: #60A5FA;
  --blue-100: #DBEAFE;
  --green-600: #16A34A;
  --green-500: #22C55E;
  --green-100: #DCFCE7;
  --amber-600: #D97706;
  --amber-500: #F59E0B;
  --amber-100: #FEF3C7;
  --red-600: #DC2626;
  --red-500: #EF4444;
  --red-100: #FEE2E2;
  --purple-500: #8B5CF6;
  --purple-100: #F3E8FF;
  --font: 'Outfit', system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: 200ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--slate-100);
  color: var(--slate-700);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading & Auth Screens ────────────────────────────────────────────── */

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-card h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--navy-900);
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--slate-500);
  font-size: 14px;
  margin-bottom: 32px;
}

.auth-card input[type="email"],
.auth-card input[type="text"],
.auth-card select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color var(--transition);
}

.auth-card input:focus,
.auth-card select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--blue-600);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-primary:hover { background: #1D4ED8; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--white);
  color: var(--slate-700);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover { background: var(--slate-50); border-color: var(--slate-400); }

.btn-danger {
  background: var(--red-600);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-sm { padding: 8px 14px; font-size: 13px; }

.msg-success { color: var(--green-600); font-size: 14px; margin-top: 12px; }
.msg-error { color: var(--red-600); font-size: 14px; margin-top: 12px; }

/* ── App Shell ─────────────────────────────────────────────────────────── */

.app-shell { display: none; min-height: 100vh; }
.app-shell.active { display: flex; flex-direction: column; }

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 { font-size: 20px; font-weight: 700; }
.app-header .user-info { font-size: 13px; color: var(--slate-400); }
.app-header .user-name { font-weight: 600; color: var(--white); }

.header-actions { display: flex; gap: 12px; align-items: center; }

.btn-icon {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--white);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.btn-icon:hover { background: rgba(255,255,255,0.2); }

/* ── Main Content ──────────────────────────────────────────────────────── */

.app-content {
  flex: 1;
  padding: 16px;
  max-width: 100%;
  overflow-x: hidden;
}

/* ── Status Badges ─────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  display: inline-block;
}

.badge-draft { background: var(--slate-100); color: var(--slate-700); }
.badge-draft .badge-dot { background: var(--slate-400); }
.badge-submitted { background: var(--amber-100); color: #92400E; }
.badge-submitted .badge-dot { background: var(--amber-500); }
.badge-pending { background: var(--amber-100); color: #78350F; }
.badge-pending .badge-dot { background: var(--amber-600); }
.badge-approved { background: var(--green-100); color: #166534; }
.badge-approved .badge-dot { background: var(--green-500); }
.badge-rejected { background: var(--red-100); color: #991B1B; }
.badge-rejected .badge-dot { background: var(--red-500); }
.badge-posted { background: var(--blue-100); color: #1E40AF; }
.badge-posted .badge-dot { background: var(--blue-500); }

/* ── Claim Cards (Mobile) ──────────────────────────────────────────────── */

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

.claim-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--transition);
  border: 1px solid var(--slate-200);
}

.claim-card:hover { box-shadow: var(--shadow); }

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

.claim-card-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-600);
}

.claim-card-desc {
  font-size: 15px;
  font-weight: 500;
  color: var(--navy-900);
  margin-bottom: 8px;
}

.claim-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--slate-500);
}

.claim-card-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-900);
}

.claim-card-items {
  font-size: 12px;
  color: var(--slate-500);
}

/* ── Empty State ───────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--slate-500);
}

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

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

.empty-state p { font-size: 14px; margin-bottom: 24px; }

/* ── New Claim / Detail View ───────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

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

.view-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy-900);
}

.btn-back {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--slate-500);
  padding: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition);
  background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-group textarea { min-height: 80px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Line Item Cards */
.line-items-section { margin-top: 24px; }

.line-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.line-items-header h3 { font-size: 16px; font-weight: 600; }

.line-item-card {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
}

.line-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.line-item-desc { font-weight: 500; font-size: 14px; color: var(--navy-900); }
.line-item-amount { font-weight: 700; font-size: 15px; color: var(--navy-900); }

.line-item-meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--slate-500);
}

.line-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.receipt-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
}

.receipt-yes { background: var(--green-100); color: #166534; }
.receipt-no { background: var(--slate-100); color: var(--slate-500); }

/* Receipt Upload */
.receipt-upload-area {
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--slate-500);
  font-size: 14px;
}

.receipt-upload-area:hover,
.receipt-upload-area.dragover {
  border-color: var(--blue-500);
  background: var(--blue-100);
  color: var(--blue-600);
}

.receipt-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  object-fit: contain;
}

/* ── Bottom Nav (Mobile) ───────────────────────────────────────────────── */

.bottom-nav {
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--slate-200);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 11px;
  color: var(--slate-500);
  cursor: pointer;
  transition: color var(--transition);
  gap: 3px;
}

.bottom-nav-item.active { color: var(--blue-600); }
.bottom-nav-item .nav-icon { font-size: 20px; }

/* Add padding at bottom for fixed nav */
.app-content { padding-bottom: 80px; }

/* ── FAB (Mobile New Claim) ────────────────────────────────────────────── */

.fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--blue-600);
  color: var(--white);
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

.fab:hover { transform: scale(1.05); }

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--navy-900);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  transition: transform 300ms ease;
  box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--red-600); }
.toast.toast-success { background: var(--green-600); }

/* ── Summary Bar ───────────────────────────────────────────────────────── */

.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
}

.summary-card .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy-900);
}

.summary-card .label {
  font-size: 11px;
  color: var(--slate-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Loading Spinner ───────────────────────────────────────────────────── */

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--slate-200);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 32px auto;
}

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

/* ====================================================================
   DESKTOP (>= 768px)
   ==================================================================== */

@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .fab { display: none; }
  .app-content { padding-bottom: 16px; }

  /* Desktop layout: sidebar + content */
  .app-shell.active {
    flex-direction: column;
  }

  .desktop-layout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 64px);
  }

  /* Sidebar */
  .desktop-sidebar {
    width: 240px;
    background: var(--white);
    border-right: 1px solid var(--slate-200);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
  }

  .sidebar-nav { list-style: none; flex: 1; }

  .sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--slate-700);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
  }

  .sidebar-nav-item:hover { background: var(--slate-50); color: var(--blue-600); }
  .sidebar-nav-item.active { background: var(--blue-100); color: var(--blue-600); font-weight: 600; }
  .sidebar-nav-item .nav-icon { font-size: 18px; }

  .sidebar-btn-new {
    margin: 0 16px 16px;
    padding: 12px;
    background: var(--blue-600);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background var(--transition);
  }

  .sidebar-btn-new:hover { background: #1D4ED8; }

  /* Desktop content area */
  .desktop-content {
    flex: 1;
    padding: 24px 32px;
    overflow-x: hidden;
    max-width: calc(100% - 240px);
  }

  /* Table view for desktop */
  .claims-table-wrapper {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--slate-200);
    overflow-x: auto;
  }

  .claims-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
  }

  .claims-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--slate-50);
    color: var(--slate-500);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
  }

  .claims-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--slate-100);
    white-space: nowrap;
  }

  .claims-table tr:hover td { background: var(--slate-50); }
  .claims-table tr { cursor: pointer; }

  .claims-table .col-number { font-weight: 600; color: var(--blue-600); }
  .claims-table .col-amount { font-weight: 700; text-align: right; }

  /* Desktop summary bar - wider */
  .summary-bar { grid-template-columns: repeat(4, 1fr); }

  /* Desktop form layout */
  .form-row { grid-template-columns: 1fr 1fr 1fr; }

  /* Desktop drag-and-drop zone */
  .receipt-upload-area {
    padding: 40px;
  }

  /* Hide mobile-only elements */
  .mobile-only { display: none !important; }
}

/* Mobile-only: hide desktop sidebar */
@media (max-width: 767px) {
  .desktop-sidebar { display: none !important; }
  .desktop-layout { display: block !important; }
  .desktop-content { padding: 0 !important; max-width: 100% !important; }
  .desktop-only { display: none !important; }
}

/* ── Utilities ─────────────────────────────────────────────────────────── */

.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
