@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: rgba(20, 20, 20, 0.85);
  --bg-card-hover: rgba(40, 40, 40, 1);
  --accent: #990014;
  --accent2: #545454;
  --accent3: #75000e;
  --text: #ffffff;
  --text-muted: #a0a0a0;
  --text-dim: #707070;
  --border: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(153, 0, 20, 0.5);
  --danger: #ef4444;
  --success: #22c55e;
  --sidebar-w: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

body.light-mode {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --accent: #990014;
  --accent2: #545454;
  --accent3: #d0001a;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border: rgba(0, 0, 0, 0.1);
  --border-accent: rgba(153, 0, 20, 0.3);
  --shadow: 0 4px 20px rgba(0,0,0,0.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
  background-image: radial-gradient(ellipse at 20% 50%, rgba(153,0,20,0.15) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 20%, rgba(84,84,84,0.15) 0%, transparent 50%);
}

body.light-mode {
  background-image: radial-gradient(ellipse at 20% 50%, rgba(153,0,20,0.05) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 20%, rgba(84,84,84,0.05) 0%, transparent 50%);
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-accent);
  background: var(--accent);
  color: #ffffff;
  min-height: 90px;
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.3));
}

.logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffffff;
}

.nav-menu { list-style: none; padding: 1rem 0; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(20,184,166,0.08);
}

.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.page { display: block; }
.page.hidden { display: none; }

.page-header {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border-accent);
  background: var(--accent);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #ffffff;
}

.page-subtitle { color: rgba(255,255,255,0.8); font-size: 0.875rem; margin-top: 0.25rem; }

.page-body { padding: 1.5rem 2rem; }

/* ── MENU TOGGLE (mobile) ── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  cursor: pointer;
}

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  transition: all var(--transition);
}

.card:hover { border-color: var(--border-accent); box-shadow: var(--shadow); }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ── DASHBOARD ── */
.dash-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.gauge-wrap { flex-shrink: 0; position: relative; }
#overall-gauge { width: 160px; height: 160px; }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#overall-percent {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.gauge-label { font-size: 0.7rem; color: var(--text-muted); }

.dash-hero-info { flex: 1; }
#dash-greeting { font-size: 1.75rem; font-weight: 700; }
#dash-info { color: var(--text-muted); margin-top: 0.5rem; font-size: 0.9rem; }
#overall-hours { color: var(--accent); font-weight: 600; margin-top: 1rem; font-size: 1rem; }

#dash-notes {
  color: var(--text);
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  backdrop-filter: blur(10px);
}

.cat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.cat-card-icon { font-size: 2rem; line-height: 1; }
.cat-card-info { flex: 1; min-width: 0; }
.cat-card-title { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.4rem; }
.cat-card-nums { font-size: 1rem; }
.cat-done { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.cat-slash { color: var(--text-dim); }
.cat-target { color: var(--text-muted); }

.progress-bar-wrap {
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
  height: 6px;
  margin: 0.6rem 0 0.4rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 100px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--accent);
}

.cat-card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
}

.cat-pct { color: var(--accent); font-weight: 600; }
.cat-remaining { color: var(--text-dim); }

/* ── MODULE HEADER ── */
.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.hours-counter { font-size: 1rem; }
.hours-done { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.hours-sep { color: var(--text-dim); margin: 0 0.4rem; }
.hours-target { font-size: 1.2rem; font-weight: 600; color: var(--text-muted); }
.hours-pct { color: var(--text-dim); margin-left: 0.5rem; }

.module-progress {
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
  margin-top: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.module-progress .progress-bar { background: linear-gradient(90deg, var(--accent2), var(--accent)); }

/* ── CALENDAR ── */
.calendar { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.cal-title { font-weight: 700; font-size: 1rem; }

.cal-nav-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.cal-nav-btn:hover { background: var(--accent); border-color: var(--accent); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  padding: 1px;
}

.cal-day-name {
  background: var(--bg-secondary);
  text-align: center;
  padding: 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.cal-day {
  background: var(--bg-primary);
  min-height: 60px;
  padding: 0.4rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.cal-day:hover { background: rgba(20,184,166,0.1); }
.cal-day.empty { background: rgba(15,23,42,0.5); cursor: default; }
.cal-day.today { background: rgba(99,102,241,0.15); border: 1px solid var(--accent2); }
.cal-day.has-entry { background: rgba(20,184,166,0.12); }

.cal-day-num {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.cal-day.today .cal-day-num { color: var(--accent2); font-weight: 700; }
.cal-day.has-entry .cal-day-num { color: var(--accent); font-weight: 700; }

.cal-entry-label {
  font-size: 0.7rem;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0 4px;
  margin-top: 2px;
  font-weight: 600;
}

/* ── DATA TABLE ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.data-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.data-table tbody tr.completed td { opacity: 0.6; }
.data-table tbody tr.completed td:first-child { opacity: 1; }

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1.5rem;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  font-family: inherit;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { padding: 1.5rem; }
.tab-panel.hidden { display: none; }

/* ── FORMS ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 0.4rem; }

.form-input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color var(--transition);
}

.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20,184,166,0.1); }
.form-input-lg { font-size: 1.5rem; font-weight: 700; text-align: center; padding: 1rem; }

.hours-minutes-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.hours-minutes-row .form-group { flex: 1; margin-bottom: 0; }

.hm-sep {
  padding-bottom: 0.65rem;
  color: var(--text-dim);
  font-size: 1.1rem;
  font-weight: 600;
  flex-shrink: 0;
}

.form-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.checkbox-label input[type=checkbox] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.input-with-btn { display: flex; gap: 0.5rem; }
.input-with-btn .form-input { flex: 1; }

/* ── BUTTONS ── */
.btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent3); transform: translateY(-1px); }
.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: rgba(255,255,255,0.12); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0.3rem; border-radius: 4px; transition: background var(--transition); color: var(--text); }
.btn-icon:hover { background: rgba(153,0,20,0.15); color: var(--accent); }

.actions-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.modal-overlay.active { display: flex; }

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: modalIn 0.2s ease;
  /* Klick-Events NICHT an das Overlay weitergeben */
  position: relative;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-date { color: var(--accent); font-weight: 600; font-size: 1rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; flex-wrap: wrap; }

/* ── TOAST ── */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
  max-width: 320px;
}

.toast.visible { opacity: 1; transform: translateX(0); }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }

/* ── MISC ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

.empty-state span { font-size: 3rem; display: block; margin-bottom: 1rem; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
}

.ai-status {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 1.5rem;
}

.ai-status.loading { background: rgba(245,158,11,0.1); color: var(--accent3); }
.ai-status.success { background: rgba(34,197,94,0.1); color: var(--success); }
.ai-status.error { background: rgba(239,68,68,0.1); color: var(--danger); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.col-left, .col-right { display: flex; flex-direction: column; gap: 1.5rem; }

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.key-group {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.key-toggle {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text);
  height: 38px;
  width: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background var(--transition);
}

.key-toggle:hover { background: rgba(255,255,255,0.15); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,0.6); }
  .main-content { margin-left: 0; height: 100vh; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .page-header { padding: 1rem 1rem 0.75rem 4rem; }
  .page-body { padding: 1rem; }
  .two-col { grid-template-columns: 1fr; }
  .dash-hero { flex-direction: column; text-align: center; }
  #dash-greeting { font-size: 1.25rem; }
  .cal-day { min-height: 44px; }
  .modal-box { padding: 1.5rem; }
}

@media (max-width: 480px) {
  .cat-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 0.8rem; }
  .data-table thead th, .data-table tbody td { padding: 0.5rem 0.6rem; }
}
