/* ============================================================
   Invoice-IQ — Global Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700&family=Inter:wght@400;500;600;700&display=swap');

/* Sol-IQ brand tokens — aligned with HR-IQ (canonical source: sol-iq-hub /
   HR-IQ tailwind.config.ts). Navy sidebar + dawn-orange→sun-amber gradient. */
:root {
  --sidebar-width: 230px;
  --sidebar-bg: #0F2749;       /* iq-navy */
  --sidebar-hover: #163257;    /* iq-navy-700 */
  --sidebar-active: #F5A623;   /* sun-amber (active accent bar) */
  --topbar-h: 60px;
  --accent: #FF7A45;           /* dawn-orange */
  --accent-tint: #FFF1E8;      /* pale dawn */
  --sol: #F5A623;              /* sun-amber */
  --dawn: #FF7A45;             /* dawn-orange */
  --iq-navy: #0F2749;
  --iq-blue: #2F6FED;
  --grad-sun: linear-gradient(135deg, #FF7A45 0%, #F5A623 100%);
  --border: rgba(15,39,73,0.10); /* iq-navy/10 */
  --lift: 0 16px 32px -20px rgba(15,39,73,0.30);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --body-bg: #FAF6F0;          /* sol-mist */
  --card-bg: #ffffff;
  --ink: #1C1917;              /* sol-ink */
  --text-muted: #64748b;
}

/* ---- Layout ---- */

* { box-sizing: border-box; }
body { background: var(--body-bg); color: var(--ink); font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; margin: 0; }

#app-wrapper { min-height: 100vh; }

/* ---- Sidebar ---- */

#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand i { font-size: 1.3rem; color: var(--accent); }
/* Gradient rounded-square brand mark (matches HR-IQ app shell) */
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--grad-sun);
  flex-shrink: 0;
  margin-right: 10px;
}
.brand-text { font-family: 'Bricolage Grotesque', 'Inter', sans-serif; font-size: 1.1rem; font-weight: 700; color: #ffffff; letter-spacing: -0.02em; line-height: 1.1; }
.brand-text strong { color: var(--sol); font-weight: 800; }
.brand-sub { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.4); }

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4);
  padding: 14px 18px 4px;
}

#sidebar .nav-link {
  color: rgba(255,255,255,0.7);
  padding: 9px 14px;
  border-radius: 8px;
  margin: 1px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
#sidebar .nav-link i { font-size: 1rem; width: 18px; text-align: center; }
#sidebar .nav-link:hover { background: var(--sidebar-hover); color: #ffffff; }
#sidebar .nav-link.active {
  background: linear-gradient(90deg, rgba(255,122,69,0.25) 0%, rgba(245,166,35,0.10) 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--sol);
}

