/* ==========================================================================
   CheckoutIQ Admin — Metis-style theme (v1.1)
   Design language adapted from the MIT-licensed "Metis" Bootstrap 5 dashboard
   (same lineage as the artwani admin panel):
   one accent colour, structure from borders (not shadows), Inter typography,
   seamless dark/light mode via Bootstrap 5.3 data-bs-theme.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root,
[data-bs-theme="light"] {
  --ciq-accent: #2563eb;            /* Metis single accent — Blue 600 */
  --ciq-accent-700: #1d4ed8;
  --ciq-accent-soft: #dbeafe;      /* Blue 100 */
  --ciq-bg: #f1f5f9;               /* app ground — Slate 100 */
  --ciq-panel: #ffffff;            /* panels sit on the ground */
  --ciq-panel-2: #f8fafc;          /* sunken / inset areas */
  --ciq-border: #e2e8f0;           /* Slate 200 */
  --ciq-ink: #0f172a;              /* primary text — Slate 900 */
  --ciq-ink-2: #475569;            /* secondary — Slate 600 */
  --ciq-ink-3: #94a3b8;            /* muted — Slate 400 */
  --ciq-sidebar-bg: #ffffff;
  --ciq-sidebar-ink: #334155;
  --ciq-sidebar-ink-2: #94a3b8;
  --ciq-nav-hover: #f1f5f9;
  --ciq-nav-active-bg: #dbeafe;
  --ciq-nav-active-ink: #1d4ed8;
  --ciq-topbar-bg: rgba(255, 255, 255, 0.92);
  --ciq-input-bg: #ffffff;
  --ciq-shadow-float: 0 12px 32px rgba(15, 23, 42, 0.14);
  --ciq-radius: 12px;
}

