/* ── Lumen Design System ─────────────────────────────────────────────────── */

/* Light theme tokens */
:root {
  --bg:           #F7F4EE;
  --surface:      #FFFFFE;
  --surface-2:    #EFEBE2;
  --surface-3:    #E4DFD2;
  --ink:          #0E0E10;
  --ink-2:        #2A2A2F;
  --ink-muted:    #6E6B66;
  --ink-faint:    #A19E97;
  --border:       rgba(14,14,16,0.08);
  --border-md:    rgba(14,14,16,0.12);
  --border-strong:rgba(14,14,16,0.16);
  --accent:       #C1542F;
  --accent-soft:  #F2DACC;
  --accent-ink:   #FFFFFF;
  --success:      #2E7D55;
  --warning:      #B5851A;
  --danger:       #C0392B;
  --hover:        rgba(14,14,16,0.04);
  --selected:     rgba(193,84,47,0.08);
  --shadow-sm:    0 1px 2px rgba(14,14,16,0.04), 0 1px 1px rgba(14,14,16,0.02);
  --shadow-md:    0 4px 16px rgba(14,14,16,0.06), 0 1px 2px rgba(14,14,16,0.04);
  --shadow-lg:    0 24px 48px rgba(14,14,16,0.12), 0 8px 16px rgba(14,14,16,0.06);
  --sidebar-w:    240px;
  --sidebar-mini: 64px;
  --sidebar-ease: width 0.2s cubic-bezier(0.4,0,0.2,1);
  --r-sm:  6px;
  --r-md:  8px;
  --r-lg:  10px;
  --r-xl:  14px;
  --r-2xl: 18px;
}

/* Dark theme tokens */
[data-theme="dark"] {
  --bg:           #0B0B0D;
  --surface:      #131316;
  --surface-2:    #1A1A1E;
  --surface-3:    #232328;
  --ink:          #F2EFE8;
  --ink-2:        #D9D5CC;
  --ink-muted:    #908C84;
  --ink-faint:    #5C5953;
  --border:       rgba(242,239,232,0.08);
  --border-md:    rgba(242,239,232,0.12);
  --border-strong:rgba(242,239,232,0.16);
  --accent:       #E27855;
  --accent-soft:  #3C231A;
  --accent-ink:   #0B0B0D;
  --success:      #5BB58A;
  --warning:      #D6A93F;
  --danger:       #E55A4A;
  --hover:        rgba(242,239,232,0.05);
  --selected:     rgba(226,120,85,0.10);
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg:    0 24px 48px rgba(0,0,0,0.6), 0 8px 16px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s ease, color 0.25s ease;
}

.serif { font-family: 'Instrument Serif', Georgia, 'Times New Roman', serif; font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: 'Geist Mono', ui-monospace, 'Cascadia Code', monospace; font-variant-numeric: tabular-nums; }

/* ── Shell layout ──────────────────────────────────────────────────────── */
.lumen-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.lumen-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: var(--sidebar-ease);
  z-index: 100;
  overflow: hidden;
}
.lumen-sidebar.is-collapsed { width: var(--sidebar-mini); }

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.logo-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-name {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 18px;
  font-style: italic;
  color: var(--ink);
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.lumen-sidebar.is-collapsed .logo-name { opacity: 0; pointer-events: none; }

/* Nav scroll area */
.sidebar-nav-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: none;
}
.sidebar-nav-wrap::-webkit-scrollbar { display: none; }

/* Nav section label */
.nav-section {
  padding: 16px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s, padding 0.15s, max-height 0.15s;
  max-height: 40px;
}
.lumen-sidebar.is-collapsed .nav-section {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Nav item (used for both <a> and <button> nav entries) */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin: 1px 6px;
  border-radius: var(--r-md);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: none;
  background: transparent;
  width: calc(100% - 12px);
  text-align: left;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active {
  background: var(--selected);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Icon slot inside nav item */
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
/* Override MudIcon size inside sidebar nav */
.nav-icon .mud-icon-root { font-size: 18px !important; width: 18px !important; height: 18px !important; }
.nav-icon svg { width: 18px; height: 18px; }

/* Label + collapsed behaviour */
.nav-label { white-space: nowrap; overflow: hidden; transition: opacity 0.15s; flex: 1; }
.lumen-sidebar.is-collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }
.lumen-sidebar.is-collapsed .nav-item {
  margin: 1px 6px;
  padding: 8px;
  justify-content: center;
  width: calc(100% - 12px);
}
.lumen-sidebar.is-collapsed .nav-item::before { display: none; }

/* Badge pill in nav items */
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
  line-height: 1.6;
}
.lumen-sidebar.is-collapsed .nav-badge { display: none; }

/* ── Sidebar footer ─────────────────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
  overflow: hidden;
  min-width: 0;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info {
  overflow: hidden;
  min-width: 0;
  transition: opacity 0.15s;
}
.lumen-sidebar.is-collapsed .user-info { opacity: 0; width: 0; }
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-link {
  font-size: 11px;
  color: var(--ink-muted);
  text-decoration: none;
  display: block;
}
.user-link:hover { color: var(--accent); }

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
  padding: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); border-color: var(--border-strong); }
.icon-btn svg { width: 14px; height: 14px; }
.collapse-btn { margin-left: auto; }

/* ── Main content area ──────────────────────────────────────────────────── */
.lumen-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
  transition: margin-left 0.2s cubic-bezier(0.4,0,0.2,1);
}
.sidebar-collapsed .lumen-main { margin-left: var(--sidebar-mini); }

/* ── MudBlazor global overrides ─────────────────────────────────────────── */
/* Remove uppercase from buttons everywhere */
.mud-button-root {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 500 !important;
}
/* Warmer card borders */
.mud-card {
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}
.mud-elevation-2 { box-shadow: var(--shadow-sm) !important; }
.mud-elevation-4 { box-shadow: var(--shadow-md) !important; }
/* Input border radius */
.mud-input-outlined .mud-input-outlined-border { border-radius: var(--r-md) !important; }
/* Chip radius */
.mud-chip { border-radius: var(--r-sm) !important; }
/* Select consistent radius */
.mud-select-outlined .mud-input-outlined-border { border-radius: var(--r-md) !important; }
/* Table */
.mud-table-container { border-radius: var(--r-lg) !important; overflow: hidden; }
/* Snackbar */
.mud-snackbar { border-radius: var(--r-lg) !important; }
/* Progress bar */
.mud-progress-linear { border-radius: 999px !important; }
/* Dialog */
.mud-dialog { border-radius: var(--r-xl) !important; }

/* ── Blazor error / reconnect UI ────────────────────────────────────────── */
#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--danger);
  color: #fff;
  padding: 0.6rem 1.25rem;
  z-index: 10000;
  font-size: 13px;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; font-size: 1.25rem; line-height: 1; }
.blazor-error-boundary { background: var(--danger); padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeout {
  from { opacity: 1; }
  to   { opacity: 0; pointer-events: none; }
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: padding-box; }
