/* =========================================================
   TechGeeks Platform — Corporate UI (Light Content + Dark Chrome)
   ✅ Fully responsive + auto-adjusts to any screen resolution
   ✅ Full app fits viewport; ONLY .content scrolls (no page cut-off)
   ✅ Fluid spacing / fonts via clamp()
   ✅ Sidebar scrolls independently on desktop if nav is long
   ✅ Mobile drawer works; prevents sideways overflow
   ========================================================= */

/* =========================
   1) Tokens (FLUID)
========================= */
:root{
  --brand: #f7941d;
  --brand-soft: #fde6c8;

  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-muted: #fafafa;
  --border: #e3e6eb;

  --text: #1f2937;
  --muted: #6b7280;

  --chrome-bg: #ffffff;
  --chrome-panel: #ffffff;
  --chrome-border: #e3e6eb;
  --chrome-text: #111827;
  --chrome-muted: #6b7280;
  --chrome-hover: #f4f6fb;

  --chrome-active-bg: var(--brand-soft);
  --chrome-active-border: var(--brand);

  /* FLUID sizing */
  --pad: clamp(10px, 1.2vw, 18px);
  --gap: clamp(10px, 1.2vw, 18px);
  --content-pad: clamp(12px, 1.4vw, 22px);

  --radius: clamp(10px, 1vw, 14px);
  --radius-sm: clamp(8px, 0.8vw, 12px);

  --fs-title: clamp(16px, 1.1vw, 20px);
  --fs-body: clamp(13px, 0.95vw, 15px);

  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

  /* Sidebar width adapts */
  --sidebar-w: clamp(220px, 18vw, 300px);

  /* App max width (set to none/100% if you want full-bleed) */
  --app-max: none;
}

/* (kept for future use; harmless if theme toggle removed) */
html[data-theme="dark"]{
  --chrome-bg: #0a1020;
  --chrome-panel: #0c1427;
  --chrome-border: #1e2a44;
  --chrome-text: #e5e7eb;
  --chrome-muted: #9aa4b2;
  --chrome-hover: #0f1a33;

  --chrome-active-bg: #142645;
  --chrome-active-border: #3b82f6;
}

/* =========================
   2) Base / Viewport Lock
========================= */
*{ box-sizing:border-box; }

html, body{ height:100%; }

html{
  overflow: hidden;              /* app controls scrolling */
}

body{
  margin:0;
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;              /* prevent page scroll/cutoff issues */
  font-size: var(--fs-body);
}

a{ color: inherit; text-decoration:none; }
.muted{ color: var(--muted); }

/* =========================
   3) Typography
========================= */
.page-title{
  font-size: var(--fs-title);
  font-weight:900;
  margin:0 0 12px;
}

/* =========================
   4) Buttons / Links
========================= */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:9px 12px;
  border-radius: var(--radius-sm);
  font-size:13px;
  font-weight:800;
  border:1px solid var(--border);
  background: var(--panel);
  cursor:pointer;
}

.btn-primary{
  background: var(--brand);
  border-color: var(--brand);
  color:#111;
}
.btn-primary:hover{ filter:brightness(0.97); }

.btn-ghost{
  background: transparent;
  border:1px solid transparent;
}

.link-btn{
  background: transparent;
  border:none;
  padding:0;
  font: inherit;
  cursor:pointer;
  color: inherit;
  opacity:.9;
}
.link-btn:hover{ text-decoration:underline; }

/* =========================
   5) Forms
========================= */
label{
  font-size:12px;
  font-weight:800;
  margin:12px 0 6px;
  display:block;
}

input, select{
  width:100%;
  padding:10px 12px;
  border-radius: var(--radius-sm);
  border:1px solid var(--border);
  background:#fff;
}

input:focus, select:focus{
  outline:none;
  border-color: var(--brand);
  box-shadow:0 0 0 3px rgba(247,148,29,0.20);
}

/* =========================
   6) Alerts
========================= */
.alert{
  padding:10px 12px;
  border-radius: var(--radius-sm);
  font-size:13px;
  background:#fef3c7;
  border:1px solid #fde68a;
}
.alert-error{
  background:#fff1f2;
  border:1px solid #fecdd3;
  color:#9f1239;
}

/* =========================
   7) Auth Pages (Login/Reset)
   (Auth pages can scroll naturally; don't lock overflow)
========================= */
.auth-wrap{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  overflow: auto;
}

.auth-card{
  width:100%;
  max-width:420px;
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:22px;
  box-shadow: var(--shadow);
}

.brand{ display:flex; align-items:center; gap:10px; margin-bottom:16px; }
.brand-centered{ justify-content:center; padding:6px 0 2px; }
.brand-logo-lg{ height:52px; width:auto; display:block; }

