/* ==========================================================================
   DanskVocab - Main Design System & Layout
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand colors */
  --color-primary: hsl(351, 82%, 46%);
  --color-primary-hover: hsl(351, 85%, 38%);
  --color-primary-light: hsl(351, 100%, 96%);
  --color-primary-dark: hsl(351, 80%, 30%);
  --color-accent: hsl(205, 85%, 48%);
  --color-accent-light: hsl(205, 90%, 95%);

  /* Grammar color coding */
  --pos-noun: hsl(210, 80%, 45%);
  --pos-noun-bg: hsl(210, 100%, 96%);
  --pos-noun-border: hsl(210, 80%, 85%);
  
  --pos-verb: hsl(152, 70%, 35%);
  --pos-verb-bg: hsl(152, 75%, 96%);
  --pos-verb-border: hsl(152, 60%, 82%);

  --pos-adj: hsl(38, 92%, 44%);
  --pos-adj-bg: hsl(38, 100%, 95%);
  --pos-adj-border: hsl(38, 80%, 80%);

  --pos-other: hsl(270, 60%, 48%);
  --pos-other-bg: hsl(270, 80%, 96%);
  --pos-other-border: hsl(270, 60%, 85%);

  /* Neutrals (Light Mode) */
  --bg-app: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f3f5;
  --bg-surface-elevated: #ffffff;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;
  
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: hsl(351, 82%, 46%);

  /* Feedback colors */
  --color-success: hsl(150, 75%, 38%);
  --color-success-bg: hsl(150, 80%, 95%);
  --color-warning: hsl(35, 95%, 48%);
  --color-warning-bg: hsl(35, 95%, 95%);
  --color-danger: hsl(0, 80%, 55%);
  --color-danger-bg: hsl(0, 85%, 96%);

  /* Typography */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-main);
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 12px 30px -10px rgba(0, 0, 0, 0.07), 0 4px 10px -2px rgba(0, 0, 0, 0.03);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark mode theme */
[data-theme="dark"] {
  --bg-app: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-subtle: #182234;
  --bg-surface-elevated: #243248;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --border-light: #334155;
  --border-medium: #475569;
  
  --color-primary-light: hsl(351, 60%, 18%);
  
  --pos-noun-bg: hsl(210, 60%, 18%);
  --pos-noun-border: hsl(210, 50%, 30%);
  
  --pos-verb-bg: hsl(152, 50%, 16%);
  --pos-verb-border: hsl(152, 45%, 28%);

  --pos-adj-bg: hsl(38, 60%, 18%);
  --pos-adj-border: hsl(38, 50%, 30%);

  --pos-other-bg: hsl(270, 50%, 18%);
  --pos-other-border: hsl(270, 40%, 30%);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 12px -2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 20px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 24px 32px -6px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 14px 35px -10px rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

/* ==========================================================================
   App Shell & Left Sidebar Navigation
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: var(--shadow-xs);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-brand-wrapper {
  padding: 1.25rem 1.25rem 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-facilities {
  flex: 1;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 0 0.6rem 0.4rem 0.6rem;
}

.facility-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  width: 100%;
}

.facility-btn:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-main);
}

.facility-btn.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: rgba(224, 36, 62, 0.2);
  font-weight: 700;
}

.facility-btn-icon {
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.facility-btn-text {
  display: flex;
  flex-direction: column;
}

.facility-btn-name {
  font-size: 0.95rem;
  line-height: 1.2;
}

.facility-btn-desc {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-subtle);
  margin-top: 0.15rem;
}

.facility-btn.active .facility-btn-desc {
  color: var(--color-primary);
  opacity: 0.85;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-surface-subtle);
}

/* App Main Content Area */
.app-main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.facility-panel {
  display: none;
  width: 100%;
  flex: 1;
}

.facility-panel.active {
  display: flex;
  flex-direction: column;
}

/* Mobile Sidebar & Responsiveness */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }

  .sidebar-facilities {
    flex-direction: row;
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
  }

  .facility-btn {
    padding: 0.6rem 0.85rem;
    white-space: nowrap;
  }

  .facility-btn-desc {
    display: none;
  }
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.25rem;
  font-family: var(--font-display);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  text-transform: uppercase;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface-subtle);
  padding: 0.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .nav-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  background: var(--bg-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.tab-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  font-weight: 700;
}

.tab-badge:empty {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Main Layout */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 250ms ease-out forwards;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Layout Grids */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 960px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
  .header-container {
    flex-wrap: wrap;
  }
  .nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }
}

/* Section Header */
.section-head {
  margin-bottom: 1.5rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* Footer */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
  padding: 1.25rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: gap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--color-primary);
}

@media (max-width: 640px) {
  .footer-container {
    flex-direction: column;
    text-align: center;
  }
}
