/* ============================================================
   prism-layout.css — Kenki Prism Shell & Sidebar Layout
   Extracted from dashboard.html for use on all authenticated pages
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body, 'Inter', sans-serif);
  background: var(--ink, #1A1614);
  color: var(--prism-text, #F5F0E8);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Global Cormorant Garamond for all headings ── */
h1, h2, h3, h4, .card h2, .card h3 {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-weight: 400;
  font-variant-numeric: lining-nums;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--border-color, #3D3530); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::selection { background: rgba(196,94,58,.3); color: var(--parchment); }

/* ── Global form dark theme ─────────────── */
select, .form-input[type="select"], select.form-input {
  background-color: var(--deep-stone, #1A1614) !important;
  color: var(--parchment, #F5F0E8) !important;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A7D70' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem;
}
select option { background: var(--deep-stone, #1A1614); color: var(--parchment, #F5F0E8); }

/* ── Global Kenki checkboxes ────────────── */
input[type="checkbox"] {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2px solid var(--border-color, #3D3530); border-radius: 50%;
  background: transparent; cursor: pointer; position: relative;
  transition: border-color .2s, background .2s;
}
input[type="checkbox"]:checked {
  background: var(--accent, #C45E3A); border-color: var(--accent, #C45E3A);
}
input[type="checkbox"]:checked::after {
  content: ''; position: absolute; top: 3px; left: 6px;
  width: 5px; height: 9px; border: solid var(--parchment, #F5F0E8);
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent, #C45E3A); outline-offset: 2px; }

/* ── Global input teal borders ────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
  border: 1px solid rgba(74,155,142,.3) !important;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: #4A9B8E !important;
  outline: none;
}

/* ── Global action buttons ──────────────── */
.btn-edit, .btn-del,
button[class*="edit"], button[class*="delete"],
button[onclick*="delete"], button[onclick*="Delete"] {
  background: transparent !important;
  border: 1px solid var(--border-color, #3D3530) !important;
  border-radius: 6px !important;
  font-size: 0.72rem !important;
  padding: 0.25rem 0.6rem !important;
  cursor: pointer !important;
  font-family: inherit !important;
  line-height: 1.4 !important;
  transition: background .15s, border-color .15s !important;
}
button[class*="edit"], .btn-edit { color: var(--sub, #8A7D70) !important; }
button[class*="delete"], .btn-del,
button[onclick*="delete"], button[onclick*="Delete"] { color: var(--sub, #8A7D70) !important; }
button[class*="edit"]:hover, .btn-edit:hover { background: rgba(196,94,58,.08) !important; border-color: var(--accent, #C45E3A) !important; }
button[class*="delete"]:hover, .btn-del:hover,
button[onclick*="delete"]:hover, button[onclick*="Delete"]:hover { background: rgba(231,76,60,.08) !important; border-color: rgba(231,76,60,.4) !important; }

/* ══════════════════════════════════════════
   LAYOUT SHELL
   ══════════════════════════════════════════ */
.prism-shell { display: flex; height: 100vh; overflow: hidden; }

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.prism-sidebar {
  width: var(--sidebar-w, 240px);
  min-width: var(--sidebar-w, 240px);
  height: 100vh;
  background: var(--deep-stone, #231F1C);
  border-right: 1px solid var(--border-color, #3D3530);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  overflow: hidden;
  flex-shrink: 0;
}
[data-theme="light"] .prism-sidebar { background: #1A1614; border-right-color: #3D3530; }
[data-theme="light"] .prism-sidebar .sidebar-logo-text,
[data-theme="light"] .prism-sidebar .sidebar-nav-btn,
[data-theme="light"] .prism-sidebar .sidebar-user-name { color: #F5F0E8; }
[data-theme="light"] .prism-sidebar .sidebar-nav-btn { color: #A89B8C; }
[data-theme="light"] .prism-sidebar .sidebar-nav-btn.active { color: #F5F0E8; }
[data-theme="light"] .prism-sidebar .sidebar-user-plan { color: #6B5E53; }

.sidebar-logo { padding: 0 24px; margin-bottom: 40px; display: flex; align-items: center; gap: 12px; text-decoration: none; }
.sidebar-logo-text { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: 0.04em; color: var(--parchment); }
.sidebar-logo-gradient,
#kenki-gradient-text {
  font-family: 'Cormorant Garamond', serif !important;
  font-weight: 600 !important; font-size: 22px !important;
  letter-spacing: 0.04em !important;
  background: linear-gradient(90deg, #C45E3A 0%, #7A8B6F 50%, #4A9B8E 100%) !important;
  -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important;
  background-clip: text !important; color: transparent !important;
  display: inline-block !important;
}

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; }
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* Module list */
.sidebar-modules-divider {
  padding: 12px 24px 6px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.25em; color: var(--muted); font-family: var(--font-body); font-weight: 500;
  border-top: 1px solid var(--border-color); margin: 8px 12px 0; padding-top: 12px;
}
.sidebar-modules { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-module-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-radius: 6px; border: none;
  background: transparent; color: var(--sub); font-size: 13px;
  font-family: var(--font-body); font-weight: 400; cursor: pointer;
  transition: all 0.2s ease; text-align: left; text-decoration: none;
}
.sidebar-module-btn:hover { background: rgba(245,240,232,0.05); color: var(--accent-light); }
.sidebar-module-btn .mod-icon { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-module-btn.active { background: rgba(196,94,58,0.12); color: var(--parchment) !important; font-weight: 500; }
[data-theme="light"] .sidebar-module-btn { color: #A89B8C; }
[data-theme="light"] .sidebar-module-btn:hover { color: var(--accent-light); }
[data-theme="light"] .sidebar-modules-divider { color: #6B5E53; border-top-color: #3D3530; }

/* Nav buttons */
.sidebar-nav { padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav-btn {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-radius: 6px; border: none;
  background: transparent; color: var(--sub); font-size: 13px;
  font-family: var(--font-body); font-weight: 400; cursor: pointer;
  transition: all 0.2s ease; text-align: left; position: relative;
  text-decoration: none;
}
.sidebar-nav-btn:hover { background: rgba(245,240,232,0.05); }
.sidebar-nav-btn.active { background: rgba(196,94,58,0.12); color: var(--parchment); font-weight: 500; }
.sidebar-nav-btn.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 2px 2px 0; background: var(--accent);
}
.sidebar-nav-btn .nav-icon { font-size: 16px; width: 24px; text-align: center; opacity: 0.6; }
.sidebar-nav-btn.active .nav-icon { opacity: 1; }

/* User section */
.sidebar-user {
  padding: 16px 24px; border-top: 1px solid var(--border-color); margin-top: auto;
  display: flex; align-items: center; gap: 10px;
}
[data-theme="light"] .sidebar-user { border-top-color: #3D3530; }
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(196,94,58,0.15); border: 1px solid rgba(196,94,58,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; color: var(--accent-light); font-family: var(--font-display);
}
.sidebar-user-name { font-size: 12px; font-weight: 500; color: var(--parchment); }
.sidebar-user-plan { font-size: 10px; color: var(--muted); }

/* ══════════════════════════════════════════
   MAIN CONTENT AREA
   ══════════════════════════════════════════ */
.prism-main { flex: 1; height: 100vh; overflow: auto; background: var(--ink); }

.prism-header {
  padding: 20px 32px; border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink); position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}
.prism-header h1 {
  font-family: var(--font-display); font-size: 24px; font-weight: 400;
  color: var(--prism-text); margin: 0;
  font-variant-numeric: lining-nums;
}
.prism-header .header-date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.prism-header-right { display: flex; align-items: center; gap: 12px; }

.sync-badge {
  padding: 6px 14px; border-radius: 20px;
  background: rgba(122,139,111,0.12); border: 1px solid rgba(122,139,111,0.25);
  font-size: 11px; color: var(--sage); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.sync-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }

.theme-toggle-btn {
  background: transparent; border: 1px solid var(--border-color);
  color: var(--sub); width: 34px; height: 34px; border-radius: 6px;
  cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.theme-toggle-btn:hover { border-color: var(--accent); color: var(--prism-text); }

.signout-btn {
  padding: 6px 14px; background: transparent; border: 1px solid var(--border-color);
  border-radius: 6px; color: var(--sub); font-size: 11px; font-family: var(--font-body);
  cursor: pointer; transition: all 0.2s;
}
.signout-btn:hover { border-color: #EF4444; color: #EF4444; }

.prism-content { padding: 32px; }

/* ── Tab views ── */
.tab-view { display: none; }
.tab-view.active { display: block; }

/* ══════════════════════════════════════════
   PRISM CARD SYSTEM
   ══════════════════════════════════════════ */
.p-card {
  background: var(--stone); border-radius: 8px;
  border: 1px solid var(--border-color); padding: 24px;
}
.p-card-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 500;
  color: var(--prism-text); margin: 0 0 20px 0;
  font-variant-numeric: lining-nums;
}
.p-card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.p-card-header .p-card-title { margin-bottom: 0; }
.p-card-meta { font-size: 10px; color: var(--muted); }

/* ── Stat cards ── */
.p-stat {
  background: var(--stone); border-radius: 8px;
  border: 1px solid var(--border-color); padding: 20px 24px;
  flex: 1; min-width: 0;
}
.p-stat-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.p-stat-label {
  font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.12em; font-family: var(--font-body);
}
.p-stat-icon { font-size: 14px; opacity: 0.5; }
.p-stat-value {
  font-size: 28px; font-weight: 300; color: var(--prism-text);
  font-family: var(--font-display); display: flex; align-items: baseline; gap: 4px;
  font-variant-numeric: lining-nums;
}
.p-stat-unit { font-size: 12px; color: var(--muted); }
.p-stat-sub { font-size: 11px; margin-top: 6px; font-weight: 400; }

/* ── Grids ── */
.stat-row { display: flex; gap: 16px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.grid-sidebar { display: grid; grid-template-columns: 280px 1fr; gap: 24px; margin-bottom: 24px; }

/* ── Chart containers ── */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap canvas { width: 100% !important; max-height: 160px; }
.chart-empty-msg {
  display: none; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.85rem; text-align: center;
  min-height: 120px;
}
.chart-empty-msg a { color: var(--accent); font-size: 0.8rem; }

/* ── Progress bars ── */
.p-progress { height: 6px; border-radius: 3px; background: var(--deep-stone); overflow: hidden; }
.p-progress-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

/* ── Insight cards ── */
.insight-card {
  padding: 12px 14px; border-radius: 6px;
  background: var(--deep-stone); border-left: 3px solid var(--accent);
}
.insight-cat { font-size: 8px; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 4px; }
.insight-title { font-size: 12px; color: var(--prism-text); line-height: 1.5; font-weight: 400; }
.insight-time { font-size: 9px; color: var(--muted); margin-top: 4px; }

/* ── Nav cards grid (overview module links) ── */
.nav-cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-top: 24px;
}
.module-card {
  background: var(--stone); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 20px; text-decoration: none;
  color: var(--prism-text); transition: border-color 0.2s, transform 0.15s;
  display: block; position: relative;
}
.module-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.module-card-icon { font-size: 1.6rem; margin-bottom: 8px; }
.module-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; font-family: var(--font-body); }
.module-card p { font-size: 11px; color: var(--sub); }

/* ══════════════════════════════════════════
   RESPONSIVE — 900px (tablet / mobile)
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
  .prism-header { display: none !important; }

  .prism-sidebar {
    display: flex; width: 100%; min-width: unset; height: auto;
    flex-direction: column; border-right: none;
    border-bottom: 1px solid var(--border-color); padding: 12px 0;
  }
  [data-theme="light"] .prism-sidebar { border-right: none; border-bottom: 1px solid #3D3530; }
  html, body { height: auto; overflow: auto; }
  .prism-shell { flex-direction: column; height: auto; overflow: visible; }
  .prism-main { height: auto; overflow: visible; }

  .sidebar-logo { margin-bottom: 12px; }
  .sidebar-user { padding: 8px 24px; }

  /* Main nav: horizontal scroll */
  .sidebar-nav {
    flex-direction: row; overflow-x: auto; gap: 4px; padding: 0 12px;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-nav-btn { white-space: nowrap; padding: 8px 14px; font-size: 12px; }

  /* Hide sub-page sidebars on mobile — dashboard hamburger handles nav */
  .prism-sidebar:not(.prism-sidebar--dashboard) { display: none !important; }

  /* Dashboard sidebar stays visible and collapses horizontally */
  .prism-sidebar--dashboard .sidebar-modules-divider { margin: 4px 12px 0; padding: 8px 12px 4px; font-size: 9px; }
  .prism-sidebar--dashboard .sidebar-modules {
    flex-direction: row; overflow-x: auto; flex-wrap: nowrap; gap: 2px; padding: 0 12px 8px;
    -webkit-overflow-scrolling: touch;
  }
  .prism-sidebar--dashboard .sidebar-modules::-webkit-scrollbar { display: none; }
  .prism-sidebar--dashboard .sidebar-module-btn { white-space: nowrap; padding: 6px 12px; font-size: 11px; flex-shrink: 0; }

  .sidebar-scroll { overflow-y: visible; overflow-x: hidden; }

  /* Compact stat cards */
  .stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-row .p-stat { min-width: 0; }
  .p-stat { padding: 14px 16px; }
  .p-stat-top { margin-bottom: 8px; }
  .p-stat-value { font-size: 22px; }
  .p-stat-sub { font-size: 10px; }

  /* Tighter card padding + grid gaps */
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
  .grid-sidebar { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
  .p-card { overflow: hidden; word-wrap: break-word; padding: 16px; }
  .p-card-title { font-size: 16px; margin-bottom: 12px; }
  .prism-content { padding: 14px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — 768px (small mobile)
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .prism-sidebar {
    position: sticky; top: 0; z-index: 100;
    background: var(--deep-stone);
  }
  [data-theme="light"] .prism-sidebar { background: #1A1614; }

  .sidebar-logo { display: none; }
  .sidebar-user { display: none; }

  .prism-main { margin-left: 0; width: 100%; padding: 0; }
  .prism-content { padding: 12px; }

  .prism-header h1 { font-size: 20px; }
  .prism-header { padding: 12px 16px; }
  .prism-header-right { gap: 8px; }
  .signout-btn { font-size: 10px; padding: 4px 10px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — 480px (small phones)
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
  .sidebar-nav-btn { padding: 6px 10px; font-size: 11px; }
  .sidebar-nav-btn .nav-icon { font-size: 14px; width: 18px; }
  .sidebar-module-btn { padding: 5px 10px; font-size: 10px; }
  .sidebar-module-btn .mod-icon { font-size: 12px; }

  .stat-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .p-stat { padding: 12px; }
  .p-stat-value { font-size: 20px; }
  .p-stat-label { font-size: 9px; }
  .p-card { padding: 14px; }
  .p-card-title { font-size: 14px; margin-bottom: 10px; }
  .grid-sidebar { gap: 12px; }

  .chart-empty-msg { min-height: 80px !important; font-size: 0.78rem !important; }
  .chart-wrap canvas { max-height: 120px !important; }

  .nav-cards-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .module-card { padding: 14px; }
  .module-card-icon { font-size: 1.3rem; margin-bottom: 4px; }
  .module-card h3 { font-size: 12px; }
  .module-card p { font-size: 10px; }
}

/* ── Global small action buttons ── */
.btn-sm { background:transparent; border:1px solid var(--border-color); color:var(--sub); border-radius:6px; padding:4px 10px; font-size:.72rem; cursor:pointer; font-family:var(--font-body); transition:opacity .15s; }
.btn-sm:hover { opacity:.8; }
.btn-sm-edit { color:var(--accent); border-color:var(--accent); }
.btn-sm-success { color:#34d399; border-color:#34d399; }
.btn-sm-danger { color:#ef4444; border-color:#ef4444; }
.btn-sm-ghost { color:var(--sub); border-color:var(--border-color); background:transparent; }

/* ── Tri-color accent bars (copper/sage/teal) ── */
.p-card:nth-child(3n+1) { border-left: 3px solid #C45E3A; }
.p-card:nth-child(3n+2) { border-left: 3px solid #7A8B6F; }
.p-card:nth-child(3n+3) { border-left: 3px solid #4A9B8E; }

.p-stat:nth-child(3n+1) { border-left: 3px solid #C45E3A; }
.p-stat:nth-child(3n+2) { border-left: 3px solid #7A8B6F; }
.p-stat:nth-child(3n+3) { border-left: 3px solid #4A9B8E; }

.module-card:nth-child(3n+1) { border-left: 3px solid #C45E3A; }
.module-card:nth-child(3n+2) { border-left: 3px solid #7A8B6F; }
.module-card:nth-child(3n+3) { border-left: 3px solid #4A9B8E; }

.insight-card:nth-child(3n+1) { border-left-color: #C45E3A; }
.insight-card:nth-child(3n+2) { border-left-color: #7A8B6F; }
.insight-card:nth-child(3n+3) { border-left-color: #4A9B8E; }
