/**
 * AD213 Financial Accounting PWA - Core Styles & Design System
 * Calm, timeless editorial aesthetic: Warm Paper (#FAF9F6) & Dark Slate (#121316).
 * Zero AI slop: no gratuitous capsule soup, no emoji icons, no nested cards.
 * High-signal typography, hairline rules, and tabular accounting precision.
 */

:root {
  color-scheme: light;
  /* Warm Paper Editorial Palette (Default Light) */
  --bg-primary: #FAF9F6;
  --bg-secondary: #F3EFEA;
  --bg-surface: #FFFFFF;
  --bg-hover: #ECE6DE;
  --callout-bg: #F4EFEB;
  
  --border-color: #E5E0D6;
  --border-subtle: #EFEBE3;
  --border-strong: #CDC6B8;
  
  --text-primary: #1A1B1E;
  --text-secondary: #57544E;
  --text-tertiary: #878278;
  --text-inverse: #FFFFFF;
  
  --accent-primary: #1B365D;       /* Classic Academic Navy */
  --accent-hover: #12243E;
  --accent-subtle: #EDF3FA;
  --accent-text: #1B365D;
  --brand-icon-bg: #1B365D;
  --brand-icon-fg: #FAF9F6;

  --btn-primary-bg: #1A1B1E;       /* Deep Charcoal Ink */
  --btn-primary-text: #FFFFFF;
  --btn-primary-hover: #000000;
  
  --debit-color: #1E5631;          /* Forest green for Debits / Assets */
  --debit-bg: #EAF4ED;
  --credit-color: #7E191B;         /* Deep burgundy for Credits / Liabilities */
  --credit-bg: #FDF1F1;
  --warning-color: #92400E;        /* Warm Amber for Exam Tips */
  --warning-bg: #FCF5E3;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.09);
  
  --font-serif: "Charter", "Bitstream Charter", "Sitka Text", "Cambria", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --header-height: 52px;
  --footer-height: 52px;
  --mobile-thumb-height: 56px;
}

[data-theme="dark"] {
  color-scheme: dark;
  /* Dark Slate Mode */
  --bg-primary: #121316;
  --bg-secondary: #191B20;
  --bg-surface: #1E2128;
  --bg-hover: #262932;
  --callout-bg: #181B22;
  
  --border-color: #292D36;
  --border-subtle: #20232B;
  --border-strong: #3D4350;
  
  --text-primary: #F0EDE6;
  --text-secondary: #A0A5AE;
  --text-tertiary: #6E737E;
  --text-inverse: #121316;
  
  --accent-primary: #94A3B8;       /* Calm Muted Slate Ink (Zero Neon) */
  --accent-hover: #CBD5E1;
  --accent-subtle: #1C2028;
  --accent-text: #E2E8F0;
  --brand-icon-bg: #1E3A60;
  --brand-icon-fg: #FAF9F6;

  --btn-primary-bg: #F0EDE6;       /* Editorial Inverted Ink: Crisp Light Paper */
  --btn-primary-text: #121316;
  --btn-primary-hover: #FFFFFF;
  
  --debit-color: #4ADE80;
  --debit-bg: #0E2916;
  --credit-color: #F87171;
  --credit-bg: #301314;
  --warning-color: #FBBF24;
  --warning-bg: #272010;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Base & Viewport Locking (100dvh, zero-dead-space, zero outer scroll)
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

#app-root {
  display: flex;
  flex-direction: column;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-primary);
}

/* Selection */
::selection {
  background-color: var(--accent-subtle);
  color: var(--accent-text);
}

/* Universal Form Controls - Zero Glare, Strict Theme Respect */
input, textarea, select, button {
  font-family: inherit;
  color-scheme: inherit;
}

input[type="text"],
input[type="search"],
textarea {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  caret-color: var(--text-primary);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

button:focus-visible,
[role="button"]:focus-visible,
.slide-progress-track:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

input[type="text"]:focus-visible,
input[type="search"]:focus-visible,
textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent-primary) 35%, transparent);
  outline-offset: 0;
  border-color: var(--accent-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  font-variant-numeric: tabular-nums;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Header (Fixed 48px Top Bar)
   ========================================================================== */

.app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  max-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 50;
  user-select: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text-primary);
  user-select: none;
}

.brand-logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  flex-shrink: 0;
  display: block;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease;
}

.app-brand:hover .brand-logo-mark {
  transform: scale(1.03);
}

.brand-text-group {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1;
}

.brand-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-text {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  letter-spacing: -0.005em;
}

/* Segmented Lecture Selector */
.lecture-selector {
  display: inline-flex;
  align-items: center;
  height: 30px;
  background-color: var(--bg-secondary);
  padding: 2px;
  border-radius: 999px;
  border: none;
  margin-left: 6px;
}

