/* ============================================================
   XKIM dashboard layout
   All colours use the global CSS variables defined in app.css
   so the dashboard automatically follows the active light/dark
   theme. Any hard-coded hex falls back to a sensible value but
   never overrides the theme.
   ============================================================ */

.dash-layout {
  display: flex;
  min-height: calc(100vh - 60px);
  margin-top: 60px;
  background: var(--bg);
}
.dash-layout.no-sidebar .dash-main { margin-left: 0 !important; }
.dash-layout.no-sidebar .sidebar-toggle { display: none !important; }

/* ───────── Sidebar ───────── */
.dash-sidebar {
  width: 260px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 60px;
  inset-inline-start: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}
/* Light: sidebar lifts off the page with a soft shadow so the boundary
   between sidebar and main content is always obvious. Also nudge the
   background a touch off-white so cards inside it (white) read clearly. */
[data-theme="light"] .dash-sidebar {
  background: #f8fafc;
  box-shadow: 4px 0 12px rgba(15,23,42,0.04);
  border-inline-end-color: var(--border2);
}
/* In RTL the elevation shadow must flip to the other side */
[dir="rtl"][data-theme="light"] .dash-sidebar {
  box-shadow: -4px 0 12px rgba(15,23,42,0.04);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0;
}
.user-info { overflow: hidden; flex: 1; min-width: 0; }
.user-name {
  font-weight: 600; font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.role-badge {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 5px;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.role-badge.role-buyer  { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.role-badge.role-supplier { background: rgba(16, 185, 129, 0.15); color: #34d399; }
[data-theme="light"] .role-badge.role-buyer { background: rgba(59, 130, 246, 0.10); color: #2563eb; }
[data-theme="light"] .role-badge.role-supplier { background: rgba(16, 185, 129, 0.10); color: #059669; }

/* ───────── Sidebar Navigation ───────── */
.sidebar-nav {
  padding: 12px 10px 16px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  padding: 14px 14px 6px;
  user-select: none;
}
.nav-group-label:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
  position: relative;
  white-space: nowrap;
}
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active {
  color: var(--accent);
  background: var(--accentGlow, rgba(59, 130, 246, 0.10));
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; stroke: var(--accent); }
.nav-item.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-item-quiet { color: var(--text3); font-size: 12.5px; }
.nav-item-quiet:hover { color: var(--text); }

.notif-badge {
  margin-inline-start: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.nav-pill {
  margin-inline-start: auto;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.nav-pill-warn { background: rgba(245, 158, 11, 0.18); color: #f59e0b; }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ───────── Main column ───────── */
.dash-main {
  flex: 1;
  margin-inline-start: 260px;
  margin-inline-end: 0;
  min-height: calc(100vh - 60px);
  background: var(--bg);
  min-width: 0;
}

.dash-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 60px;
  z-index: 50;
}
[data-theme="light"] .dash-topbar {
  /* Use the slightly off-white sidebar tone so the topbar sits between page
     bg and the white cards beneath it instead of blending with them. */
  background: #f8fafc;
  border-bottom-color: var(--border2);
  box-shadow: 0 1px 3px rgba(15,23,42,0.03);
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
}
.dash-page-title { font-size: 20px; font-weight: 700; color: var(--text); margin: 0; }
.dash-content { padding: 28px; max-width: 1400px; }

/* ───────── Stats Cards (used by some pages) ───────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.stat-card:hover { border-color: var(--accent); }
[data-theme="light"] .stat-card { box-shadow: var(--card-shadow); }
[data-theme="light"] .stat-card:hover { box-shadow: var(--elevated-shadow); transform: translateY(-1px); }
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.stat-icon.green  { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.stat-icon.orange { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--text3); margin-top: 4px; font-weight: 500; }

/* ───────── Sections ───────── */
.dash-section { margin-bottom: 24px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-header h2 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.section-desc { color: var(--text3); font-size: 13.5px; line-height: 1.5; }
.section-desc a { color: var(--accent); text-decoration: none; }

/* ───────── RFQ / Offer cards ───────── */
.rfq-list, .offers-list { display: flex; flex-direction: column; gap: 14px; }
.rfq-card, .offer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.rfq-card:hover, .offer-card:hover { border-color: var(--accent); }
[data-theme="light"] .rfq-card,
[data-theme="light"] .offer-card { box-shadow: var(--card-shadow); }
[data-theme="light"] .rfq-card:hover,
[data-theme="light"] .offer-card:hover { box-shadow: var(--elevated-shadow); }
.rfq-card-header, .offer-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.rfq-card-title, .offer-card-title { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.rfq-card-title h3, .offer-card-title h3 {
  font-size: 15px; font-weight: 700; color: var(--text); margin: 0;
}
.offer-card-title a { text-decoration: none; }
.offer-card-title a h3:hover { color: var(--accent); }

.rfq-card-meta, .offer-card-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.meta-item { font-size: 12px; color: var(--text3); }

.rfq-card-body, .offer-card-body { padding: 16px 20px; }

.rfq-stats-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; }
.rfq-stat { display: flex; flex-direction: column; gap: 2px; }
.rfq-stat-label {
  font-size: 11px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.rfq-stat-value { font-size: 14px; font-weight: 600; color: var(--text); }
.price-value { color: #10b981; }

/* ───────── Status pills ───────── */
.status-badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  text-transform: capitalize;
}
.status-open     { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.status-awarded  { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.status-closed   { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.status-pending  { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.status-accepted { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.status-rejected { background: rgba(239, 68, 68, 0.12); color: #f87171; }
[data-theme="light"] .status-open     { background: rgba(59, 130, 246, 0.10); color: #2563eb; }
[data-theme="light"] .status-awarded  { background: rgba(16, 185, 129, 0.10); color: #059669; }
[data-theme="light"] .status-closed   { background: rgba(107, 114, 128, 0.12); color: #6b7280; }
[data-theme="light"] .status-pending  { background: rgba(245, 158, 11, 0.10); color: #d97706; }
[data-theme="light"] .status-accepted { background: rgba(16, 185, 129, 0.10); color: #059669; }
[data-theme="light"] .status-rejected { background: rgba(239, 68, 68, 0.10); color: #dc2626; }

/* ───────── Actions ───────── */
.rfq-actions, .offer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btn-danger-outline {
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  padding: 6px 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-danger-outline:hover { background: rgba(239, 68, 68, 0.10); border-color: #ef4444; }

/* ───────── Inline edit form ───────── */
.rfq-edit-form {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.edit-grid .full-width { grid-column: 1 / -1; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 4px;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}
[data-theme="light"] .form-group input,
[data-theme="light"] .form-group textarea {
  background: var(--surface);
  border-color: var(--border2);
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.edit-actions { display: flex; gap: 8px; }

/* ───────── Empty state ───────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state p { margin-bottom: 20px; font-size: 15px; }
[data-theme="light"] .empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}

/* ───────── Overlay (mobile drawer) ───────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ───────── Notifications page ───────── */
.notif-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  position: relative;
  transition: background-color 0.15s, border-color 0.15s;
}
.notif-item:hover { background: var(--surface2); border-color: var(--accent); }
.notif-item.unread {
  background: var(--accentGlow, rgba(59, 130, 246, 0.07));
  border-color: rgba(59, 130, 246, 0.25);
}
.notif-icon {
  font-size: 1.35rem;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 0.93rem; color: var(--text); }
.notif-content { font-size: 0.84rem; color: var(--text2); margin-top: 3px; }
.notif-time { font-size: 0.74rem; color: var(--text3); margin-top: 4px; }
.notif-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ───────── Responsive ───────── */

/* Tablet landscape / small laptop */
@media (max-width: 1100px) {
  .dash-sidebar { width: 220px; }
  .dash-main { margin-inline-start: 220px; }
  .dash-content { padding: 22px 18px; }
  .nav-item { font-size: 12.5px; padding: 8px 12px; gap: 10px; }
  .nav-item svg { width: 18px; height: 18px; }
  .sidebar-header { padding: 16px; }
  .user-avatar { width: 36px; height: 36px; font-size: 14px; }
  .user-name { font-size: 13px; }
  .role-badge { font-size: 9.5px; }
}

/* Tablet portrait / mobile — off-canvas drawer */
@media (max-width: 900px) {
  .dash-sidebar {
    width: 280px;
    transform: translateX(-100%);
  }
  [dir="rtl"] .dash-sidebar { transform: translateX(100%); }
  .dash-sidebar.open { transform: translateX(0) !important; }
  .dash-main { margin-inline-start: 0; }
  .sidebar-toggle { display: block; }
  .dash-content { padding: 18px 14px; }
  .dash-topbar { padding: 14px 16px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .edit-grid { grid-template-columns: 1fr; }
  .rfq-stats-row { gap: 16px; }
  .nav-item { font-size: 13.5px; padding: 10px 14px; gap: 12px; }
  .nav-item svg { width: 20px; height: 20px; }
  .dash-page-title { font-size: 17px; }
}

/* Small mobile */
@media (max-width: 480px) {
  .dash-content { padding: 14px 10px; }
  .dash-topbar { padding: 10px 12px; }
  .dash-page-title { font-size: 15px; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { padding: 14px; gap: 12px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11.5px; }
  .rfq-card-header, .offer-card-header,
  .rfq-card-body, .offer-card-body { padding: 12px 14px; }
  .rfq-card-title h3, .offer-card-title h3 { font-size: 14px; }
  .section-header h2 { font-size: 14.5px; }
}

/* ───────── RTL — flip directional ornaments ─────────
   The sidebar nav active indicator has rounded outer corners that only
   point one way; flip them so the active bar always sits cleanly against
   the start edge of the sidebar. */
[dir="rtl"] .nav-item.active::before {
  border-radius: 3px 0 0 3px;
}

/* ───────── Generic dashboard cards — light-theme separation ─────────
   When the page background and card background are both very light, a
   plain 1px border is too faint. Add a soft hairline shadow in light
   theme so every card visibly stands off the page. */
[data-theme="light"] .stat-card,
[data-theme="light"] .rfq-card,
[data-theme="light"] .offer-card,
[data-theme="light"] .notif-item {
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
[data-theme="light"] .verify-banner {
  background: linear-gradient(135deg,#fef3c7 0%,#fffbeb 100%) !important;
  border-color: #f59e0b !important;
  color: #92400e !important;
  box-shadow: 0 1px 3px rgba(245,158,11,.12);
}
[data-theme="light"] .verify-banner svg { stroke: #d97706 !important; }

/* ============================================================
   LIGHT MODE — premium layered shell
   Goal: give the dashboard real depth in light mode without
   touching dark mode. A soft tinted page gradient sits behind
   white cards; the sidebar + topbar form a cohesive "chrome"
   layer; content floats above. Inspired by Linear / Stripe.
   ============================================================ */
[data-theme="light"] .dash-layout {
  background:
    radial-gradient(1200px 600px at 100% -5%, rgba(37,99,235,0.05), transparent 60%),
    linear-gradient(180deg, #f1f4f9 0%, #eaeef4 100%);
}
[data-theme="light"] .dash-main {
  background: transparent;
}
/* Sidebar reads as a soft frosted panel with a clean right edge. */
[data-theme="light"] .dash-sidebar {
  background: linear-gradient(180deg, #fbfcfe 0%, #f4f7fb 100%);
  border-inline-end-color: var(--border);
  box-shadow: 1px 0 0 rgba(255,255,255,0.6) inset, 6px 0 24px -12px rgba(15,23,42,0.12);
}
[dir="rtl"][data-theme="light"] .dash-sidebar {
  box-shadow: -1px 0 0 rgba(255,255,255,0.6) inset, -6px 0 24px -12px rgba(15,23,42,0.12);
}
/* Topbar: translucent + blur so content scrolls subtly underneath. */
[data-theme="light"] .dash-topbar {
  background: rgba(251,252,254,0.78);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.7), 0 6px 18px -14px rgba(15,23,42,0.25);
}
[data-theme="light"] .dash-page-title { color: var(--text); letter-spacing: -0.01em; }
/* Active nav item gets a soft accent wash + crisp indicator. */
[data-theme="light"] .nav-item.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.10), rgba(37,99,235,0.04));
  color: var(--accent2);
}
