/* ══════════════════════════════════════════════
   Receipt Tracker — Shared Stylesheet
   ══════════════════════════════════════════════ */

:root {
  --bg:           #f4f5f7;
  --surface:      #ffffff;
  --border:       #e2e5eb;
  --text:         #1a1d23;
  --text-muted:   #7c8494;
  --accent:       #2563eb;
  --accent-light: #eff4ff;
  --work:         #2563eb;
  --tax:          #059669;
  --both:         #7c3aed;
  --danger:       #dc2626;
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
  --radius:       12px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
}

/* ── NAVBAR ──────────────────────────────────── */
.app-nav {
  background: var(--text);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.nav-brand .brand-icon {
  background: var(--accent);
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-user {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  display: none; /* shown via JS once logged in */
}

/* ── CARDS ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header-custom {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-header-custom .card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.card-header-custom .card-title i { color: var(--accent); }
.card-body-custom { padding: 1.25rem; }

/* ── UPLOAD ZONE ─────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafbfc;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-zone .icon-wrap {
  width: 52px; height: 52px;
  background: var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.75rem;
  font-size: 1.4rem;
  color: var(--text-muted);
  transition: all 0.2s;
}
.upload-zone:hover .icon-wrap,
.upload-zone.dragover .icon-wrap {
  background: var(--accent);
  color: #fff;
}
.upload-zone .upload-label { font-weight: 600; font-size: 0.9rem; }
.upload-zone .upload-sub   { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.2rem; }

/* ── STAT TILES ──────────────────────────────── */
.stat-tile {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-tile .stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  line-height: 1;
}
.stat-tile .stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── RECEIPT TABLE ───────────────────────────── */
.receipt-table { font-size: 0.855rem; width: 100%; border-collapse: collapse; }
.receipt-table thead th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
}
.receipt-table tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.receipt-table tbody tr:last-child td { border-bottom: none; }
.receipt-table tbody tr:hover td     { background: #fafbfc; }
.amount-cell {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── TAG BADGES ──────────────────────────────── */
.tag-badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tag-work { background: #eff6ff; color: var(--work); }
.tag-tax  { background: #ecfdf5; color: var(--tax); }
.tag-both { background: #f5f3ff; color: var(--both); }
.tag-none { background: #f0f2f5; color: var(--text-muted); }

/* ── BUTTONS ─────────────────────────────────── */
.btn-primary-custom {
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 0.5rem 1rem; font-weight: 600; font-size: 0.875rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
  transition: background 0.15s; font-family: 'DM Sans', sans-serif;
}
.btn-primary-custom:hover { background: #1d4ed8; }

.btn-outline-custom {
  background: transparent; color: #fff;
  border: 1.5px solid rgba(255,255,255,0.3); border-radius: 8px;
  padding: 0.4rem 0.9rem; font-weight: 500; font-size: 0.84rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
  transition: all 0.15s; font-family: 'DM Sans', sans-serif;
}
.btn-outline-custom:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.6);
}
.btn-logout {
  background: transparent; color: rgba(255,255,255,0.6);
  border: 1.5px solid rgba(255,255,255,0.15); border-radius: 8px;
  padding: 0.35rem 0.8rem; font-weight: 500; font-size: 0.8rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
  transition: all 0.15s; font-family: 'DM Sans', sans-serif;
}
.btn-logout:hover {
  background: rgba(220,38,38,0.15);
  border-color: rgba(220,38,38,0.4);
  color: #fca5a5;
}
.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.25rem 0.5rem; cursor: pointer; color: var(--text-muted);
  font-size: 0.8rem; transition: all 0.15s;
}
.btn-icon:hover         { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover  { background: #fee2e2; color: var(--danger); border-color: #fecaca; }

/* ── MODAL ───────────────────────────────────── */
.modal-content { border: none; border-radius: 14px; box-shadow: var(--shadow-md); }
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1.4rem;
  background: var(--bg);
  border-radius: 14px 14px 0 0;
}
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-body  { padding: 1.4rem; }
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.4rem;
  background: var(--bg);
  border-radius: 0 0 14px 14px;
}
.form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  display: block;
}
.form-control,
.form-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  color: var(--text);
}
.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
textarea.form-control { resize: vertical; }

.receipt-img-preview {
  width: 100%; border-radius: 10px; border: 1px solid var(--border);
  max-height: 280px; object-fit: contain; background: var(--bg);
  display: block;
}

/* ── AI NOTE ─────────────────────────────────── */
.ai-note {
  display: none;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ── LOADING OVERLAY ─────────────────────────── */
#loadingOverlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(26,29,35,0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
#loadingOverlay.show { display: flex; }
.loading-card {
  background: #fff;
  border-radius: 14px;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.loading-card .spinner-border { color: var(--accent); }
.loading-card .load-text {
  margin-top: 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.loading-card .load-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

/* ── FILTER BAR ──────────────────────────────── */
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.filter-bar .form-select {
  font-size: 0.84rem;
  padding: 0.35rem 0.7rem;
  height: auto;
  border-radius: 8px;
  min-width: 130px;
  width: auto;
}

/* ── EMPTY STATE ─────────────────────────────── */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; opacity: 0.3; display: block; }
.empty-state p { margin-top: 0.75rem; font-size: 0.9rem; }

/* ── LOGIN PAGE ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.login-brand .brand-icon {
  background: var(--accent);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.login-brand .brand-text { font-weight: 700; font-size: 1.1rem; }
.login-brand .brand-sub  { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }
.login-title { font-weight: 700; font-size: 1.3rem; margin-bottom: 0.3rem; }
.login-sub   { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.75rem; }
.login-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.84rem;
  margin-bottom: 1rem;
  display: none;
}
.login-error.show { display: block; }
.btn-login {
  width: 100%; background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 0.65rem; font-weight: 600; font-size: 0.95rem;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: background 0.15s; margin-top: 0.25rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-login:hover    { background: #1d4ed8; }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }
.login-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── RELIEF TRACKER ──────────────────────────── */
.relief-group { margin-bottom: 1.25rem; }
.relief-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.relief-bar-row { margin-bottom: 0.65rem; }
.relief-bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.3rem;
}
.relief-bar-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}
.relief-bar-amounts { font-size: 0.8rem; white-space: nowrap; }
.relief-bar-track {
  height: 7px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.relief-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}
.relief-over-badge {
  display: inline-block;
  background: #fee2e2;
  color: var(--danger);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.relief-badge {
  display: inline-block;
  background: #f5f3ff;
  color: var(--both);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  white-space: nowrap;
}

/* Relief Table */
.relief-table { font-size: 0.84rem; border-collapse: collapse; }
.relief-table thead th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
}
.relief-table tbody td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.relief-table tbody tr:last-child td { border-bottom: none; }
.relief-table tbody tr:hover td      { background: #fafbfc; }

/* Relief warning in modal */
.relief-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.relief-warning i { margin-top: 0.1rem; flex-shrink: 0; }

/* ── PROVIDER SELECTOR ──────────────────────── */
.provider-selector { display: flex; flex-direction: column; gap: 0.6rem; }

.provider-option {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
}
.provider-option:hover { border-color: var(--accent); background: var(--accent-light); }
.provider-selected { border-color: var(--accent) !important; background: var(--accent-light) !important; }

.provider-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.provider-option-body { margin-top: 0.85rem; }

.provider-recommended-badge {
  background: #dcfce7;
  color: #166534;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.provider-radio {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}
.provider-radio-active {
  border-color: var(--accent);
  background: var(--accent);
}
.provider-radio-active::after {
  content: '';
  position: absolute;
  width: 6px; height: 6px;
  background: #fff;
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.provider-instructions {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text);
  border: 1px solid var(--border);
}
.provider-instructions ol {
  margin: 0.4rem 0 0 1rem;
  padding: 0;
  color: var(--text-muted);
}
.provider-instructions ol li { margin-bottom: 0.2rem; }
.provider-instructions a { color: var(--accent); }

/* ── PDF PLACEHOLDER ────────────────────────── */
.receipt-pdf-placeholder {
  width: 100%;
  min-height: 180px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff7ed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: #c2410c;
  padding: 1.5rem;
}
.receipt-pdf-placeholder i {
  font-size: 2.8rem;
}
.receipt-pdf-placeholder div {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
  max-width: 100%;
}

/* ── RELIEF TOOLTIPS ────────────────────────── */
.relief-has-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: default;
}
.relief-tip-icon {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.7;
  flex-shrink: 0;
}
.relief-tip-box {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 260px;
  background: var(--text);
  color: #fff;
  font-size: 0.77rem;
  font-weight: 400;
  line-height: 1.5;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 999;
  pointer-events: none;
  white-space: normal;
}
/* Arrow */
.relief-tip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 16px;
  border: 6px solid transparent;
  border-top-color: var(--text);
}
.relief-has-tip:hover .relief-tip-box,
.relief-has-tip:focus .relief-tip-box {
  display: block;
}

/* ── RELIEF DISCLAIMER ───────────────────────── */
.relief-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.82rem;
  color: #1e40af;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.relief-disclaimer i { margin-top: 0.1rem; flex-shrink: 0; }

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 768px) {
  .app-nav    { padding: 0.65rem 1rem; }
  .nav-user   { display: none !important; }
  .filter-bar { gap: 0.4rem; }
  .filter-bar .form-select { min-width: 110px; }
  .login-card { padding: 2rem 1.5rem; }

  /* On mobile: hide button text, show icons only */
  .nav-right  { gap: 0.4rem; }
  .btn-outline-custom .nav-btn-text,
  .btn-logout .nav-btn-text { display: none; }
  .btn-outline-custom {
    padding: 0.4rem 0.55rem;
    min-width: 34px;
    justify-content: center;
  }
  .btn-logout {
    padding: 0.35rem 0.55rem;
    min-width: 34px;
    justify-content: center;
  }
}
