/* Alenis Cockpit — Design-System (Lastenheft 11.3) */
:root {
  --grau-primaer: #58595B;
  --rot-akzent:   #E2231A;
  --text-schwarz: #1C1C1E;
  --grau-hell:    #F4F4F4;
  --border:       #D1D1D6;
  --grau-sek:     #8E8E93;
  --gruen:        #34A853;
  --orange:       #F2A900;
  --navy:         #1A2D4F;
  --weiss:        #FFFFFF;
  --radius-btn: 6px;
  --radius-card: 8px;
  --schatten: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --schatten-modal: 0 10px 40px rgba(0,0,0,.2);
  --max-width: 1280px;
  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --font-code: Consolas, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); font-size: 15px; color: var(--text-schwarz); background: var(--grau-hell); -webkit-text-size-adjust: 100%; }
h1 { font-size: 28px; font-weight: bold; margin: 0 0 12px; }
h2 { font-size: 22px; font-weight: bold; margin: 0 0 10px; }
h3 { font-size: 18px; font-weight: bold; margin: 0 0 8px; }
code, pre { font-family: var(--font-code); font-size: 13px; }
a { color: var(--rot-akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--grau-sek); }
.app-shell { max-width: var(--max-width); margin: 0 auto; padding: 16px; }

/* Header & Navigation */
.app-header { display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--weiss); position: sticky; top: 0; z-index: 50; }
.app-header[hidden] { display: none; }   /* [hidden] muss display:flex überstimmen */
.app-header img.logo { height: 32px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav button { background: none; border: none; padding: 8px 12px; border-radius: var(--radius-btn); cursor: pointer; font-size: 15px; color: var(--grau-primaer); white-space: nowrap; }
.topnav button.active { background: var(--grau-primaer); color: var(--weiss); }
.header-right { display: flex; align-items: center; gap: 10px; }
.usermenu { display: flex; align-items: center; gap: 8px; font-size: 14px; }
/* Hamburger — nur Mobile sichtbar (P19) */
.nav-toggle { display: none; background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; color: var(--grau-primaer); margin-left: auto; }
.nav-toggle[hidden] { display: none !important; }
@media (min-width: 768px) { .app-header img.logo { height: 48px; } }

/* Buttons */
.btn { font-family: var(--font); font-size: 15px; padding: 8px 14px; border-radius: var(--radius-btn); border: 1px solid var(--border); background: var(--weiss); color: var(--text-schwarz); cursor: pointer; }
.btn:hover { background: var(--grau-hell); }
.btn-primary { background: var(--grau-primaer); color: var(--weiss); border-color: var(--grau-primaer); }
.btn-primary:hover { background: #46474a; }
.btn-danger { background: var(--rot-akzent); color: var(--weiss); border-color: var(--rot-akzent); }
.btn-sm { padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: none; color: var(--rot-akzent); cursor: pointer; padding: 0; }

/* Karten */
.card { border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--schatten); padding: 16px; background: var(--weiss); margin-bottom: 16px; }

/* Metrik-Kacheln */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--weiss); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; cursor: pointer; text-align: center; }
.tile.active { border-color: var(--grau-primaer); box-shadow: var(--schatten); }
.tile .num { font-size: 28px; font-weight: bold; }
.tile .lbl { color: var(--grau-sek); font-size: 13px; }

/* Toolbar (Filter/Sortier/Suche) */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-btn); font-size: 14px; font-family: var(--font); }
.toolbar .grow { flex: 1; min-width: 160px; }
.spacer { flex: 1; }

