/* =========================================================
   Bochat360 • assets/css/app.css  (v3 — advanced / pro / stylish)
   Built on Bootstrap 5.3.x
   ========================================================= */

/* ---------- THEME TOKENS ---------- */
:root {
  --brand: #1294d6;
  --brand-soft: color-mix(in srgb, var(--brand) 8%, transparent);
  --brand-ink: #0a5a7a;
  --accent: #facc15;
  --danger-soft: rgba(248,113,113,.12);

  --body: #0f172a;
  --muted: #6b7280;

  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e7eb;

  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 0 rgba(2,6,23,.05);
  --shadow-md: 0 6px 24px rgba(2,6,23,.08);
  --shadow-lg: 0 14px 36px rgba(15,23,42,.14);

  --container-pad-x: clamp(14px, 2.4vw, 28px);
  --footer-offset: 72px; /* JS in footer will override this with actual height */
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --focus-ring: 0 0 0 .22rem color-mix(in srgb, var(--brand) 28%, transparent);

  /* extras for stylish bits */
  --tile-radius: 16px;
  --tile-border: color-mix(in srgb, var(--border) 88%, transparent);
  --hero-grad: linear-gradient(180deg,
                    color-mix(in srgb, var(--brand) 5%, var(--surface)) 0%,
                    var(--surface) 100%);

  /* NEW: gradient system reused site-wide */
  --grad-1: radial-gradient(
              1400px 700px at 60% -10%,
              color-mix(in srgb, var(--brand) 18%, #ffffff 30%) 0%,
              transparent 70%
            );
  --grad-2: radial-gradient(
              900px 500px at 10% 120%,
              color-mix(in srgb, var(--accent) 12%, transparent) 0%,
              transparent 65%
            );
}

/* Keep dark-ready but force light later */
@media (prefers-color-scheme: dark) {
  :root {
    --body: #e5e7eb;
    --muted: #9ca3af;
    --surface: #0b1220;
    --surface-2: #0f172a;
    --border: #1f2937;
    --shadow-sm: 0 1px 0 rgba(0,0,0,.25);
    --shadow-md: 0 6px 24px rgba(0,0,0,.32);
    --shadow-lg: 0 14px 36px rgba(0,0,0,.55);
  }
}

/* ---------- GLOBAL ---------- */
html, body { height: 100%; }
body {
  color: var(--body);
  background:
    var(--grad-1),
    var(--grad-2),
    var(--surface-2);
  font-feature-settings: "ss01" 1, "cv01" 1, "cv02" 1;
  padding-bottom: calc(var(--footer-offset) + var(--safe-bottom));
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: 2px;
  border-radius: 6px;
}
.container, .container-fluid, .container-lg {
  padding-left: var(--container-pad-x);
  padding-right: var(--container-pad-x);
}
i.bi { vertical-align: -0.1em; }

/* =========================================================
   APP SHELL (header + sidebar) — cleaner, more SaaS-y
   ========================================================= */
.navbar.sticky-top {
  backdrop-filter: saturate(140%) blur(4px);
  background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
  border-bottom: 1px solid var(--border) !important;
  min-height: 56px;
}

/* 🔥 FIX: Prevent content sliding under navbar */
main.col-12,
main.col-md-9,
main.col-lg-10 {
  padding-top: 76px !important;
}

.navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: -.02em;
  display: flex;
  gap: .4rem;
  align-items: center;
}
.navbar .navbar-brand .brand-dot {
  width: 24px; height: 24px;
  border-radius: 8px;
  background: radial-gradient(circle, #fff 0%, var(--brand) 60%);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--brand) 35%, transparent);
}
.navbar .nav-link { padding: .5rem .7rem; border-radius: .5rem; }
.navbar .nav-link.active,
.navbar .nav-link:focus-visible {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--body);
}

