/* ============================================================
   eBO Dashboard — app.css
   Full multi-page SPA with sidebar navigation
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg:           #F0F2F5;
  --surface:      #FFFFFF;
  --surface2:     #F7F8FA;
  --border:       #E2E8F0;
  --text:         #1A202C;
  --text-muted:   #718096;
  --text-inv:     #FFFFFF;
  --accent:       #3B82F6;
  --accent-dark:  #2563EB;
  --accent-light: #EFF6FF;
  --success:      #10B981;
  --warn:         #F59E0B;
  --danger:       #EF4444;
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       10px;
  --shadow:       0 1px 4px rgba(0,0,0,.08);
  --shadow-md:    0 4px 12px rgba(0,0,0,.1);
}

[data-theme="dark"] {
  --bg:          #0F1117;
  --surface:     #1A1D27;
  --surface2:    #1E2130;
  --border:      #2D3148;
  --text:        #E2E8F0;
  --text-muted:  #718096;
  --text-inv:    #0F1117;
  --accent:      #60A5FA;
  --accent-dark: #3B82F6;
  --accent-light:#1E2A40;
  --success:     #34D399;
  --warn:        #FBBF24;
  --danger:      #F87171;
  --shadow:      0 1px 4px rgba(0,0,0,.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,.5);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; color: var(--text); }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .2s ease;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.logo-icon { font-size: 20px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-icon { font-size: 16px; min-width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.theme-toggle-btn {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  transition: all .15s;
}
.theme-toggle-btn:hover { color: var(--text); background: var(--bg); }

/* ---------- Main wrap ---------- */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}
.main-wrap.sidebar-hidden { margin-left: 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  z-index: 50;
  flex-shrink: 0;
}
.sidebar-toggle {
  background: none; border: none;
  font-size: 18px; color: var(--text-muted);
  padding: 4px 6px; border-radius: 6px;
  transition: background .15s;
}
.sidebar-toggle:hover { background: var(--surface2); }
.topbar-title {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
}
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.room-select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  font-size: 13px;
  min-width: 180px;
  color: var(--text);
}
.date-input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  font-size: 12px;
  color: var(--text);
}

/* ---------- Buttons ---------- */
.btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ---------- Error box ---------- */
.error-box {
  margin: 8px 16px 0;
  padding: 12px 16px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  color: #991B1B;
  font-size: 13px;
  white-space: pre-wrap;
}
[data-theme="dark"] .error-box { background: #3B1010; border-color: #7F1D1D; color: #FCA5A5; }

/* ---------- Pages ---------- */
.page {
  display: none;
  padding: 16px;
  flex: 1;
}
.page.active { display: block; }

/* ---------- Upload strip ---------- */
.upload-strip {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.upload-item { display: flex; gap: 8px; align-items: center; }
.file-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.file-label input[type="file"] { font-size: 11px; }
.upload-status { font-size: 12px; color: var(--success); }

/* ---------- KPI row ---------- */
.kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.kpi-card {
  flex: 1;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--text); }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.kpi-card.good .kpi-value { color: var(--success); }
.kpi-card.warn .kpi-value { color: var(--warn); }
.kpi-card.bad .kpi-value { color: var(--danger); }

/* ---------- Chart cards ---------- */
.charts-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.charts-grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .charts-grid-2col, .charts-grid-3col { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.chart-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--text); }
.chart-room-badge {
  margin-left: auto;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.chart-area { height: 280px; }
.chart-area-tall { height: 600px; }
.panel-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 10px;
}
.text-muted { color: var(--text-muted); font-size: 13px; }