[data-bs-theme="dark"] {
  --ciq-accent: #3b82f6;           /* Blue 500 — readable on dark */
  --ciq-accent-700: #60a5fa;
  --ciq-accent-soft: #1e3a8a;
  --ciq-bg: #0a0f1c;               /* darkest surface = app ground */
  --ciq-panel: #131c2e;            /* panels one step above ground */
  --ciq-panel-2: #0d1526;
  --ciq-border: #1e293b;           /* Slate 800 */
  --ciq-ink: #f1f5f9;              /* Slate 100 */
  --ciq-ink-2: #94a3b8;            /* Slate 400 */
  --ciq-ink-3: #64748b;            /* Slate 500 */
  --ciq-sidebar-bg: #131c2e;
  --ciq-sidebar-ink: #cbd5e1;
  --ciq-sidebar-ink-2: #64748b;
  --ciq-nav-hover: #1e293b;
  --ciq-nav-active-bg: #1e3a8a;
  --ciq-nav-active-ink: #bfdbfe;
  --ciq-topbar-bg: rgba(19, 28, 46, 0.92);
  --ciq-input-bg: #0d1526;
  --ciq-shadow-float: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ---------- Base ---------- */
.ciq-admin {
  background: var(--ciq-bg);
  color: var(--ciq-ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.925rem;
  -webkit-font-smoothing: antialiased;
}
.ciq-admin-wrap { display: flex; min-height: 100vh; }

/* ---------- Sidebar (Metis-style bordered panel) ---------- */
.ciq-sidebar {
  width: 248px; flex: 0 0 248px;
  background: var(--ciq-sidebar-bg);
  color: var(--ciq-sidebar-ink);
  border-right: 1px solid var(--ciq-border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; height: 100vh; height: 100dvh;
  z-index: 1040; overflow-y: auto; overscroll-behavior: contain;
  transition: width 0.22s ease, flex-basis 0.22s ease, transform 0.25s ease;
}
.ciq-brand-row { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem 0.75rem 1.25rem; border-bottom: 1px solid var(--ciq-border); }
.ciq-sidebar-brand { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.02em; color: var(--ciq-ink); text-decoration: none; }
.ciq-sidebar-brand span { color: var(--ciq-accent); }
.ciq-sidebar-brand small { font-size: 0.6rem; font-weight: 700; color: var(--ciq-ink-3); letter-spacing: 0.14em; text-transform: uppercase; margin-left: 0.35rem; }
.ciq-side-collapse { border: 1px solid var(--ciq-border); background: var(--ciq-panel-2); color: var(--ciq-ink-2); border-radius: 8px; width: 30px; height: 30px; align-items: center; justify-content: center; cursor: pointer; }
.ciq-side-collapse:hover { color: var(--ciq-accent); border-color: var(--ciq-accent); }

.ciq-side-nav { flex: 1; overflow-y: auto; padding: 0.75rem; }
.ciq-side-nav a { display: flex; align-items: center; gap: 0.7rem; color: var(--ciq-sidebar-ink); text-decoration: none; padding: 0.55rem 0.75rem; border-radius: 9px; font-size: 0.9rem; font-weight: 500; margin-bottom: 2px; border: 1px solid transparent; }
.ciq-side-nav a:hover { background: var(--ciq-nav-hover); color: var(--ciq-ink); }
.ciq-side-nav a.active { background: var(--ciq-nav-active-bg); color: var(--ciq-nav-active-ink); font-weight: 600; }
.ciq-side-nav a i { font-size: 1.05rem; width: 1.4rem; text-align: center; flex: 0 0 auto; }
.ciq-side-nav a.active i { color: var(--ciq-accent); }
.ciq-nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ciq-side-foot { padding: 0.85rem 1.25rem; border-top: 1px solid var(--ciq-border); display: flex; gap: 1.1rem; margin-top: auto; }
.ciq-side-foot a, .ciq-side-foot button.ciq-logout-btn { color: var(--ciq-ink-2); text-decoration: none; font-size: 0.85rem; font-weight: 500; display: inline-flex; align-items: center; gap: 0.4rem; }
.ciq-side-foot a:hover, .ciq-side-foot button.ciq-logout-btn:hover { color: var(--ciq-accent); }
.ciq-side-foot button.ciq-logout-btn { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }

/* Desktop collapsed sidebar — icon rail */
.ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar { width: 76px; flex-basis: 76px; }
.ciq-admin-wrap.ciq-side-collapsed .ciq-main { margin-left: 76px; }
.ciq-admin-wrap.ciq-side-collapsed .ciq-brand-row { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
.ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar-brand small,
.ciq-admin-wrap.ciq-side-collapsed .ciq-nav-label,
.ciq-admin-wrap.ciq-side-collapsed .ciq-side-foot a span, .ciq-admin-wrap.ciq-side-collapsed .ciq-side-foot button.ciq-logout-btn span { display: none; }
.ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar-brand { font-size: 0; }
.ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar-brand::after { content: "C"; font-size: 1.35rem; font-weight: 800; color: var(--ciq-accent); }
.ciq-admin-wrap.ciq-side-collapsed .ciq-side-nav a { justify-content: center; padding: 0.6rem 0; }
.ciq-admin-wrap.ciq-side-collapsed .ciq-side-collapse i { transform: rotate(180deg); }
.ciq-admin-wrap.ciq-side-collapsed .ciq-side-foot { justify-content: center; }

/* ---------- Main + topbar ---------- */
.ciq-main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: 248px; transition: margin-left 0.22s ease; }
.ciq-topbar-admin {
  background: var(--ciq-topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ciq-border);
  padding: 0.7rem 1.4rem; display: flex; align-items: center; gap: 0.7rem;
  position: sticky; top: 0; z-index: 1030;
}
.ciq-topbar-admin h1 { font-weight: 700; letter-spacing: -0.01em; color: var(--ciq-ink); font-size: 1.15rem; margin: 0; }
.ciq-theme-toggle { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; }
.ciq-content { padding: 1.5rem; flex: 1; max-width: 1720px; width: 100%; margin: 0 auto; }
.ciq-admin-foot { padding: 0.9rem 1.5rem; color: var(--ciq-ink-3); border-top: 1px solid var(--ciq-border); font-size: 0.82rem; }

/* ---------- Panels: borders, not shadows (Metis rule) ---------- */
.card { border: 1px solid var(--ciq-border); border-radius: var(--ciq-radius); background: var(--ciq-panel); box-shadow: none; }
.card-header { background: transparent; border-bottom: 1px solid var(--ciq-border); font-weight: 600; color: var(--ciq-ink); }
.card-body { color: var(--ciq-ink); }
.table { --bs-table-bg: transparent; color: var(--ciq-ink); }
.table thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ciq-ink-2); font-weight: 700; border-bottom: 1px solid var(--ciq-border); background: var(--ciq-panel-2); }
.table > :not(caption) > * > * { border-bottom-color: var(--ciq-border); }
.form-control, .form-select { background: var(--ciq-input-bg); border-color: var(--ciq-border); color: var(--ciq-ink); border-radius: 9px; }
.form-control:focus, .form-select:focus { background: var(--ciq-input-bg); color: var(--ciq-ink); border-color: var(--ciq-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ciq-accent) 18%, transparent); }
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--ciq-ink-2); }
.btn-primary { --bs-btn-bg: var(--ciq-accent); --bs-btn-border-color: var(--ciq-accent); --bs-btn-hover-bg: var(--ciq-accent-700); --bs-btn-hover-border-color: var(--ciq-accent-700); --bs-btn-active-bg: var(--ciq-accent-700); --bs-btn-active-border-color: var(--ciq-accent-700); border-radius: 9px; font-weight: 600; }
.btn { border-radius: 9px; font-weight: 500; }
.btn-outline-secondary { --bs-btn-color: var(--ciq-ink-2); --bs-btn-border-color: var(--ciq-border); --bs-btn-hover-bg: var(--ciq-nav-hover); --bs-btn-hover-color: var(--ciq-ink); --bs-btn-hover-border-color: var(--ciq-border); }
a { color: var(--ciq-accent); }
.dropdown-menu { background: var(--ciq-panel); border: 1px solid var(--ciq-border); border-radius: var(--ciq-radius); box-shadow: var(--ciq-shadow-float); }
.dropdown-item { color: var(--ciq-ink); }
.dropdown-item:hover { background: var(--ciq-nav-hover); color: var(--ciq-ink); }
.modal-content { background: var(--ciq-panel); border: 1px solid var(--ciq-border); border-radius: 14px; }
.alert { border-radius: var(--ciq-radius); }
.badge { font-weight: 600; }
.list-group-item { background: var(--ciq-panel); border-color: var(--ciq-border); color: var(--ciq-ink); }
.list-group-item-action:hover { background: var(--ciq-nav-hover); color: var(--ciq-ink); }
.input-group-text { background: var(--ciq-panel-2); border-color: var(--ciq-border); color: var(--ciq-ink-2); }
hr { border-color: var(--ciq-border); opacity: 1; }
.text-muted { color: var(--ciq-ink-2) !important; }