/* Tabellen */
table.data { width: 100%; border-collapse: collapse; background: var(--weiss); border-radius: var(--radius-card); overflow: hidden; }
table.data th { background: var(--grau-primaer); color: var(--weiss); text-align: left; padding: 10px; font-size: 13px; font-weight: bold; }
table.data th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.data th.sortable:hover { background: #46474a; }
table.data td { padding: 10px; border-top: 1px solid var(--border); font-size: 14px; }
table.data tbody tr:nth-child(even) { background: var(--grau-hell); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: #eaeaea; }
.row-actions { text-align: right; white-space: nowrap; }

/* Karten-Liste (Mobile / >5 Spalten, P18) */
.cardlist { display: none; flex-direction: column; gap: 10px; }
.item-card { background: var(--weiss); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 12px; box-shadow: var(--schatten); }
.item-card .ic-title { font-weight: bold; margin-bottom: 4px; }
.item-card .ic-meta { color: var(--grau-sek); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.item-card .ic-actions { display: flex; gap: 8px; }

/* Badges / Status */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: bold; white-space: nowrap; }
.badge-grau { background: var(--grau-hell); color: var(--grau-primaer); }
.badge-gruen { background: #e6f4ea; color: var(--gruen); }
.badge-orange { background: #fdf0d5; color: #9a6b00; }
.badge-rot { background: #fde7e6; color: var(--rot-akzent); }
.badge-blau { background: #e7eefb; color: var(--navy); }
.overdue { color: var(--rot-akzent); font-weight: bold; }

/* Tabs (Projektdetail) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer; font-size: 15px; color: var(--grau-sek); white-space: nowrap; }
.tabs button.active { color: var(--text-schwarz); border-bottom-color: var(--rot-akzent); font-weight: bold; }

/* Formulare */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; color: var(--grau-primaer); font-weight: bold; }
.form-field input, .form-field select, .form-field textarea { padding: 9px; border: 1px solid var(--border); border-radius: var(--radius-btn); font-size: 15px; font-family: var(--font); width: 100%; box-sizing: border-box; }
.form-field textarea { min-height: 80px; resize: vertical; }

/* Modal — Vollbild auf Mobile (P16) */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay[hidden] { display: none; }
.modal { background: var(--weiss); border-radius: var(--radius-card); box-shadow: var(--schatten-modal); width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { padding: 16px; border-bottom: 1px solid var(--border); font-size: 18px; font-weight: bold; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }

/* Freigaben-Bereich */
.freigaben { border: 1px dashed var(--border); border-radius: var(--radius-card); padding: 12px; margin-top: 12px; }
.freigaben .fg-row { display: flex; align-items: center; gap: 16px; padding: 6px 0; }
.freigaben .fg-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; }

/* Capture */
.capture-wrap { text-align: center; padding: 24px 0; }
.record-btn { width: 160px; height: 160px; border-radius: 50%; border: none; background: var(--rot-akzent); color: var(--weiss); font-size: 18px; font-weight: bold; cursor: pointer; box-shadow: var(--schatten-modal); }
.record-btn.recording { animation: pulse 1.2s infinite; background: #b81b14; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(226,35,26,.5);} 70%{box-shadow:0 0 0 24px rgba(226,35,26,0);} 100%{box-shadow:0 0 0 0 rgba(226,35,26,0);} }
.queue-info { margin-top: 16px; color: var(--grau-sek); }

/* Login */
.login-wrap { max-width: 380px; margin: 8vh auto; }
.login-wrap .card { padding: 24px; }
.login-wrap .form-field { margin-bottom: 12px; }

/* Toast (P8) */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text-schwarz); color: var(--weiss); padding: 12px 18px; border-radius: var(--radius-btn); z-index: 200; box-shadow: var(--schatten-modal); max-width: 90vw; }
.toast[hidden] { display: none; }
.toast.err { background: var(--rot-akzent); }
.toast.ok { background: var(--gruen); }

/* Mobile (P16–P19, Breakpoint 768px) */
@media (max-width: 767px) {
  .tiles { grid-template-columns: 1fr 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; } /* einspaltig (P17) */
  table.data { display: none; }
  .cardlist { display: flex; }
  .overlay { display: block; padding: 0; }
  .overlay[hidden] { display: none; }
  .modal { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
  .ic-actions .btn { opacity: 1; } /* Edit immer sichtbar (P18) */

  /* P19 — Navigation als Hamburger-Drawer statt Horizontal-Scroll */
  .app-header { flex-wrap: wrap; gap: 8px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topnav, .header-right {
    display: none;
    flex-basis: 100%;
    width: 100%;
  }
  .app-header.nav-open .topnav,
  .app-header.nav-open .header-right {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .topnav button { width: 100%; text-align: left; padding: 12px 14px; font-size: 16px; }
  .header-right { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; gap: 8px; }
  .usermenu { flex-direction: column; align-items: stretch; gap: 8px; }
  .usermenu .btn { width: 100%; }
  .install-btn { width: 100%; }
}