.auth-row{ display:flex; justify-content:space-between; align-items:center; margin-top:10px; }
.auth-link{ font-size:12px; color: var(--muted); }
.auth-link:hover{ text-decoration:underline; }

.auth-btn{ width:100%; margin-top:14px; }
.auth-footer{ text-align:center; margin-top:16px; font-size:12px; }

/* =========================
   8) App Layout (Viewport-fit)
   - Shell fits viewport
   - Sidebar scrolls if long
   - Content area scrolls (only)
========================= */
.shell{
  display:flex;
  height: 100dvh;
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;

  gap: var(--gap);
  padding: var(--pad);
  background: var(--bg);

  overflow: hidden;              /* no sideways/page overflow */
}

/* Sidebar */
.sidebar{
  width: var(--sidebar-w);
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--chrome-text);
  box-shadow: var(--shadow);

  /* ✅ shrink to content */
  height: auto;
  align-self: flex-start;

  /* ✅ but don't exceed viewport; scroll only if longer */
  max-height: calc(100vh - (var(--pad) * 2));
  max-height: calc(100dvh - (var(--pad) * 2));
  overflow: auto;
  -webkit-overflow-scrolling: touch;

  position: relative;
  flex: 0 0 auto;
}

.sidebar-brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  border-radius: var(--radius);
  border:1px solid var(--chrome-border);
  background: var(--chrome-panel);
  margin-bottom:12px;
}
.sidebar-logo{ height:32px; width:auto; display:block; }

.nav{ display:flex; flex-direction:column; gap:8px; }
.nav-divider{ height:1px; background: var(--chrome-border); margin:10px 6px; }

.main{
  flex:1;
  min-width: 0;

  /* critical: allow inner scrolling area */
  display:flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================
   8b) Topbar (All screens)
========================= */
.topbar{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(10px, 1.1vw, 16px) clamp(12px, 1.2vw, 18px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--chrome-text);
  box-shadow: var(--shadow);
  gap: 14px;

  /* stays visible while content scrolls */
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Left side: crumbs */
.crumbs{
  display:flex;
  align-items:center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--chrome-muted);
}

