/* ==========================================================================
   FINKU GEN-Z — LAYOUT SYSTEM & APP SHELL (layout.css)
   ========================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   SIDEBAR NAVIGATION (Desktop & Tablet)
   -------------------------------------------------------------------------- */
.app-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, rgba(17,17,24,0.98) 0%, rgba(13,13,20,0.99) 100%);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 50;
  transition: transform var(--transition-normal), background var(--transition-normal);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* Full light shell — sidebar must follow body.light-mode (was hardcoded dark) */
body.light-mode .app-sidebar {
  background: linear-gradient(180deg, #FCFCFC 0%, #FAF8F5 100%);
  box-shadow: 1px 0 0 var(--border-color);
}

body.light-mode .device-badge {
  background: rgba(0, 0, 0, 0.05);
}

body.light-mode .nav-item.active {
  background: rgba(0, 217, 139, 0.1);
  border-color: rgba(0, 217, 139, 0.22);
  color: #047857;
}
body.light-mode .nav-item.active svg {
  stroke: #047857;
}
body.light-mode .brand-text {
  color: var(--text-primary);
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--border-radius-sm);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #000;
  box-shadow: none;
}

.brand-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

body.light-mode .brand-name {
  color: var(--text-primary) !important;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), stroke var(--transition-fast);
  color: var(--text-secondary);
}

.nav-item:hover {
  background-color: var(--bg-glass-hover);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-item:hover svg {
  stroke: var(--accent-green);
}

.nav-item.active {
  background: rgba(0, 217, 139, 0.06);
  color: var(--accent-green);
  border-color: rgba(0, 217, 139, 0.15);
  box-shadow: none;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--accent-green);
  border-radius: 0 3px 3px 0;
  box-shadow: none;
}

.nav-item.active svg {
  transform: scale(1.15);
  stroke: var(--accent-green);
}

/* Sidebar Footer / Device Identity info */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-glass);
}

.device-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.device-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* --------------------------------------------------------------------------
   MAIN CONTENT AREA
   -------------------------------------------------------------------------- */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

.app-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

#main-header-title,
.page-title {
  font-family: var(--font-display);
  font-weight: 600;
}

.header-title-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.header-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.header-subtitle[hidden] {
  display: none !important;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.content-body {
  flex: 1;
  padding: 32px 32px 100px 32px; /* Bottom padding 100px to prevent FAB overlap */
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Remove constraints for full-bleed AI chat canvas */
.content-body:has(#view-aichat.active) {
  padding: 0;
  max-width: none;
}


/* Page Views */
.page-view {
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

.page-view.active {
  display: block;
}

.page-view.active#view-aichat {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   FAB QUICK ADD — desktop header Catat (bolt); mobile = raised gold + in nav
   -------------------------------------------------------------------------- */
.fab-quick-add {
  position: fixed;
  bottom: 32px;
  right: 36px;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 22px;
  background: var(--gradient-primary);
  color: #000;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--border-radius-pill);
  border: none;
  box-shadow: var(--shadow-glow-green);
  cursor: pointer;
  transition: all var(--transition-bounce);
}

.fab-quick-add:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 10px 30px rgba(0, 229, 160, 0.5);
}

.fab-quick-add i {
  font-size: 20px;
  font-weight: bold;
}

.bottom-nav-fab-slot {
  flex: 1 1 0;
  min-width: 56px;
  max-width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  position: relative;
  pointer-events: auto;
  visibility: visible;
  overflow: visible;
}

#btn-header-quick-add.btn-header-catat {
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  margin-right: 8px;
}

#btn-header-quick-add.btn-header-catat .finku-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
}

/* Desktop only — mobile uses raised FAB; higher specificity than base hide */
@media (min-width: 769px) {
  .fab-quick-add {
    display: none !important;
  }
  #btn-header-quick-add.btn-header-catat {
    display: flex !important;
  }
}
@media (max-width: 768px) {
  #btn-header-quick-add,
  #btn-header-quick-add.btn-header-catat {
    display: none !important;
  }
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 55;
  padding: 6px 12px;
  justify-content: space-around;
  align-items: center;
  overflow: visible;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
}

.bottom-nav-item.active {
  color: var(--accent-green);
}

