/* =========================================================
   GiftCard Pro – Dashboard styles
   Built on Bootstrap 5.3 (uses its data-bs-theme switch)
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  --sidebar-w: 272px;
  --topbar-h: 72px;
  --radius: 16px;

  --primary: #5b3df5;
  --primary-hover: #4a2ee0;
  --primary-soft: rgba(91, 61, 245, .1);

  --bg: #f5f6fc;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --border: #e9ebf5;
  --text: #14163a;
  --muted: #6b7096;
  --shadow: 0 1px 2px rgba(20, 22, 58, .04), 0 8px 24px rgba(20, 22, 58, .05);

  --sidebar-bg: linear-gradient(180deg, #16145a 0%, #0d0b38 100%);
  --sidebar-text: #b9bce6;
  --sidebar-active: linear-gradient(90deg, #5b45e8, #4a3bd0);

  --success: #1fa65a;

  /* Bootstrap overrides */
  --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-primary: var(--primary);
  --bs-primary-rgb: 91, 61, 245;
  --bs-link-color: var(--primary);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
}

[data-bs-theme="dark"] {
  --primary: #7a64ff;
  --primary-hover: #8f7cff;
  --primary-soft: rgba(122, 100, 255, .16);

  --bg: #0a0c1b;
  --surface: #131630;
  --surface-2: #191d3b;
  --border: #252a4d;
  --text: #e9ebff;
  --muted: #9aa1cf;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);

  --sidebar-bg: linear-gradient(180deg, #0c0b2e 0%, #070620 100%);
  --sidebar-text: #a9acd9;

  --bs-primary-rgb: 122, 100, 255;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
body {
  font-family: var(--bs-font-sans-serif);
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .25s ease, color .25s ease;
}
a { text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover);
  --bs-btn-active-bg: var(--primary-hover);
  --bs-btn-active-border-color: var(--primary-hover);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
  font-weight: 600;
  border-radius: 10px;
}

.dropdown-menu {
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-link-hover-bg: var(--surface-2);
  --bs-dropdown-divider-bg: var(--border);
  border-radius: 12px;
  font-size: .875rem;
  --bs-dropdown-link-active-bg: var(--primary);
}

/* ---------- Layout ---------- */
.app-main {
  min-height: 100vh;
  transition: margin-left .25s ease;
}
@media (min-width: 992px) {
  .app-main { margin-left: var(--sidebar-w); }
  body.sidebar-collapsed .app-main { margin-left: 0; }
}

.content {
  padding: 1.25rem 1rem 2.5rem;
  max-width: 1760px;
  margin-inline: auto;
}
@media (min-width: 576px) { .content { padding: 1.5rem 1.5rem 3rem; } }
@media (min-width: 1200px) { .content { padding: 1.75rem 2rem 3rem; } }

/* ---------- Sidebar ---------- */
.sidebar { --bs-offcanvas-width: 288px; --bs-offcanvas-bg: transparent; border: 0; }

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1.25rem .9rem 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (min-width: 992px) {
  .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0;
    width: var(--sidebar-w) !important;
    height: 100vh !important;
    z-index: 1040;
    transition: transform .25s ease;
    visibility: visible !important;
  }
  body.sidebar-collapsed .sidebar { transform: translateX(-100%) !important; visibility: hidden !important; }
}