/* Older sticky helper (still OK if used) */
.sidebar-sticky {
  position: sticky;
  top: 56px;
  max-height: calc(100vh - 56px);
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 1rem .8rem 1rem;
  background: var(--surface);
  border-right: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.sidebar-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: .4rem 0 .5rem .25rem;
}
.sidebar-link{
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .45rem .65rem;
  border-radius: .6rem;
  color: var(--bs-body-color);
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
  font-size: .88rem;
}
.sidebar-link i { color: #94a3b8; }
.sidebar-link:hover {
  background: color-mix(in srgb, var(--brand) 4%, transparent);
}
.sidebar-link.active {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
  font-weight: 600;
}
.offcanvas-start { width: 280px !important; }
.offcanvas-backdrop.show { opacity: .25 !important; }

/* =========================================================
   LAYOUT HEIGHT — sidebar + main fit viewport nicely
   (between navbar (56px) and sticky footer)
   ========================================================= */
.container-fluid > .row {
  min-height: calc(100vh - 56px - var(--footer-offset));
}

aside.bochat-sidebar-shell,
aside[class*="col-"] {
  min-height: calc(100vh - 56px - var(--footer-offset)) !important;
  display: flex;
  flex-direction: column;
}

.bochat-sidebar-inner {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

main.col-12,
main.col-md-9,
main.col-lg-10 {
  min-height: calc(100vh - 56px - var(--footer-offset));
  padding-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
}

main.col-12 > *:last-child,
main.col-md-9 > *:last-child,
main.col-lg-10 > *:last-child {
  margin-bottom: 0;
}

@media (max-width: 767.98px){
  .container-fluid > .row {
    min-height: auto;
  }
  aside.bochat-sidebar-shell,
  aside[class*="col-"],
  main.col-12,
  main.col-md-9,
  main.col-lg-10 {
    min-height: auto !important;
  }
}

/* =========================================================
   DASHBOARD HERO / SECTION HEADER
   ========================================================= */
.hero-box{
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--hero-grad);
  box-shadow: var(--shadow-md);
  padding: clamp(1rem, 2vw, 1.4rem);
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.hero-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.hero-sub {
  color: var(--muted);
  font-size: .8rem;
}
@media (max-width: 768px){
  .hero-box { flex-direction: column; align-items: flex-start; }
}

/* =========================================================
   KPI / METRIC CARDS — stylish, still Bootstrap-friendly
   ========================================================= */
.kpi-card {
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
  background: radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--brand) 2%, #fff) 0%, #fff 48%);
  box-shadow: 0 6px 20px rgba(15,23,42,.02);
}
.kpi-label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .65rem;
  color: #94a3b8;
}
.kpi-value {
  font-size: 2.05rem;
  font-weight: 700;
  margin-top: .35rem;
}
.kpi-meta {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .5rem;
  border-radius: 999px;
  font-size: .625rem;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  color: var(--brand-ink);
}

/* =========================================================
   CARDS / PANELS
   ========================================================= */
.card{
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card.shadow-sm{ box-shadow: var(--shadow-md) !important; }
.card-header{
  background: color-mix(in srgb, var(--surface) 96%, var(--border));
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

/* =========================================================
   TABLES — pro, sticky head, mobile scroll
   ========================================================= */
.table {
  --tbl-pad-y: .55rem;
  --tbl-pad-x: .6rem;
}
.table>:not(caption)>*>* { padding: var(--tbl-pad-y) var(--tbl-pad-x); }
.table thead th {
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid var(--border) !important;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr:hover {
  background: color-mix(in srgb, var(--surface) 98%, var(--border));
}
.table .btn {
  --bs-btn-padding-y: .25rem;
  --bs-btn-padding-x: .5rem;
  --bs-btn-font-size: .8125rem;
}
.table-responsive {
  -webkit-overflow-scrolling: touch;
  box-shadow: inset 10px 0 8px -10px rgba(2,6,23,.03),
              inset -10px 0 8px -10px rgba(2,6,23,.03);
  border-radius: var(--radius);
}

/* =========================================================
   PRINT
   ========================================================= */
@media print{
  .navbar, aside, .app-footer, .offcanvas{ display: none !important; }
  main{ padding: 0 !important; }
  body{ background: #fff !important; }
  .card, .table, .table thead th{ box-shadow: none !important; }
}

/* Remove old unwanted offset logic */
@media (min-width: 992px){
  main#main-content {
    margin-left: 0 !important;
    transition: none;
  }
  .is-collapsed + main#main-content {
    margin-left: 0 !important;
  }
}