/* ---------- Stat cards ---------- */
.ciq-stat-card { background: var(--ciq-panel); border: 1px solid var(--ciq-border); border-radius: var(--ciq-radius); padding: 1.1rem; height: 100%; }
.ciq-stat-icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 1.2rem; margin-bottom: 0.6rem; }
.ciq-stat-val { font-size: 1.5rem; font-weight: 700; color: var(--ciq-ink); letter-spacing: -0.01em; }
.ciq-stat-label { font-size: 0.82rem; color: var(--ciq-ink-2); }

/* ---------- Standalone auth pages (login / install) ---------- */
.ciq-auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--ciq-bg); }
.ciq-auth-card { width: 100%; max-width: 430px; background: var(--ciq-panel); border: 1px solid var(--ciq-border); border-radius: 16px; padding: 2rem; }
.ciq-auth-brand { font-weight: 800; font-size: 1.6rem; letter-spacing: -0.02em; color: var(--ciq-ink); text-align: center; margin-bottom: 0.25rem; }
.ciq-auth-brand span { color: var(--ciq-accent); }
.ciq-auth-sub { text-align: center; color: var(--ciq-ink-2); font-size: 0.88rem; margin-bottom: 1.5rem; }

/* ---------- Slim scrollbars ---------- */
.ciq-sidebar::-webkit-scrollbar, .ciq-side-nav::-webkit-scrollbar { width: 8px; }
.ciq-sidebar::-webkit-scrollbar-thumb, .ciq-side-nav::-webkit-scrollbar-thumb { background: var(--ciq-border); border-radius: 8px; }
.ciq-sidebar::-webkit-scrollbar-track, .ciq-side-nav::-webkit-scrollbar-track { background: transparent; }
.ciq-sidebar, .ciq-side-nav { scrollbar-width: thin; scrollbar-color: var(--ciq-border) transparent; }

/* ---------- Mobile: sidebar becomes overlay ---------- */
@media (max-width: 991px) {
  .ciq-sidebar { transform: translateX(-100%); box-shadow: var(--ciq-shadow-float); }
  .ciq-sidebar.open { transform: none; }
  .ciq-main { margin-left: 0; }
  .ciq-content { padding: 1rem; }
  .ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar { width: 248px; flex-basis: 248px; }
  .ciq-admin-wrap.ciq-side-collapsed .ciq-main { margin-left: 0; }
  .ciq-admin-wrap.ciq-side-collapsed .ciq-nav-label,
  .ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar-brand small,
  .ciq-admin-wrap.ciq-side-collapsed .ciq-side-foot a span { display: revert; }
  .ciq-admin-wrap.ciq-side-collapsed .ciq-side-nav a { justify-content: flex-start; }
  .ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar-brand { font-size: 1.3rem; }
  .ciq-admin-wrap.ciq-side-collapsed .ciq-sidebar-brand::after { content: none; }
}

/* Print: keep printouts clean */
@media print {
  .ciq-sidebar, .ciq-topbar-admin, .ciq-admin-foot { display: none !important; }
  .ciq-main { margin-left: 0; }
  .ciq-admin { background: #fff; }
}