.bottom-nav-item.active svg {
  stroke: var(--accent-green);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  .content-body {
    padding: 24px 20px;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%) !important;
    width: 280px !important;
    z-index: 200 !important;
  }
  .app-sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  .app-main {
    margin-left: 0;
    width: 100%;
    padding-bottom: 80px; /* space for bottom nav */
  }
  .app-header {
    padding: 0 20px;
  }
  .bottom-nav {
    display: flex;
    position: fixed !important;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 55;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
  /* Raised gold + in center fab-slot (above nav bar, not flush) */
  .bottom-nav-fab-slot .fab-quick-add,
  .bottom-nav-fab-slot .fab-quick-add.fab-nav-center {
    position: relative !important;
    left: auto;
    right: auto;
    bottom: auto;
    transform: translateY(-10px);
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    padding: 0;
    margin-top: -28px;
    border-radius: 50%;
    background: var(--accent-yellow);
    color: #1a1200;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
    border: 3px solid var(--bg-secondary);
    z-index: 2;
    gap: 0;
    flex-shrink: 0;
  }
  .bottom-nav-fab-slot .fab-quick-add:hover {
    transform: translateY(-13px) scale(1.04);
    box-shadow: 0 10px 28px rgba(245, 158, 11, 0.55);
  }
  .bottom-nav-fab-slot .fab-quick-add span {
    display: none;
  }
  .bottom-nav-fab-slot .fab-quick-add .fab-plus {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: #1a1200;
  }
}

/* AI Chat — hide gold FAB */
.app-container:has(#view-aichat.active) .fab-quick-add {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Lab Mode + Elite prestige (champagne / platinum — subtle, no glow spam)
   -------------------------------------------------------------------------- */
.lab-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 3px 7px;
  border-radius: 4px;
  color: #1a1510;
  background: linear-gradient(135deg, #E8D5A8 0%, #C9A86C 55%, #A89060 100%);
  border: 1px solid rgba(232, 213, 168, 0.55);
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
}
.lab-indicator[hidden] { display: none !important; }

.elite-prestige-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 4px 8px;
  border-radius: 999px;
  color: #E8E4DC;
  background: linear-gradient(145deg, #3a3a42 0%, #5c5c66 40%, #2e2e34 100%);
  border: 1px solid rgba(212, 175, 120, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  line-height: 1;
  flex-shrink: 0;
  margin-right: 2px;
}
.elite-prestige-badge[hidden] { display: none !important; }

#sidebar-brand-logo.lab-logo-pulse {
  outline: 1px solid rgba(201, 168, 108, 0.55);
  border-radius: 10px;
}

body.lab-mode [data-lab-only][hidden] {
  display: none !important;
}

.lab-health-card,
.lab-twin-weekly,
.lab-whatif-scenarios,
.lab-pdf-template {
  border: 1px solid rgba(201, 168, 108, 0.28);
  background: linear-gradient(160deg, rgba(201, 168, 108, 0.07) 0%, var(--bg-card, #12121a) 55%);
}

.lab-health-compare {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
  font-weight: 600;
}

.lab-health-diagnosis {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary);
  margin: 0 0 10px;
  font-weight: 600;
}

.lab-health-cta {
  width: 100%;
  margin: 0 0 10px;
}

.lab-health-why {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.lab-health-why > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
}

.lab-health-why-list {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.45;
}

.lab-health-layer {
  margin-top: 12px;
  border: 1px solid rgba(201, 168, 108, 0.22);
  border-radius: 10px;
  padding: 8px 12px 10px;
  background: rgba(0, 0, 0, 0.12);
}

.lab-health-layer > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

.lab-health-preview-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #C9A86C;
}

.lab-health-layer-body {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.lab-health-layer-lead {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 11px;
}

.lab-health-subh {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 10px 0 4px;
}

.lab-health-empty {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

.lab-health-chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lab-health-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lab-health-bar-label {
  width: 62px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.lab-health-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary, #1a1a24);
  border-radius: 99px;
  overflow: hidden;
}

.lab-health-bar-fill {
  display: block;
  height: 100%;
  background: #C9A86C;
  border-radius: 99px;
}

.lab-health-bar-val {
  width: 28px;
  text-align: right;
  font-weight: 700;
  color: var(--text-primary);
}

.lab-health-delta {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.lab-health-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 6px 0;
  cursor: pointer;
}

.lab-health-check input {
  margin-top: 2px;
  flex-shrink: 0;
}

.lab-health-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.lab-health-story {
  font-size: 12px;
  line-height: 1.5;
  margin: 8px 0 0;
  color: var(--text-secondary);
}

.lab-health-plan,
.lab-health-cross,
.lab-health-scen {
  margin: 4px 0 0;
  padding-left: 18px;
}

.lab-health-plan-link {
  border: 0;
  background: none;
  color: #C9A86C;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0 0 4px;
  text-decoration: underline;
}

.lab-health-alert {
  font-size: 12px;
  color: #FFAB00;
  margin: 0 0 8px;
}

