/* Luniat App Shell — Based on ElevenLabs DESIGN.md (getdesign) */

:root {
  /* Colors — exact ElevenLabs tokens */
  --primary: #292524;
  --primary-active: #0c0a09;
  --ink: #0c0a09;
  --body: #4e4e4e;
  --body-strong: #292524;
  --muted: #777169;
  --muted-soft: #a8a29e;
  --hairline: #e7e5e4;
  --hairline-soft: #f0efed;
  --hairline-strong: #d6d3d1;
  --canvas: #f5f5f5;
  --canvas-soft: #fafafa;
  --surface-card: #ffffff;
  --surface-strong: #f0efed;
  --surface-dark: #0c0a09;
  --on-primary: #ffffff;
  --on-dark: #ffffff;
  --on-dark-soft: #a8a29e;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --error: #dc2626;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 64px;

  /* Radius — ElevenLabs scale */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-xxl: 24px;
  --r-pill: 9999px;

  /* Spacing — ElevenLabs 4px base */
  --s-xs: 8px;
  --s-sm: 12px;
  --s-base: 16px;
  --s-md: 20px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;

  /* Fonts */
  --font: 'Inter', -apple-system, system-ui, sans-serif;
  --font-display: 'Instrument Serif', 'EB Garamond', Georgia, serif;

  /* Shadow — single tier, ElevenLabs "hairline + soft drop" */
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.04);
  --shadow-popover: 0 4px 24px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--body);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.16px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}
.sidebar-overlay { display: none; }

/* ============================================================
   SIDEBAR — white bg, SVG stroke icons, clean like ElevenLabs
   ============================================================ */
.app-sidebar {
  background: var(--surface-card);
  border-right: 1px solid var(--hairline);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: var(--s-sm) var(--s-xs);
  overflow-y: auto;
}

/* Brand */
.sidebar-brand { padding: var(--s-sm) var(--s-sm); margin-bottom: var(--s-xs); }
.sidebar-brand-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.5px;
}

/* Workspace */
.workspace-selector {
  display: flex; align-items: center; gap: var(--s-sm);
  padding: 10px var(--s-sm);
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  margin: 0 4px var(--s-md);
  cursor: pointer;
  transition: border-color 0.15s;
}
.workspace-selector:hover { border-color: var(--hairline-strong); }
.workspace-avatar {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: linear-gradient(135deg, #d9c7a0, #8b6b43);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.workspace-info { flex: 1; min-width: 0; }
.workspace-name { font-size: 14px; font-weight: 500; color: var(--body-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-plan { font-size: 12px; color: var(--muted); }

/* Sidebar scroll area */
.sidebar-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 4px 0; scrollbar-width: thin; scrollbar-color: var(--hairline) transparent; }
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 4px; }

/* Divider (legacy compat) */
.sidebar-divider { height: 1px; background: var(--hairline); margin: var(--s-sm) var(--s-sm); }

/* Nav groups — always visible, with label */
.sidebar-group { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.sidebar-group + .sidebar-group { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--hairline-soft); }
.sidebar-group-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px var(--s-sm) 6px; }

/* Legacy section labels */
.sidebar-section + .sidebar-section { margin-top: var(--s-sm); }
.sidebar-section-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 4px var(--s-sm) 6px; }

/* Nav items — smooth transitions */
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--s-sm);
  border-radius: 9px;
  text-decoration: none;
  color: var(--body);
  font-size: 14px; font-weight: 500; line-height: 1.4;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
  position: relative;
}
.sidebar-nav-item:hover { background: var(--surface-strong); color: var(--ink); transform: translateX(2px); }
.sidebar-nav-item.active { background: var(--surface-strong); color: var(--ink); font-weight: 600; }
.sidebar-nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; background: #E8FF4A; border-radius: 0 3px 3px 0;
  animation: indicator-slide 0.25s ease-out;
}
@keyframes indicator-slide { from { height: 0; opacity: 0; } to { height: 18px; opacity: 1; } }
.sidebar-nav-item.disabled { opacity: 0.35; pointer-events: none; }
.sidebar-nav-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--muted); transition: transform 0.18s ease; }
.sidebar-nav-item:hover .sidebar-nav-icon { color: var(--body-strong); transform: scale(1.1); }
.sidebar-nav-item.active .sidebar-nav-icon { color: var(--body-strong); }

