/* =====================================================================
   UNIFIED STYLE.CSS – Single source of truth für alle Seiten
   ===================================================================== */

/* ── CSS Variables ──────────────────────────────────────────────────── */
:root {
  --primary:       #003d87;
  --primary-light: #0056b3;
  --secondary:     #e60000;
  --success:       #0b7a0b;
  --warning:       #a67c00;
  --danger:        #c62828;
  --gray:          #888888;

  --bg:            #f7f9fc;
  --bg-card:       #ffffff;
  --menu-bg:       rgba(255, 255, 255, 0.9);

  --text:          #333333;
  --text-muted:    #666666;

  --border:        #dddddd;
  --shadow:        rgba(0, 0, 0, 0.1);
  --highlight:     rgba(0, 61, 135, 0.12);
}

html.dark {
  --primary:       #4a90d9;
  --primary-light: #6ba3e0;
  --secondary:     #ff4444;
  --success:       #2ecc71;
  --warning:       #f39c12;
  --danger:        #ef5350;
  --gray:          #aaaaaa;

  --bg:            #1a1a2e;
  --bg-card:       #16213e;
  --menu-bg:       rgba(22, 33, 62, 0.9);

  --text:          #eeeeee;
  --text-muted:    #aaaaaa;

  --border:        #333333;
  --shadow:        rgba(0, 0, 0, 0.3);
  --highlight:     rgba(74, 144, 217, 0.2);
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.5;
  transition: background 0.3s, color 0.3s;
}

/* Seiten mit fixed header bekommen Abstand */
body.has-header { padding-top: 70px; }

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  background: var(--bg-card);
  color: var(--primary);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: 0 4px 12px var(--shadow);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