.lecture-btn {
  background: transparent;
  border: none;
  height: 24px;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.lecture-btn:hover:not(.active) {
  color: var(--text-primary);
}

.lecture-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 1px var(--border-subtle);
}

/* Header Buttons - Borderless Editorial Ghost Actions */
.header-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  height: 30px;
  padding: 0 8px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.header-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.header-btn.active {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.header-btn .icon {
  width: 14px;
  height: 14px;
  opacity: 0.85;
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: color-mix(in srgb, var(--text-primary) 5%, transparent);
  border: none;
  border-radius: 4px;
  color: var(--text-tertiary);
  margin-left: 1px;
}

/* ==========================================================================
   Main Viewport
   ========================================================================== */

.main-viewport {
  flex: 1;
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
  width: 100%;
  background-color: var(--bg-primary);
}

.study-pane {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 100%;
  background-color: var(--bg-primary);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Bottom Navigation Bar & Scrubber
   ========================================================================== */

.app-footer {
  height: var(--footer-height);
  min-height: var(--footer-height);
  max-height: var(--footer-height);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  user-select: none;
  z-index: 40;
}

/* Desktop: floating rounded dock instead of a full-width slab */
@media (min-width: 768px) {
  .app-footer {
    width: min(780px, calc(100% - 32px));
    margin: 0 auto 14px;
    padding: 0 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.04);
  }

  [data-theme="dark"] .app-footer {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

.footer-nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.footer-nav-btn:hover:not(:disabled) {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

#next-btn {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

#next-btn:hover:not(:disabled) {
  background-color: var(--btn-primary-hover);
  color: var(--btn-primary-text);
}

.footer-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.footer-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 24px;
  max-width: 600px;
}

.slide-stepper-text {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.slide-progress-track {
  flex: 1;
  height: 6px;
  background-color: color-mix(in srgb, var(--text-primary) 8%, transparent);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: height 0.15s ease, background-color 0.15s ease;
}

.slide-progress-track::before {
  content: '';
  position: absolute;
  top: -7px;
  bottom: -7px;
  left: 0;
  right: 0;
}

.slide-progress-track:hover {
  height: 8px;
  background-color: color-mix(in srgb, var(--text-primary) 12%, transparent);
}

.slide-progress-bar {
  position: relative;
  height: 100%;
  min-width: 6px;
  background-color: var(--accent-primary);
  border-radius: 999px;
  width: 0%;
  transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.slide-progress-bar::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--bg-surface);
  border: 3px solid var(--accent-primary);
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transform: translateY(-50%) scale(0);
  transition: transform 0.15s ease;
}

.slide-progress-track:hover .slide-progress-bar::after {
  transform: translateY(-50%) scale(1);
}

.footer-action-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  height: 32px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.footer-action-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.footer-action-btn.active {
  background-color: var(--accent-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-text);
}

/* ==========================================================================
   Tabular Typography & Accounting Tables
   Classic ledger lines, tabular figures, no artificial rounded borders
   ========================================================================== */

.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

.table-scroll-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 18px 0;
  border: none;
  background: transparent;
}

.table-scroll-wrapper > .accounting-table {
  margin: 0;
}

.accounting-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  font-size: 0.88rem;
  margin: 18px 0;
  background: transparent;
  border: none;
}

.accounting-table th {
  padding: 9px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-strong);
  border-bottom: 1.5px solid var(--text-primary);
  background: transparent;
  text-align: left;
}

.accounting-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  text-align: left;
  line-height: 1.5;
  vertical-align: top;
}

.accounting-table tbody tr:hover td {
  background-color: color-mix(in srgb, var(--bg-secondary) 50%, transparent);
}

.accounting-table td.amount,
.accounting-table th.amount {
  text-align: right;
  white-space: nowrap;
}

.accounting-table tr.total-row td {
  border-top: 1px solid var(--text-primary);
  border-bottom: 3px double var(--text-primary);
  font-weight: 700;
  background: transparent;
}

/* Debit / Credit Inline Tags */
.debit-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--debit-color);
  letter-spacing: 0.02em;
}

.credit-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--credit-color);
  letter-spacing: 0.02em;
}

/* ==========================================================================
   SVG Vector Icons
   ========================================================================== */

.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Reset Modal & Floating Toast Notification
   ========================================================================== */

.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.kc-reset-slide-btn {
  color: var(--text-tertiary);
  transition: all 0.15s ease;
}

.kc-reset-slide-btn:hover {
  color: var(--credit-color) !important;
  border-color: var(--credit-color) !important;
  background-color: var(--credit-bg) !important;
}