/* Badges */
.sidebar-nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: var(--r-pill);
}
.sidebar-nav-badge.new { background: #e8f5e9; color: #2e7d32; }
.sidebar-nav-badge.soon { background: var(--surface-strong); color: var(--muted-soft); }

.sidebar-spacer { flex: 1; }

/* User */
.sidebar-user {
  display: flex; align-items: center; gap: var(--s-xs);
  padding: 8px var(--s-sm);
  border-radius: var(--r-md);
  cursor: pointer; position: relative;
  transition: background 0.1s;
}
.sidebar-user:hover { background: var(--surface-strong); }
.sidebar-user-avatar {
  width: 26px; height: 26px; border-radius: var(--r-pill);
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 11px; flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 500; color: var(--body-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { display: none; }

/* User dropdown */
.user-dropdown {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface-card); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 6px;
  opacity: 0; pointer-events: none; transform: translateY(4px);
  transition: all 0.15s; z-index: 100;
  box-shadow: var(--shadow-popover);
}
.user-dropdown.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.user-dropdown-item {
  display: block; padding: var(--s-xs) var(--s-sm); font-size: 14px;
  color: var(--body); text-decoration: none; border-radius: var(--r-sm);
  border: none; background: transparent; width: 100%; text-align: left;
  cursor: pointer; font-family: inherit; line-height: 1.5;
}
.user-dropdown-item:hover { background: var(--surface-strong); color: var(--ink); }
.user-dropdown-divider { height: 1px; background: var(--hairline); margin: 4px 0; }
.user-dropdown-logout { color: var(--error); }

/* ============================================================
   TOPBAR — ElevenLabs: 64px, canvas bg
   ============================================================ */
.app-main {
  display: flex; flex-direction: column;
  min-height: 100vh;
  background: var(--surface-card);
}

.app-topbar {
  height: 48px;
  border-bottom: 1px solid var(--hairline-soft);
  display: flex; align-items: center;
  padding: 0 var(--s-lg);
  background: var(--surface-card);
  position: sticky; top: 0; z-index: 50;
}

.topbar-mobile-toggle {
  display: none; background: transparent; border: none;
  cursor: pointer; padding: var(--s-xs); margin-right: var(--s-xs);
  font-size: 18px; color: var(--body);
}

.app-breadcrumbs {
  display: flex; align-items: center; gap: var(--s-xs);
  font-size: 15px; font-weight: 500; color: var(--muted); line-height: 1.4;
}
.app-breadcrumbs a {
  color: var(--muted); text-decoration: none;
  padding: 4px var(--s-xs); border-radius: var(--r-sm);
}
.app-breadcrumbs a:hover { background: var(--surface-strong); color: var(--body-strong); }
.app-breadcrumbs .arrow { color: var(--muted-soft); }
.app-breadcrumbs .current { color: var(--body-strong); font-weight: 500; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s-sm); }
.topbar-credits {
  font-size: 12px; font-weight: 600; color: var(--ink);
  padding: 4px 10px; background: var(--surface-strong);
  border-radius: var(--r-pill); letter-spacing: 0.96px;
  text-transform: uppercase; line-height: 1.4;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.app-content {
  flex: 1; padding: var(--s-xl);
  max-width: 1100px; width: 100%;
  animation: content-enter 0.35s ease-out;
}
@keyframes content-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* View Transitions (modern browsers) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-fade-out 0.2s ease-out; }
::view-transition-new(root) { animation: vt-fade-in 0.25s ease-in; }
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
.app-sidebar { view-transition-name: sidebar; }
::view-transition-old(sidebar), ::view-transition-new(sidebar) { animation: none; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200; box-shadow: 4px 0 24px rgba(0,0,0,0.06);
    background: var(--surface-card);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(10,10,8,0.4);
    z-index: 150; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .sidebar-overlay.active { opacity: 1; pointer-events: auto; }
  .topbar-mobile-toggle { display: flex; }
  .app-content { padding: var(--s-md); }
}

/* Tool cards — grid of action shortcuts */
.tool-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-sm); padding: var(--s-lg) var(--s-base);
  background: var(--surface-card); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); text-decoration: none;
  color: var(--body); font-size: 13px; font-weight: 500;
  text-align: center; transition: all 0.15s;
}
.tool-card:hover { border-color: var(--hairline-strong); box-shadow: var(--shadow-hover); color: var(--ink); }
.tool-card svg { color: var(--muted); transition: color 0.15s; }
.tool-card:hover svg { color: var(--ink); }

/* ============================================================
   PAGE CONTENT — Using ElevenLabs type scale
   ============================================================ */

/* Page header — display-sm: 24px/300 */
.page-header { margin-bottom: var(--s-xl); }
.page-title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 300; line-height: 1.2;
  letter-spacing: 0; color: var(--ink); margin-bottom: 6px;
}
.page-title em { font-style: italic; }
.page-sub { font-size: 15px; color: var(--muted); letter-spacing: 0.15px; line-height: 1.47; }