.sidebar-system-badge {
  margin: 2px 14px 6px;
  padding: 0 4px;
  color: rgba(255,255,255,0.4);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  color: #94a3b8;
  font-size: 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  gap: 6px;
}
.sidebar-footer a { color: #64748b; }
.sidebar-footer a:hover { color: #94a3b8; }
.sidebar-logout-link {
  display: flex; align-items: center;
  font-size: 0.78rem;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar-logout-link:hover { color: #f87171 !important; }

/* ---- Main content ---- */

#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(250,246,240,0.80);   /* sol-mist/80 */
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.content-body { padding: 24px; }

/* ---- Cards ---- */

.stat-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--lift); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(47,111,237,0.10); color: #2f6fed; }
.stat-icon.green  { background: #f0fdf4; color: #059669; }
.stat-icon.amber  { background: rgba(245,166,35,0.15); color: #b45309; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }
.stat-icon.purple { background: rgba(255,122,69,0.15); color: #FF7A45; }

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--ink); font-family: 'Bricolage Grotesque', 'Inter', sans-serif; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Dashboard panel ---- */

.panel {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h6 { margin: 0; font-weight: 600; font-size: 0.9rem; color: #0f172a; }
.panel-body { padding: 0; }

/* ---- Tables ---- */

.ap-table { width: 100%; font-size: 0.875rem; }
.ap-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 10px 16px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.ap-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.ap-table tr:last-child td { border-bottom: none; }
.ap-table tbody tr:hover { background: #f8fafc; cursor: pointer; }

/* ---- Status badges ---- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-info      { background: #eff6ff; color: #3b82f6; }
.badge-success   { background: #f0fdf4; color: #059669; }
.badge-warning   { background: #fffbeb; color: #d97706; }
.badge-danger    { background: #fef2f2; color: #dc2626; }

/* ---- Confidence bar ---- */

.confidence-bar {
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  overflow: hidden;
  width: 80px;
  display: inline-block;
  vertical-align: middle;
}
.confidence-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s;
}

/* ---- Invoice detail ---- */

.detail-section {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.doc-viewer-section {
  position: sticky;
  top: 16px;
}
.detail-section h6 {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.detail-row { display: flex; gap: 8px; margin-bottom: 8px; font-size: 0.875rem; }
.detail-label { color: var(--text-muted); min-width: 140px; flex-shrink: 0; }
.detail-value { font-weight: 500; color: #0f172a; }

/* ---- Audit log ---- */

.audit-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.825rem;
}
.audit-item:last-child { border-bottom: none; }
.audit-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
  flex-shrink: 0;
}
.audit-time { color: var(--text-muted); white-space: nowrap; min-width: 130px; }

/* ---- Approval task card ---- */

.task-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}
.task-card:hover { box-shadow: var(--lift); }
.task-amount { font-size: 1.4rem; font-weight: 700; color: var(--ink); }

/* ---- Filters bar ---- */

.filter-bar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ---- Settings ---- */

.settings-nav .nav-link {
  color: #475569;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.875rem;
}
.settings-nav .nav-link.active {
  background: var(--accent-tint);
  color: #C2410C;
  font-weight: 600;
}
.settings-section { background: #fff; border-radius: 16px; border: 1px solid var(--border); padding: 24px; }
.settings-section h6 { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 16px; }

/* ---- Login ---- */

.login-body {
  background: var(--sidebar-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 420px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(15,39,73,0.45);
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--grad-sun);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  margin: 0 auto 16px;
  box-shadow: 0 10px 24px rgba(255,122,69,0.35);
}
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.user-btn:hover { background: #f8fafc; border-color: var(--accent); }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-sun);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

/* ---- Drop zone ---- */

.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  background: #fff;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 14px;
  position: relative;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.drop-zone.drag-over { box-shadow: 0 0 0 4px rgba(245,166,35,.18); }
.drop-zone-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
  transition: background .2s;
}
.drop-zone.drag-over .drop-zone-icon { background: var(--accent); color: #fff; }
.drop-zone-text { flex: 1; }
.drop-zone-text strong { font-size: .9rem; color: #0f172a; }
.drop-zone-text small  { color: var(--text-muted); display: block; margin-top: 1px; }
.drop-zone-btn { flex-shrink: 0; }

.upload-item {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 8px 12px;
  font-size: .85rem; margin-bottom: 6px;
}
.upload-item .filename { flex: 1; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item .upload-status { flex-shrink: 0; font-size: .8rem; }
.upload-item.done   { border-color: #a7f3d0; background: #f0fdf4; }
.upload-item.error  { border-color: #fca5a5; background: #fef2f2; }

/* ---- Pager ---- */

.ap-pager { display: flex; gap: 6px; align-items: center; }
.ap-pager button {
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}
.ap-pager button:disabled { opacity: 0.4; cursor: default; }
.ap-pager button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Misc ---- */

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; display: block; margin-bottom: 12px; opacity: 0.4; }

.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.match-line { font-size: 0.8rem; padding: 4px 0; border-bottom: 1px solid #f1f5f9; }
.match-line:last-child { border-bottom: none; }

/* ---- Mobile nav toggle ---- */

#mobile-nav-toggle { display: none; }
#sidebar-overlay { display: none; }

/* ---- Responsive: collapsible sidebar below 768px ---- */

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #sidebar.open { transform: translateX(0); }

  #main-content { margin-left: 0; }

  #mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 1.25rem;
    color: var(--text-muted);
  }

  #sidebar-overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 190;
  }

  .topbar { padding-left: 12px !important; padding-right: 12px !important; gap: 8px; }
  .topbar h5 { font-size: 1rem; }
  .content-body { padding-left: 12px; padding-right: 12px; }
}
.discrepancy-item { background: #fff7ed; border-left: 3px solid var(--warning); padding: 6px 10px; border-radius: 0 6px 6px 0; font-size: 0.8rem; margin-bottom: 4px; }

/* ---- Bootstrap accent overrides (Sol-IQ / HR-IQ) ---- */

/* Primary CTA = HR-IQ gradient pill (dawn-orange → sun-amber) */
.btn-primary {
  --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-color: #1C1917;
  --bs-btn-hover-bg: transparent; --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: #1C1917;
  --bs-btn-active-bg: transparent; --bs-btn-active-border-color: transparent; --bs-btn-active-color: #1C1917;
  --bs-btn-disabled-bg: transparent; --bs-btn-disabled-border-color: transparent; --bs-btn-disabled-color: #1C1917;
  background-image: var(--grad-sun);
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(255,122,69,0.28);
}
.btn-primary:hover { background-image: var(--grad-sun); filter: brightness(0.97); box-shadow: 0 10px 24px rgba(255,122,69,0.34); }
.btn-primary:active { background-image: var(--grad-sun); filter: brightness(0.94); }
.btn-primary:disabled, .btn-primary.disabled { background-image: var(--grad-sun); opacity: 0.55; box-shadow: none; }
.btn-outline-primary {
  --bs-btn-color: #C2410C; --bs-btn-border-color: var(--dawn); --bs-btn-border-radius: 10px;
  --bs-btn-hover-bg: var(--dawn); --bs-btn-hover-border-color: var(--dawn); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--dawn); --bs-btn-active-border-color: var(--dawn); --bs-btn-active-color: #fff;
  font-weight: 600;
}
.text-primary { color: #C2410C !important; }
a { color: #C2410C; }
a:hover { color: var(--dawn); }