.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem 1.5rem; }
.brand-mark {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  font-size: 1.4rem; color: #fff;
  border-radius: 12px;
  background: linear-gradient(135deg, #a55bff, #6b3cf0);
  box-shadow: 0 6px 16px rgba(107, 60, 240, .45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { color: #fff; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { font-size: .7rem; color: var(--sidebar-text); white-space: nowrap; }

.sidebar-nav { display: flex; flex-direction: column; gap: .2rem; }

.nav-item-gc {
  display: flex; align-items: center; gap: .85rem;
  width: 100%;
  padding: .7rem .85rem;
  border: 0; background: transparent;
  color: var(--sidebar-text);
  font-size: .9rem; font-weight: 500; text-align: left;
  border-radius: 10px;
  transition: background-color .15s, color .15s;
}
.nav-item-gc i:first-child { font-size: 1.2rem; width: 1.4rem; text-align: center; flex: none; }
.nav-item-gc:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-item-gc.active {
  color: #fff; font-weight: 600;
  background: var(--sidebar-active);
  box-shadow: 0 6px 16px rgba(74, 59, 208, .35);
}
.nav-item-gc .caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.nav-item-gc[aria-expanded="true"] .caret { transform: rotate(180deg); }
.nav-item-gc[aria-expanded="true"] { color: #fff; }

.sub-nav { list-style: none; margin: .1rem 0 .3rem; padding: 0 0 0 3.05rem; }
.sub-nav a {
  display: block; padding: .5rem .5rem;
  color: var(--sidebar-text); font-size: .85rem; border-radius: 8px;
}
.sub-nav a:hover { color: #fff; background: rgba(255, 255, 255, .05); }

.sidebar-promo {
  margin-top: auto;
  padding: 1.1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-nav + .sidebar-promo { margin-top: 1.5rem; }
.sidebar-promo .promo-icon {
  width: 42px; height: 42px; display: grid; place-items: center;
  font-size: 1.2rem; color: #fff; border-radius: 12px; margin-bottom: .8rem;
  background: linear-gradient(135deg, #7b5cff, #5a3df0);
}
.sidebar-promo h6 { color: #fff; font-weight: 700; margin-bottom: .35rem; }
.sidebar-promo p { font-size: .8rem; margin-bottom: .9rem; color: var(--sidebar-text); }
.sidebar-promo .btn { padding: .5rem 1rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 576px) { .topbar { padding: 0 1.5rem; gap: 1rem; } }
@media (min-width: 1200px) { .topbar { padding: 0 2rem; } }

.icon-btn {
  position: relative;
  width: 40px; height: 40px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text);
  font-size: 1.25rem;
  transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.icon-btn.sm { width: 32px; height: 32px; font-size: 1.1rem; color: var(--muted); }
.icon-btn.has-dot::after {
  content: ""; position: absolute; top: 8px; right: 9px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #ef3b4d; border: 2px solid var(--surface);
}
#themeToggle { font-size: 1.1rem; }
#themeToggle .theme-icon-dark { display: none; color: #ffc94d; }
#themeToggle .theme-icon-light { color: var(--primary); }
[data-bs-theme="dark"] #themeToggle .theme-icon-dark { display: inline; }
[data-bs-theme="dark"] #themeToggle .theme-icon-light { display: none; }

.biz-btn, .user-btn {
  display: flex; align-items: center; gap: .65rem;
  background: transparent; border: 0; padding: .25rem .4rem;
  border-radius: 12px; color: var(--text); text-align: left;
}
.biz-btn:hover, .user-btn:hover { background: var(--surface-2); }
.biz-logo {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center; font-size: 1.35rem; color: #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb347, #ff6a3d);
  box-shadow: 0 0 0 3px color-mix(in srgb, #ff8a3d 20%, transparent);
}
.biz-info, .user-info { display: flex; flex-direction: column; line-height: 1.25; }
.biz-info strong, .user-info strong { font-size: .9rem; font-weight: 600; white-space: nowrap; }
.biz-info small, .user-info small { font-size: .75rem; color: var(--muted); white-space: nowrap; }

.badge-biz {
  align-items: center; gap: .4rem;
  padding: .4rem .8rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
}
.topbar-divider { width: 1px; height: 32px; background: var(--border); }
.avatar {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  font-size: .85rem; font-weight: 700; color: #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a2870, #14124f);
}
[data-bs-theme="dark"] .avatar { background: linear-gradient(135deg, #5b45e8, #3a2bb0); }

/* ---------- Page heading ---------- */
.page-title { font-size: clamp(1.35rem, 1rem + 1.2vw, 1.75rem); font-weight: 700; letter-spacing: -.02em; margin: 0 0 .2rem; }
.page-sub { color: var(--muted); font-size: .9rem; }

.btn-range {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .6rem .95rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow);
}
.btn-range i:first-child { color: var(--primary); }
.btn-range:hover { border-color: var(--primary); }

/* ---------- Cards ---------- */
.gc-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: background-color .25s, border-color .25s;
}
@media (min-width: 576px) { .gc-card { padding: 1.4rem 1.5rem; } }

.card-title-gc { font-size: 1.05rem; font-weight: 700; margin: 0 0 1.1rem; letter-spacing: -.01em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head .card-title-gc { margin-bottom: 0; }
.link-all { font-size: .82rem; font-weight: 600; color: var(--primary); white-space: nowrap; }
.link-all:hover { text-decoration: underline; }

/* KPI */
.stat-card { display: flex; align-items: center; gap: 1rem; height: 100%; }
.stat-icon {
  width: 56px; height: 56px; flex: none;
  display: grid; place-items: center;
  font-size: 1.5rem; color: #fff; border-radius: 50%;
}
.stat-icon .naira { font-size: 1.6rem; font-weight: 600; line-height: 1; }
.bg-violet { background: linear-gradient(135deg, #8a5cff, #5b3df5); box-shadow: 0 8px 18px rgba(91, 61, 245, .3); }
.bg-green  { background: linear-gradient(135deg, #2ccf7a, #159a52); box-shadow: 0 8px 18px rgba(31, 166, 90, .3); }
.bg-blue   { background: linear-gradient(135deg, #4d8bff, #2556e8); box-shadow: 0 8px 18px rgba(47, 107, 255, .3); }
.bg-orange { background: linear-gradient(135deg, #ffb340, #f08a10); box-shadow: 0 8px 18px rgba(245, 154, 31, .3); }

.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: clamp(1.4rem, 1.1rem + .9vw, 1.7rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.25; margin: .1rem 0 .15rem; }
.stat-trend { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .35rem; font-size: .8rem; font-weight: 600; color: var(--success); }
.stat-trend small { font-weight: 400; color: var(--muted); font-size: .72rem; white-space: nowrap; }

/* Donut */
.status-overview { display: flex; align-items: center; min-height: 250px; gap: 1.75rem; flex-wrap: wrap; justify-content: center; }
.donut { position: relative; width: 210px; height: 210px; flex: none; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut svg circle { fill: none; stroke-width: 6.5; transition: stroke-width .15s, opacity .15s; }
.donut svg .track { stroke: var(--surface-2); }
.donut svg.dim circle.seg { opacity: .35; }
.donut svg.dim circle.seg.hl { opacity: 1; stroke-width: 7.5; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-center strong { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.donut-center span { font-size: .8rem; color: var(--muted); }

.status-legend { list-style: none; padding: 0; margin: 0; flex: 1 1 280px; min-width: 0; }
.status-legend li {
  display: grid; grid-template-columns: 14px 1fr auto 56px; align-items: center; gap: .75rem;
  padding: .72rem .25rem; border-bottom: 1px solid var(--border);
  font-size: .86rem; cursor: default;
}
.status-legend li:last-child { border-bottom: 0; }
.status-legend .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.status-legend .num { font-weight: 600; text-align: right; min-width: 2ch; }
.status-legend .pct { color: var(--muted); text-align: right; font-size: .8rem; }
.status-legend li:hover { background: var(--surface-2); border-radius: 8px; }

/* Tables */
.table-gc {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--surface-2);
  --bs-table-hover-color: var(--text);
  font-size: .84rem;
  white-space: nowrap;
}
.table-gc thead th {
  background: var(--surface-2);
  color: var(--muted); font-weight: 500; font-size: .78rem;
  padding: .7rem .85rem;
  border-bottom: 0;
}
.table-gc thead th:first-child { border-radius: 10px 0 0 10px; }
.table-gc thead th:last-child  { border-radius: 0 10px 10px 0; }
.table-gc tbody td { padding: .85rem .85rem; border-color: var(--border); }
.table-gc tbody tr:last-child td { border-bottom: 0; }
.table-gc tbody tr:hover > * { background: var(--surface-2); }
.table-gc .code { font-weight: 500; }

/* Status pills */
.status {
  --c: #6b7096;
  display: inline-block;
  padding: .28rem .7rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.3;
  color: color-mix(in srgb, var(--c) 82%, #000);
  background: color-mix(in srgb, var(--c) 15%, transparent);
}
[data-bs-theme="dark"] .status { color: color-mix(in srgb, var(--c) 62%, #fff); }
.s-active    { --c: #1fa65a; }
.s-confirmed { --c: #1fa65a; }
.s-partial   { --c: #7b4dff; }
.s-paid      { --c: #2f6bff; }
.s-pending   { --c: #e8a40c; }
.s-redeemed  { --c: #1e9fb4; }
.s-expired   { --c: #e5304a; }

/* Shortcut cards */
.action-card {
  position: relative; display: block; height: 100%;
  padding: 1.25rem 1.3rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text);
  background-image: linear-gradient(135deg, var(--tint-a), var(--tint-b));
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.action-card:hover { transform: translateY(-3px); border-color: var(--tc); color: var(--text); box-shadow: 0 14px 30px rgba(20, 22, 58, .1); }
.action-card h3 { font-size: 1rem; font-weight: 700; margin: .9rem 0 .3rem; }
.action-card p { font-size: .8rem; color: var(--muted); margin: 0; padding-right: 2.2rem; min-height: 2.4em; }
.action-icon {
  width: 46px; height: 46px; display: grid; place-items: center;
  font-size: 1.3rem; border-radius: 50%;
  color: var(--tc);
  background: color-mix(in srgb, var(--tc) 14%, var(--surface));
}
.action-card .go { position: absolute; right: 1.2rem; bottom: 1.1rem; font-size: 1.1rem; color: var(--tc); transition: transform .18s; }
.action-card:hover .go { transform: translateX(4px); }

.tint-violet { --tc: #5b3df5; --tint-a: #f3effe; --tint-b: #ffffff; }
.tint-blue   { --tc: #2f6bff; --tint-a: #edf3ff; --tint-b: #ffffff; }
.tint-green  { --tc: #1fa65a; --tint-a: #ebf8f0; --tint-b: #ffffff; }
.tint-red    { --tc: #e5304a; --tint-a: #fdeef0; --tint-b: #ffffff; }
[data-bs-theme="dark"] .tint-violet { --tc: #9a86ff; --tint-a: rgba(122, 100, 255, .16); --tint-b: var(--surface); }
[data-bs-theme="dark"] .tint-blue   { --tc: #6c9bff; --tint-a: rgba(77, 139, 255, .15);  --tint-b: var(--surface); }
[data-bs-theme="dark"] .tint-green  { --tc: #3fd484; --tint-a: rgba(44, 207, 122, .13);  --tint-b: var(--surface); }
[data-bs-theme="dark"] .tint-red    { --tc: #ff6a80; --tint-a: rgba(255, 90, 115, .14);  --tint-b: var(--surface); }

/* Quick actions */
.quick-list { list-style: none; margin: 0; padding: 0; }
.quick-list li { border-bottom: 1px solid var(--border); }
.quick-list li:last-child { border-bottom: 0; }
.quick-list a {
  display: flex; align-items: center; gap: .9rem;
  padding: .85rem .35rem;
  color: var(--text); font-size: .88rem; border-radius: 10px;
}
.quick-list a > i:first-child { font-size: 1.15rem; color: var(--primary); width: 1.4rem; text-align: center; }
.quick-list a > span { flex: 1; min-width: 0; }
.quick-list a > i:last-child { color: var(--muted); font-size: .8rem; transition: transform .15s; }
.quick-list a:hover { background: var(--surface-2); color: var(--text); }
.quick-list a:hover > i:last-child { transform: translateX(3px); color: var(--primary); }

/* ---------- Responsive tweaks ---------- */

/* Compact tables + hide the (repeated) business column where space is tight */
.table-gc thead th, .table-gc tbody td { padding-inline: .65rem; }
@media (min-width: 576px) and (max-width: 1199.98px), (min-width: 1400px) and (max-width: 1599.98px) {
  .col-biz { display: none; }
}
@media (min-width: 1200px) { .stat-card { padding: 1.25rem; gap: .9rem; } .stat-icon { width: 52px; height: 52px; } }


/* Phones: tables become stacked cards */
@media (max-width: 575.98px) {
  .table-gc { white-space: normal; }
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody { display: block; }
  .table-stack tbody tr {
    display: block;
    padding: .55rem .9rem;
    margin-bottom: .75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
  }
  .table-stack tbody tr:last-child { margin-bottom: 0; }
  .table-stack tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .4rem 0; border: 0; text-align: right !important;
    background: transparent !important;
  }
  .table-stack tbody td::before {
    content: attr(data-label);
    color: var(--muted); font-size: .76rem; font-weight: 500; text-align: left;
  }
  .table-stack tbody td.code { font-size: .95rem; font-weight: 700; padding-bottom: .55rem; margin-bottom: .2rem; border-bottom: 1px dashed var(--border); }
  .table-stack tbody td[data-label="Actions"] { justify-content: space-between; }

  .donut { width: 180px; height: 180px; }
  .status-overview { gap: 1rem; }
  .status-legend { flex-basis: 100%; }
  .status-legend li { grid-template-columns: 14px 1fr auto 48px; gap: .6rem; }

  .stat-icon { width: 50px; height: 50px; font-size: 1.35rem; }
}

@media (max-width: 380px) {
  .topbar { gap: .35rem; padding: 0 .6rem; }
  .icon-btn { width: 36px; height: 36px; }
  .biz-logo, .avatar { width: 36px; height: 36px; }
}

/* Large / ultra-wide screens */
@media (min-width: 1600px) {
  body { font-size: .95rem; }
  .donut { width: 230px; height: 230px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* Print */
@media print {
  .sidebar, .topbar, .action-card .go { display: none !important; }
  .app-main { margin: 0 !important; }
}