/* Stats — feature-card: surface-card, r-xl, 24px padding */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-base); margin-bottom: var(--s-xl); }
.stat-card {
  background: var(--surface-card); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); padding: var(--s-lg);
}
.stat-label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.96px; line-height: 1.4;
  margin-bottom: var(--s-xs);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 300; line-height: 1.13;
  letter-spacing: -0.32px; color: var(--ink); margin-bottom: 4px;
}
.stat-detail { font-size: 14px; color: var(--muted); line-height: 1.5; }
.stat-detail a { color: var(--body-strong); text-decoration: none; font-weight: 500; }
.stat-detail a:hover { text-decoration: underline; }

/* CTA card — dark surface */
.cta-card {
  background: var(--surface-dark); color: var(--on-dark);
  border-radius: var(--r-xl); padding: var(--s-xl);
  margin-bottom: var(--s-xl);
}
.cta-card h2 { font-size: 20px; font-weight: 500; line-height: 1.35; margin-bottom: 6px; }
.cta-card p { font-size: 15px; color: var(--on-dark-soft); margin-bottom: var(--s-md); letter-spacing: 0.15px; line-height: 1.47; }

/* Section headers — title-sm: 18px/500 */
.section-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: var(--s-xl) 0 var(--s-base);
}
.section-header h2 { font-size: 18px; font-weight: 500; color: var(--body-strong); line-height: 1.44; letter-spacing: 0.18px; }
.section-header a { color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; }
.section-header a:hover { color: var(--body-strong); }

/* Post list — voice-row style: transparent bg, hairline dividers */
.recent-posts, .posts-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl); overflow: hidden;
}
.post-row {
  display: flex; gap: var(--s-base); padding: var(--s-sm) var(--s-md);
  background: var(--surface-card); align-items: center;
  border-bottom: 1px solid var(--hairline-soft);
}
.post-row:last-child { border-bottom: none; }
.post-thumb {
  width: 48px; height: 48px; border-radius: var(--r-md);
  background: linear-gradient(135deg, #d9c7a0, #8b6b43); flex-shrink: 0;
}
.post-content { flex: 1; min-width: 0; }
.post-caption { font-size: 15px; font-weight: 500; color: var(--body-strong); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.15px; }
.post-meta { font-size: 14px; color: var(--muted); display: flex; gap: var(--s-sm); align-items: center; }
.post-status { font-size: 12px; padding: 4px 10px; border-radius: var(--r-pill); font-weight: 600; letter-spacing: 0.96px; text-transform: uppercase; line-height: 1.4; }
.status-published { background: var(--success-soft); color: var(--success); }

/* Profile summary — feature-card style */
.profile-summary {
  background: var(--surface-card); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); padding: var(--s-lg);
}
.profile-row { padding: var(--s-xs) 0; font-size: 16px; color: var(--body); display: flex; gap: var(--s-sm); letter-spacing: 0.16px; line-height: 1.5; }
.profile-row strong { color: var(--muted); font-weight: 500; min-width: 80px; }

/* Empty state */
.empty-state {
  background: var(--surface-card); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); padding: 64px var(--s-xl); text-align: center;
}
.empty-state h2 { font-size: 18px; font-weight: 500; color: var(--body-strong); margin-bottom: var(--s-xs); }
.empty-state p { color: var(--muted); font-size: 16px; margin-bottom: var(--s-md); max-width: 360px; margin-left: auto; margin-right: auto; letter-spacing: 0.16px; }

/* Settings grid */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-base); }
.settings-card {
  background: var(--surface-card); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); padding: var(--s-lg);
  text-decoration: none; color: var(--body); display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.settings-card:hover { border-color: var(--hairline-strong); box-shadow: var(--shadow-hover); }
.settings-card.disabled { opacity: 0.4; pointer-events: none; }
.settings-card h3 { font-size: 16px; font-weight: 500; color: var(--body-strong); margin-bottom: 4px; display: flex; align-items: center; gap: var(--s-xs); }
.settings-card p { color: var(--muted); font-size: 15px; letter-spacing: 0.15px; }
.badge-soon { font-size: 12px; padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-strong); color: var(--muted-soft); font-weight: 600; letter-spacing: 0.96px; text-transform: uppercase; }

/* ============================================================
   BUTTONS — ElevenLabs: pill, 15px/500, 40px height
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-xs);
  padding: 10px 20px; height: 40px;
  border-radius: var(--r-pill);
  font-family: var(--font); font-weight: 500; font-size: 15px; line-height: 1;
  text-decoration: none; border: 1px solid transparent;
  cursor: pointer; background: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-active); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--hairline-strong); }
.btn-outline:hover { background: var(--surface-strong); }
.btn-on-dark { background: var(--surface-card); color: var(--ink); }
.btn-on-dark:hover { background: var(--canvas); }
.btn-large { padding: 12px 24px; height: 44px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