header img { height: 32px; flex-shrink: 0; }
header h1  { margin: 0; font-size: 1.5em; font-weight: 700; flex: 1; min-width: 200px; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--shadow); }

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-gray      { background: var(--gray);      color: #fff; }
.btn-blue      { background: var(--primary);   color: #fff; }
.btn-sm        { padding: 5px 10px; font-size: 0.82em; }
.btn-lg        { padding: 12px 24px; font-size: 1em; }

/* ── Status Labels ──────────────────────────────────────────────────── */
.status-label          { padding: 4px 10px; border-radius: 4px; color: #fff; font-weight: bold; font-size: 0.85em; }
.status-wartend        { background: var(--warning); }
.status-in_bearbeitung { background: var(--success); }
.status-fertig         { background: var(--gray); }

/* ── Karten ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 8px var(--shadow);
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 20px;
}
.section h3 {
  margin: 0 0 14px 0;
  color: var(--primary);
  font-size: 1.1em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* ── Tabellen ───────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
th {
  background: var(--primary);
  color: #fff;
  padding: 8px 10px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}
td { border: 1px solid var(--border); padding: 8px 10px; white-space: nowrap; }
tr:hover { background: rgba(0, 61, 135, 0.05); }

/* ── Formulare ──────────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.95em;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

/* ── Menü ───────────────────────────────────────────────────────────── */
.user-menu-wrapper { position: relative; }

.menu-btn {
  background: none; border: none;
  font-size: 24px; cursor: pointer;
  color: var(--primary); padding: 6px 10px;
  border-radius: 8px; transition: all 0.3s ease;
}
.menu-btn:hover { background: var(--bg); transform: scale(1.1); }

.glass-panel {
  background: var(--menu-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.menu-dropdown {
  position: absolute; right: 0; top: 45px;
  min-width: 220px; display: none;
  z-index: 1000; box-shadow: 0 6px 16px var(--shadow);
}
.menu-dropdown.show { display: block; }

.menu-flyout {
  position: absolute; right: 102%; top: 0;
  display: none; z-index: 1000; min-width: 220px;
  box-shadow: 0 6px 16px var(--shadow);
}
.menu-flyout.show { display: block; }

#menuDropdown { position: absolute; top: 100%; right: 0; }
#menuFlyout {
  position: absolute; right: 100%; top: 0;
  background: var(--menu-bg);
  backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--border);
  border-radius: 16px; display: none;
  min-width: 220px; z-index: 1100;
}

.menu-item,
.menu-dropdown a,
.menu-dropdown button {
  display: flex; width: 100%;
  padding: 12px 16px; background: none; border: none;
  text-align: left; font-size: 14px; cursor: pointer;
  color: var(--text); text-decoration: none;
  align-items: center; gap: 10px;
  transition: background 0.2s;
}
.menu-item:hover,
.menu-item.hover-active,
.menu-dropdown a:hover,
.menu-dropdown button:hover {
  background: rgba(0, 61, 135, 0.08);
  color: var(--primary);
}

.menu-dropdown .dark-toggle,
.menu-dropdown .notif-toggle {
  background: none; border: none; border-radius: 0;
  padding: 12px 16px; width: 100%; text-align: left;
  font-size: 14px; cursor: pointer; color: var(--text);
  font-weight: normal; display: flex; align-items: center; gap: 10px;
  transition: background 0.2s;
}
.menu-dropdown .dark-toggle:hover,
.menu-dropdown .notif-toggle:hover {
  background: rgba(0, 61, 135, 0.08); color: var(--primary);
}

.menu-divider { height: 1px; background: var(--border); margin: 5px 0; }

.dark-toggle {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  color: var(--text); font-size: 0.9em; transition: all 0.2s;
}
.dark-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-card {
  width: min(920px, 96%); background: var(--bg-card);
  padding: 20px; border-radius: 12px;
  border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.modal-header {
  display: flex; justify-content: space-between;
  align-items: center; gap: 12px; margin-bottom: 12px;
}
.modal-content { color: var(--text); white-space: pre-wrap; line-height: 1.5; }
.modal-close-btn {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--text-muted); transition: color 0.2s;
}
.modal-close-btn:hover { color: var(--secondary); }

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; z-index: 9999;
  display: flex; flex-direction: column;
  gap: 10px; pointer-events: none;
}
.toast-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  display: flex; gap: 12px; padding: 14px 16px;
  align-items: flex-start;
  transform: translateX(20px) translateY(10px); opacity: 0;
  transition: transform 360ms cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 260ms ease;
  pointer-events: all;
}
.toast-item.show      { transform: none; opacity: 1; }
.toast-body           { flex: 1 1 auto; min-width: 0; }
.toast-title          { font-weight: 700; font-size: 14px; margin-bottom: 2px; color: var(--text); }
.toast-message        { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.toast-close          { background: transparent; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 2px; margin-left: 8px; border-radius: 6px; opacity: 0.5; transition: opacity 0.2s; }
.toast-close:hover    { opacity: 1; }
.toast-success        { border-left-color: #10b981 !important; }
.toast-error          { border-left-color: #ef4444 !important; }
.toast-info           { border-left-color: #3b82f6 !important; }
.toast-warning        { border-left-color: #f59e0b !important; }
.toast-container.pos-bottom-right { bottom: 24px; right: 24px; top: auto; left: auto; flex-direction: column-reverse; }
.toast-container.pos-top-right    { top: 24px; right: 24px; bottom: auto; left: auto; flex-direction: column; }
html.dark .toast-item { background: rgba(26,28,30,0.65); border-color: rgba(255,255,255,0.08); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }

/* ── Filter-Bar (asc / rc) ──────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px; background: var(--bg); border-radius: 10px;
  border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0,0,0,0.03);
  position: sticky; top: 70px; z-index: 60;
}
.filter-item          { display: flex; flex-direction: column; gap: 6px; }
.filter-item label    { font-size: 0.75rem; color: var(--text-muted); }
.btn-row              { display: flex; gap: 8px; align-items: center; }

/* ── Reason-Code Picker ─────────────────────────────────────────────── */
.rc-brand-btn {
  cursor: pointer; transition: all .12s ease;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; background: var(--bg); color: var(--text);
}
.rc-brand-btn.active, .rc-brand-btn.selected,
.rc-cat-tile.selected {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff; border-color: var(--primary);
  box-shadow: 0 12px 36px rgba(0,0,0,0.15); transform: translateY(-6px);
}
.rc-cat-tile {
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease;
  border-radius: 8px; padding: 10px; text-align: center;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
}
.rc-cat-tile:hover { transform: translateY(-4px); box-shadow: 0 8px 30px rgba(0,0,0,0.08); }

.rc-subcat-tile {
  cursor: pointer; transition: all .12s ease;
  border-radius: 8px; padding: 10px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
}
.rc-subcat-tile.selected {
  border-color: var(--primary); color: var(--primary);
  box-shadow: 0 8px 26px rgba(0,0,0,0.12);
  transform: translateY(-3px); border-left: 4px solid var(--primary);
}
.rc-reason-btn { cursor: pointer; transition: all .12s ease; border-radius: 8px; padding: 8px; text-align: left; border: 1px solid var(--border); background: var(--bg); }
.rc-reason-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

.reason-path       { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.95em; color: var(--text-muted); }
.reason-path .segment { padding: 2px 8px; border-radius: 6px; }
.reason-path .segment.current { background: var(--primary); color: #fff; font-weight: 700; }
.reason-path .sep  { color: var(--text-muted); margin: 0 4px; }

/* ── Help Dropdown ──────────────────────────────────────────────────── */
.help-dropdown {
  position: fixed; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 9999;
  min-width: 160px; max-height: 300px; overflow-y: auto; display: none;
}
.help-dropdown.open { display: block; }
.help-select-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; cursor: pointer; transition: background 0.2s; }
.help-select-item:hover    { background: var(--bg); }
.help-select-item.selected { background: var(--primary); color: #fff; }

/* ── Berater Option ─────────────────────────────────────────────────── */
.berater-option {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: 80px; height: 80px; padding: 8px;
  cursor: pointer; border-radius: 12px; transition: transform 0.2s, background 0.2s;
  background: var(--bg-card); border: 1px solid var(--border);
}
.berater-option:hover { transform: scale(1.05); background: rgba(0,61,135,0.06); border-color: var(--primary); }

/* ── Block (index Dashboard) ────────────────────────────────────────── */
.block {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 2em; min-width: 120px;
  box-shadow: 0 2px 8px var(--shadow); transition: background 0.2s; border-radius: 8px;
}
.block:hover { background: #e0f7fa; }
html.dark .block:hover { background: rgba(74,144,217,0.07); }

/* ── contenteditable ────────────────────────────────────────────────── */
.block-title[contenteditable] {
  outline: 2px dashed var(--primary); padding: 0.2em 0.5em;
  border-radius: 4px; min-width: 60px; cursor: text; background: #f0faff;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  header h1 { font-size: 1.2em; }
  .filter-bar { top: 60px; }
  .filter-item input[type=text] { min-width: 140px; }
}

@media print {
  header, .menu-btn, .dark-toggle { display: none !important; }
  body { background: #fff !important; color: #000 !important; padding: 0 !important; }
}
