/* ============================================================================
   BASE.CSS — Reset + body defaults + typography + link styles + scrollbar
   ============================================================================ */

/* Box-sizing reset */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Body defaults */
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
}

/* Headings */
h1, h2, h3, h4 {
  font-family: var(--font-body);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 8px 0;
}

h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; }

/* Links */
a {
  color: var(--press-red);
  text-decoration: none;
}

a:hover {
  color: var(--press-red-hover);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Focus indicators */
:focus-visible {
  outline: 2px solid var(--press-red);
  outline-offset: 2px;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--ink);
  color: white;
  padding: var(--sp-2) var(--sp-4);
  z-index: 1000;
  transition: top var(--t-fast);
}
.skip-link:focus {
  top: 0;
}

/* ============================================================================
   APP SHELL LAYOUT
   ============================================================================ */

#app-shell { display: flex; height: 100vh; overflow: hidden; }
#sidebar-container { display: flex; flex-shrink: 0; }

/* Primary sidebar — icon strip */
#sidebar-primary {
  width: 56px;
  background: var(--ink);
  color: white;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--ink-lighter);
  flex-shrink: 0;
}

#nav-icons { flex: 1; display: flex; flex-direction: column; padding-top: var(--sp-2); }

.collapse-btn {
  width: 56px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--silver);
  cursor: pointer;
  transition: color var(--t-fast);
  flex-shrink: 0;
}
.collapse-btn:hover { color: white; }

/* Secondary sidebar — sub-item panel */
#sidebar-secondary {
  width: 200px;
  background: var(--ink-light);
  color: white;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--ink-lighter);
  flex-shrink: 0;
}
#sidebar-secondary.open { display: flex; }

#secondary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--silver);
  border-bottom: 1px solid var(--ink-lighter);
  flex-shrink: 0;
}

#secondary-close {
  background: none;
  border: none;
  color: var(--silver);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast);
}
#secondary-close:hover { color: white; }

#nav-links { display: flex; flex-direction: column; padding: var(--sp-2) 0; }

.nav-section-label {
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--silver);
  opacity: 0.6;
}

/* Sidebar rail — thin strip when fully closed */
#sidebar-rail {
  width: 12px;
  background: var(--ink);
  display: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: width var(--t-fast), background var(--t-fast);
}
#sidebar-rail:hover {
  width: 16px;
  background: var(--ink-light);
}

/* Sidebar state classes on #app-shell */
#app-shell.sidebar-full #sidebar-container { display: flex; }
#app-shell.sidebar-full #sidebar-secondary { display: flex; }
#app-shell.sidebar-full #sidebar-rail { display: none; }

#app-shell.sidebar-collapsed #sidebar-container { display: flex; }
#app-shell.sidebar-collapsed #sidebar-secondary { display: none !important; }
#app-shell.sidebar-collapsed #sidebar-rail { display: none; }

#app-shell.sidebar-closed #sidebar-container { display: none; }
#app-shell.sidebar-closed #sidebar-rail { display: block; }

/* Main content — always fills remaining space */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  width: 100%;
  max-width: 100%;
}

/* Header */
#header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  justify-content: flex-end;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.icon-btn:hover { color: var(--text); background: var(--cream); }

/* Login screen */
#login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-10);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  box-shadow: var(--shadow-md);
  min-width: 320px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  text-align: center;
}

/* Primary nav items */
.nav-icon {
  width: 56px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--silver);
  transition: color var(--t-fast), background var(--t-fast);
  border-left: 3px solid transparent;
  flex-shrink: 0;
}
.nav-icon:hover { color: white; background: var(--ink-light); }
.nav-icon.active { color: white; border-left-color: var(--press-red); background: var(--ink-light); }

/* Secondary nav items */
.nav-link {
  display: block;
  padding: var(--sp-2) var(--sp-4);
  color: var(--silver);
  font-size: 13px;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  border-radius: var(--r-sm);
  margin: 2px var(--sp-2);
}
.nav-link:hover { color: white; background: var(--ink-lighter); }
.nav-link.active { color: white; background: var(--ink-lighter); }

/* Dark mode base overrides */
body.dark-mode {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1c2128;
  --card: #1c2128;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #656d76;
  --border: #30363d;
  --border-strong: #3d444d;
  --cream: #1c2128;
}