.crumb-trail{
  display:flex;
  align-items:center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.crumb-trail a{
  font-size: clamp(16px, 1.1vw, 18px);
  font-weight: 900;
  opacity: .96;
}
.crumb-trail a:hover{ text-decoration: underline; }

.crumb-sep{
  color: var(--muted);
  opacity: .8;
  font-weight: 800;
}

.crumb-active{
  flex: 1 1 auto;
  min-width: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

/* Right side: user + logout icon */
.topbar-right{
  display:flex;
  align-items:center;
  gap: 10px;
  flex: 0 0 auto;
}

.topbar-right .muted{
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* Logout icon button */
.logout-btn{
  width: 36px;
  height: 36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  cursor:pointer;
  transition: background .15s ease, border-color .15s ease;
}
.logout-btn:hover{
  background:#fff1f2;
  border-color:#fecdd3;
}
.logout-btn i{ font-size: 15px; }

/* Content (ONLY scroll area on desktop/tablet) */
.content{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;

  padding: var(--content-pad);
  width: 100%;
  max-width: none;
  margin: 0;

  animation: contentFade .12s ease-out;
}
@keyframes contentFade{
  from{ opacity:.65; transform: translateY(2px); }
  to{ opacity:1; transform: translateY(0); }
}

/* =========================
   9) Sidebar Accordion
========================= */
.nav-group{ display:block; }

.nav-item{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding:10px 12px;
  border-radius: var(--radius-sm);
  font-size:13px;
  font-weight:800;
  border:1px solid transparent;
  color: var(--chrome-text);
  background: transparent;
}

.nav-row{
  display:flex;
  align-items:center;
  gap:8px;
}

.nav-row > .nav-item{
  flex: 1 1 auto;
  min-width: 0;
}

.nav-row > .nav-caret-btn{
  flex: 0 0 auto;
  margin-left: auto;
}

.nav-item:hover{ background: var(--chrome-hover); }

.nav-item.active{
  background: var(--chrome-active-bg);
  border-color: var(--chrome-active-border);
}

.nav-item i{ width:18px; text-align:center; opacity:.92; }

.nav-label{
  flex:1;
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.nav-caret-btn{
  flex:0 0 auto;
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius: var(--radius-sm);
  border:1px solid transparent;
  background: transparent;
  color: var(--chrome-muted);
  cursor:pointer;
}
.nav-caret-btn:hover{
  background: var(--chrome-hover);
  color: var(--chrome-text);
}

.nav-caret{
  display:inline-block;
  transform: rotate(0deg);
  transition: transform .15s ease;
}

.nav-sub{
  overflow:hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .18s ease, opacity .15s ease;
  margin-left: 28px;
  padding-left: 10px;
  border-left: 1px solid var(--chrome-border);
}
.nav-group.is-open > .nav-sub{
  border-left-color: var(--chrome-active-border);
}
.nav-sub-item.active{
  position: relative;
}
.nav-sub-item.active::before{
  content: "";
  position: absolute;
  left: -11px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--chrome-active-border);
  border-radius: 2px;
}
.nav-group.is-open .nav-sub{
  opacity: 1;
  max-height: 600px;
  margin-top: 8px;
  margin-bottom: 10px;
}
.nav-group.is-open .nav-caret{ transform: rotate(90deg); }

.nav-sub-item{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
  padding:9px 10px;
  margin: 0 0 6px 0;
  border-radius: var(--radius-sm);
  font-size:13px;
  font-weight:700;
  border:1px solid transparent;
  color: var(--chrome-muted);
  background: transparent;
}
.nav-sub-item i{ width:16px; text-align:center; opacity:.85; }
.nav-sub-item:hover{ background: var(--chrome-hover); color: var(--chrome-text); }
.nav-sub-item.active{
  background: var(--chrome-active-bg);
  border-color: var(--chrome-active-border);
  color: var(--chrome-text);
}

html[data-theme="dark"] .nav-sub-item.active::before{
  box-shadow: 0 0 6px rgba(59,130,246,.6);
}

/* =========================
   10) Cards / Modules
========================= */
.card{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:14px;
}

.card h2{ font-size:15px; margin:0; }

.card-desc{
  margin:6px 0 10px;
  font-size:13px;
  line-height:1.45;
  color: var(--muted);
}

.module-grid{
  display:grid;
  gap:14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.module-card{
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  transition: transform .08s ease, box-shadow .08s ease;
}

.module-card:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
}

.module-title{
  display:flex;
  align-items:center;
  gap:10px;
}
.module-title i{ opacity:.92; }

.module-actions{ margin-top: 10px; }

/* =========================
   11) Mobile Drawer (sidebar)
========================= */
.mobile-only{ display:none; }

.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:40px;
  height:40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--chrome-text);
  cursor:pointer;
}
.icon-btn:hover{
  background: var(--chrome-hover);
  border-color: var(--chrome-border);
}

.mobile-overlay{ display:none; }

/* =========================
   12) Responsive
========================= */

/* Large screens: slightly more breathing room (auto via clamp already; just subtle) */
@media (min-width: 1600px){
  :root{
    --app-max: none; /* keep full-bleed; set e.g. 1800px if you want a cap */
  }
}

/* Tablet / Mobile */
@media (max-width: 900px){

  .mobile-only{ display:inline-flex; }

  /* Layout becomes vertical */
  .shell{
    flex-direction: column;
    padding: var(--pad);
    gap: var(--gap);
  }

  /* On mobile, allow page to fit and content to scroll; keep locked app scroll model */
  .sidebar{
    display: none;

    /* drawer state */
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(var(--sidebar-w), 86vw);
    z-index: 1000;

    padding: 14px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);

    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    height: auto;
  }

  .sidebar.is-open{
    display: inline-block;
  }

  .mobile-overlay{
    display:block;
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0,0,0,.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease-out;
  }
  .mobile-overlay.is-open{
    opacity: 1;
    pointer-events: auto;
  }

  body.no-scroll{ overflow:hidden; }

  .main{
    width: 100%;
    min-width: 0;
  }

  .content{
    width: 100%;
    padding: var(--content-pad);
    min-width: 0;
  }

  /* Modules/cards */
  .module-grid{ grid-template-columns: 1fr; }
  .module-card{ padding: 16px; }
  .module-card .btn{ width:100%; }

  /* Slightly tighter taps */
  #mobileMenuBtn.icon-btn{
    width: 38px;
    height: 38px;
  }

  .logout-btn{
    width: 34px;
    height: 34px;
  }

  .crumb-trail a{ font-size: 16px; }
}

/* Very small phones: prevent topbar overflow */
@media (max-width: 520px){
  .topbar{
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
  }
  .topbar-right{
    width: 100%;
    justify-content: space-between;
  }
  .topbar-right .muted{
    max-width: 70vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Safety: stop accidental horizontal scroll */
.shell, .main, .content, .topbar, .sidebar{
  min-width: 0;
}
/* ALERTS */
.alerts-container{
  margin-bottom:16px;
}

.alert{
  padding:12px 14px;
  border-radius:10px;
  margin-bottom:10px;
  font-size:14px;
  border:1px solid transparent;
}

.alert-success{
  background:#ecfdf5;
  border-color:#10b981;
  color:#065f46;
}

.alert-error{
  background:#fef2f2;
  border-color:#dc2626;
  color:#7f1d1d;
}

.alert-warning{
  background:#fffbeb;
  border-color:#f59e0b;
  color:#78350f;
}

.alert-info{
  background:#eff6ff;
  border-color:#3b82f6;
  color:#1e3a8a;
}
/* ALERTS */