/* === CSS Variables === */
:root {
  --color-primary: #185FA5;
  --color-primary-light: #E6F1FB;
  --color-primary-dark: #0C447C;

  --bg-page: #F5F4F0;
  --bg-surface: #FFFFFF;
  --bg-muted: #F1EFE8;

  --text-primary: #1A1A1A;
  --text-secondary: #6B6B67;
  --text-tertiary: #9A9A96;

  --border-light: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.15);

  --color-success: #0F6E56;
  --color-success-bg: #E1F5EE;
  --color-warning: #854F0B;
  --color-warning-bg: #FAEEDA;
  --color-danger: #A32D2D;
  --color-danger-bg: #FCEBEB;

  --accent-thermo: #185FA5;
  --accent-rtd: #534AB7;
  --accent-signal: #0F6E56;
  --accent-unit: #854F0B;
  --accent-uncertainty: #993C1D;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --sidebar-width: 200px;
  --topbar-height: 52px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* Dark mode — manuel toggle ÖN PLANDA, sistem tercihi fallback */
[data-theme="dark"] {
  --bg-page: #1A1A1A;
  --bg-surface: #242424;
  --bg-muted: #2A2A2A;
  --text-primary: #F0F0F0;
  --text-secondary: #A0A0A0;
  --text-tertiary: #606060;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --color-primary-light: #1A2F45;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-page: #1A1A1A;
    --bg-surface: #242424;
    --bg-muted: #2A2A2A;
    --text-primary: #F0F0F0;
    --text-secondary: #A0A0A0;
    --text-tertiary: #606060;
    --border-light: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.15);
    --color-primary-light: #1A2F45;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

h1 { font-size: 20px; font-weight: 500; margin: 0 0 8px; }
h2 { font-size: 16px; font-weight: 500; margin: 0 0 6px; }
h3 { font-size: 14px; font-weight: 500; margin: 0; }
p  { margin: 0; }

/* === Layout === */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  z-index: 50;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  margin: 0 auto;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-primary);
}
.brand-icon { color: var(--color-primary); }
.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.brand-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: 4px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-version {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* Theme icon toggle */
[data-theme="light"] .icon-moon,
:root:not([data-theme="dark"]) .icon-moon { display: inline-block; }
[data-theme="light"] .icon-sun,
:root:not([data-theme="dark"]) .icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: inline-block; }
[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: inline-block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

.main-content {
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-page);
}

.loading-placeholder {
  text-align: center;
  color: var(--text-tertiary);
  padding: 48px 0;
}

.coming-soon-page,
.error-page {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}
.coming-soon-page h1 { color: var(--text-primary); margin-bottom: 8px; }
.coming-soon-page p { color: var(--text-tertiary); }

.module-page { max-width: 980px; margin: 0 auto; }

/* === Mobile === */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .hamburger { display: flex; }
  .brand-sub { display: none; }
  .main-content { padding: 16px; }
}
