/* === Variablen === */
:root {
  --primary: #3498db;
  --primary-dark: #2176ae;
  --secondary: #6c757d;
  --danger: #e74c3c;
  --success: #27ae60;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ============================================================
   LOGIN
============================================================ */
#login {
  max-width: 380px;
  margin: 8vh auto;
  background: var(--surface);
  padding: 2rem 2.2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
#appTitle {
  color: var(--primary);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1.2rem;
}
#appTitle span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.2rem;
}
#login input {
  width: 100%;
  margin: 0.4rem 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  display: block;
  transition: border-color 0.2s;
}
#login input:focus { outline: none; border-color: var(--primary); }
#login button { width: 100%; margin-top: 0.8rem; }
#loginStatus { font-size: 0.85rem; margin-top: 0.5rem; color: var(--danger); min-height: 1.2rem; }

/* ============================================================
   HAUPTBEREICH
============================================================ */
#main {
  max-width: 1280px;
  margin: 0.8rem auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: none;
  overflow: hidden;
}

/* ============================================================
   HEADER – kompakt
============================================================ */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 1.2rem;
  background: var(--primary);
  color: #fff;
}
.app-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}
#userInfo {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
}
.app-header .btn-secondary {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}
.app-header .btn-secondary:hover {
  background: rgba(255,255,255,0.25);
}

/* ============================================================
   TABS – kompakt
============================================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  padding: 0 0.5rem;
  gap: 0.1rem;
}
.tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  cursor: pointer;
  background: transparent;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   TAB-INHALTE
============================================================ */
[id^="tabContent"] { padding: 0.8rem 1rem; }

/* ============================================================
   3-SPALTEN LAYOUT
============================================================ */
.report-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.report-toolbar label { font-weight: 600; font-size: 0.88rem; }
.report-toolbar input[type="date"] { padding: 0.3rem 0.5rem; font-size: 0.88rem; }

.report-layout {
  display: grid;
  grid-template-columns: 18% 18% 64%;
  height: calc(100vh - 155px);
}
.report-layout .col {
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.report-layout .col:last-child { border-right: none; }

.youth-item,
#reportDays div, #arztReportDays div {
  padding: 0.45rem 0.8rem;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.youth-item:hover, #reportDays div:hover, #arztReportDays div:hover { background: #f0f6ff; }
.youth-item.active, #reportDays div.active, #arztReportDays div.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ============================================================
   EDITOR
============================================================ */
#editorArea {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0.5rem 0.7rem;
}
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
#editor {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  min-height: 260px;
  font-size: 0.92rem;
}
.ql-toolbar.ql-snow {
  border-radius: var(--radius) var(--radius) 0 0;
  border-color: var(--border) !important;
  background: #fafafa;
  padding: 4px 8px;
}
.ql-container.ql-snow {
  border-color: var(--border) !important;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 0.92rem;
}

/* ============================================================
   LOCK-INFO
============================================================ */
#lockInfo {
  display: none;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
}

/* ============================================================
   VERSIONEN
============================================================ */
#versionsBox {
  border-top: 1px solid var(--border);
  margin-top: 0.6rem;
  padding-top: 0.4rem;
}
#versionsBox h4 {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.version-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  background: #fafafa;
  overflow: hidden;
}
.version-header {
  background: #f3f4f6;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}
.version-header:hover { background: #e9eaec; }
.version-content {
  padding: 8px;
  background: #fff;
  font-size: 0.88rem;
  display: none;
}

/* ============================================================
   CARDS
============================================================ */
.card {
  background: var(--surface);
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card h4 {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.card input, .card select {
  display: block;
  margin: 0.35rem 0;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 220px;
  font-size: 0.9rem;
}
.card input:focus, .card select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.88rem;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn:active { transform: scale(0.97); }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #545b62; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-saved { background: var(--success) !important; color: #fff !important; opacity: 0.8; cursor: default; }

/* ============================================================
   TAGESÜBERSICHT
============================================================ */
#overviewContainer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}
#overviewContainer .card {
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.overview-content {
  white-space: pre-wrap;
  font-size: 0.9rem;
  margin-top: 0.3rem;
  color: var(--text);
  max-height: 180px;
  overflow-y: auto;
}

/* ============================================================
   TOASTS
============================================================ */
#toastContainer {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 9999;
}
.toast {
  min-width: 220px;
  max-width: 320px;
  background: #1f2937;
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 0.25s;
  font-size: 0.88rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

/* ============================================================
   SCROLLBAR
============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   SUBTABS
============================================================ */
.subtabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.8rem;
  gap: 0.2rem;
}
.subtab-btn {
  padding: 0.4rem 0.9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}
.subtab-btn:hover { color: var(--primary); }
.subtab-btn.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   VERWALTUNG
============================================================ */
.admin-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f3f4f6;
  flex-wrap: wrap;
}
.admin-row input, .admin-row select {
  padding: 0.28rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.86rem;
  min-width: 110px;
}
.admin-row input[disabled], .admin-row select[disabled] {
  background: #f9fafb;
  color: #9ca3af;
}

/* ============================================================
   ALLE BERICHTE
============================================================ */
.sticky-filter {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
}
.sticky-date {
  position: sticky;
  top: 3.8rem;
  z-index: 15;
  background: #f0f6ff;
  padding: 0.3rem 0.8rem;
  border-bottom: 1px solid #c7dcf7;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
  display: none;
}
.scrollable-reports {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  margin-top: 0.5rem;
}
.scrollable-reports .card {
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 0.6rem;
}
.scrollable-reports h4 {
  color: var(--primary);
  font-size: 0.9rem;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 900px) {
  .report-layout { grid-template-columns: 1fr; height: auto; }
  .report-layout .col { border-right: none; border-bottom: 1px solid var(--border); }
  #main { margin: 0; border-radius: 0; }
  .tabs { overflow-x: auto; }
}