/* ---------- Tab bar (Analyse page) ---------- */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---------- Controls strip (Nutzzeiten) ---------- */
.controls-strip {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.controls-strip label { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.num-input {
  width: 56px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  text-align: center;
}

/* ---------- Meteo monthly grid ---------- */
.meteo-monthly-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 800px) { .meteo-monthly-grid { grid-template-columns: repeat(2, 1fr); } }
.meteo-month-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.meteo-month-label {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.meteo-month-chart { height: 150px; }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; }
.empty-text { text-align: center; font-size: 14px; line-height: 1.6; }

/* ---------- Notes page ---------- */
.notes-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  height: calc(100vh - var(--topbar-h) - 32px);
}
@media (max-width: 700px) { .notes-layout { grid-template-columns: 1fr; } }
.notes-sidebar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-y: auto;
}
.notes-sidebar-panel h3 { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.notes-room-list { display: flex; flex-direction: column; gap: 4px; }
.notes-room-btn {
  padding: 8px 10px;
  border: 1px solid transparent;
  background: none;
  border-radius: 7px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  transition: all .15s;
  word-break: break-all;
}
.notes-room-btn:hover { background: var(--surface2); }
.notes-room-btn.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent-light); }
.notes-main-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-y: auto;
}
.notes-room-header { margin-bottom: 20px; }
.notes-room-header h2 { font-size: 18px; font-weight: 700; }
.notes-form { display: flex; flex-direction: column; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.form-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  font-size: 13px;
  color: var(--text);
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  font-size: 13px;
  color: var(--text);
  resize: vertical;
}
.form-textarea:focus { outline: none; border-color: var(--accent); }
.airflow-row { display: flex; gap: 8px; }
.airflow-display { font-size: 12px; color: var(--text-muted); }
.form-actions { display: flex; align-items: center; gap: 12px; }
.saved-msg { font-size: 12px; color: var(--success); }

/* ---------- Export page ---------- */
.export-cards { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.export-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.export-card-pdf { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface2)); }
.export-card-icon { font-size: 28px; }
.export-card-text { flex: 1; }
.export-card-text strong { font-size: 14px; }
.export-card-text p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Project meta form ---------- */
.meta-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.meta-row { display: flex; gap: 12px; }
.meta-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.meta-field-full { flex: 1 0 100%; }
.meta-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.meta-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}
.meta-input:focus { outline: none; border-color: var(--accent); }
.meta-textarea { resize: vertical; min-height: 64px; }
.meta-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.meta-save-status { font-size: 12px; color: var(--text-muted); }


/* ---------- Sidebar sub-nav (Auto-Analyse) ---------- */
.nav-chevron {
  margin-left: auto;
  font-size: 11px;
  transition: transform .2s ease;
  color: var(--text-muted);
}
.nav-chevron.open { transform: rotate(90deg); }

.nav-subnav {
  display: none;
  padding-left: 20px;
  flex-direction: column;
  gap: 2px;
}
.nav-subnav.open { display: flex; }

.nav-subitem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: none;
  background: transparent;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.nav-subitem:hover { background: var(--surface2); color: var(--text); }
.nav-subitem.active { color: var(--accent); background: var(--accent-light); }
.nav-sublabel::before { content: "– "; }

/* ---------- Params Panel ---------- */
.params-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,.12);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.params-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.params-panel-header h3 { font-size: 14px; font-weight: 700; margin: 0; flex: 1; }
.params-room-badge {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 20px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.params-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.params-close-btn:hover { background: var(--surface2); color: var(--text); }

.params-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.param-group {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.param-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent);
  margin-bottom: 12px;
}
.param-row {
  margin-bottom: 12px;
}
.param-row:last-child { margin-bottom: 0; }
.param-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: block;
}
.param-control {
  display: flex;
  align-items: center;
  gap: 10px;
}
.param-control input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
.param-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
}
.param-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}
.params-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding-top: 6px;
}

/* ---------- Auto-Analyse page ---------- */
.analysis-rating-box {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  color: white;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.rating-header h3 {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.9;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rating-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.rating-score {
  font-size: 56px;
  font-weight: 700;
  min-width: 80px;
}
.rating-label {
  font-size: 18px;
  font-weight: 600;
}

.analysis-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 1000px) { .analysis-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .analysis-kpi-grid { grid-template-columns: 1fr; } }

.analysis-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}
.analysis-kpi:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
}
.kpi-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}
.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.analysis-insights,
.analysis-recommendations {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.analysis-insights h4,
.analysis-recommendations h4,
.analysis-trends h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.insights-list,
.recommendations-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insight-item,
.recommendation-item {
  padding: 12px;
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.recommendation-item {
  border-left-color: var(--success);
}

.insight-label,
.recommendation-label {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
}

.recommendation-label {
  color: var(--success);
}

.analysis-trends {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
