/* OPUS Cockpit – Stylesheet
   Pfad: app/app/static/style.css
   Version: V1, 04-05-2026 14:45:00 */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-mut: #6b7280;
  --sidebar: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #14b8a6;
  --accent: #008b8b;
  --accent-dark: #006a6a;

  --st-weiss: #f3f4f6;
  --st-weiss-border: #d1d5db;
  --st-blau: #3b82f6;
  --st-gelb: #eab308;
  --st-gruen: #22c55e;
  --st-orange: #f97316;
  --st-rot: #ef4444;
  --st-schwarz: #1f2937;
  --st-lila: #a855f7;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f6f8 0%, #e0f2f1 100%);
}
.login-card {
  background: white;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
  width: 380px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.brand-name { font-size: 24px; font-weight: 700; color: var(--text); }
.brand-sub { font-size: 13px; color: var(--text-mut); margin-top: 2px; }
.login-foot { font-size: 12px; color: var(--text-mut); text-align: center; margin-top: 16px; }

.error {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-mut); }
.form input, .form select, .form textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: white;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,139,139,.15);
}
.row { display: flex; gap: 12px; }
.row > label { flex: 1; }

.btn {
  background: white;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--text);
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); color: white; }
.btn-mini { padding: 4px 8px; font-size: 11px; }

/* ===== Impersonation Banner ===== */
.impersonation-banner {
  background: #fef3c7;
  color: #78350f;
  border-bottom: 2px solid #f59e0b;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.impersonation-banner .btn-mini {
  background: #78350f;
  color: white;
  border-color: #78350f;
}
.impersonation-banner .btn-mini:hover { background: #422006; }

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.brand {
  padding: 0 20px 16px;
  border-bottom: 1px solid #334155;
  margin-bottom: 16px;
}
.brand .name { color: white; font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.brand .sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.nav-section { padding: 0 8px; margin-bottom: 16px; }
.nav-section-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: #64748b; padding: 4px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 6px; cursor: pointer;
  color: var(--sidebar-text); margin-bottom: 2px; font-size: 13px;
}
.nav-item:hover { background: #334155; color: white; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: white; font-weight: 600; }
.nav-item .count {
  background: rgba(255,255,255,.15); padding: 1px 7px;
  border-radius: 10px; font-size: 11px;
}
.nav-item.active .count { background: rgba(255,255,255,.3); }
.nav-item.disabled { opacity: .5; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; color: var(--sidebar-text); }
.badge-soon {
  font-size: 9px; background: #475569; color: #cbd5e1;
  padding: 1px 5px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: .5px;
}

.user-block {
  padding: 12px 20px; border-top: 1px solid #334155;
  margin-top: auto; font-size: 12px;
}
.uname { color: white; font-weight: 600; }
.urole { color: #94a3b8; font-size: 11px; }

.main { overflow-y: auto; padding: 24px 32px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; }
.topbar h1 .sub { font-weight: 400; color: var(--text-mut); font-size: 14px; margin-left: 8px; }
.topbar .actions { display: flex; gap: 8px; }

.empty {
  padding: 60px;
  text-align: center;
  color: var(--text-mut);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ===== Items ===== */
.items {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  overflow: hidden;
}
.item {
  display: grid;
  grid-template-columns: 110px 1fr 130px 130px 100px 70px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: none; }
.item:hover { background: #fafbfc; }

.item-mid { min-width: 0; }
.item-title { font-weight: 600; color: var(--text); display: block; }
.item-title:hover { color: var(--accent); }
.item-meta { font-size: 12px; color: var(--text-mut); margin-top: 2px; }
.item-typ {
  display: inline-block; background: var(--bg); color: var(--text-mut);
  padding: 1px 7px; border-radius: 3px; font-size: 10px;
  text-transform: uppercase; letter-spacing: .5px; margin-right: 6px;
}
.gl-tag {
  display: inline-block; background: #fef3c7; color: #78350f;
  padding: 1px 6px; border-radius: 3px; font-size: 10px;
  text-transform: uppercase; letter-spacing: .5px; margin-left: 6px;
  border: 1px solid #f59e0b;
}

.next-actor { font-size: 12px; color: var(--text-mut); }
.next-actor strong { color: var(--text); }

.aging { text-align: right; font-size: 12px; }
.aging.fresh { color: var(--text-mut); }
.aging.warn { color: var(--st-orange); font-weight: 600; }
.aging.alarm { color: var(--st-rot); font-weight: 600; }

/* Deadline-Spalte in der Inbox-Liste */
.due-col { font-size: 11px; text-align: center; }
.due-col .due { display: inline-block; padding: 3px 8px; border-radius: 10px;
                font-weight: 600; line-height: 1.3; }
.due.overdue { background: #fee2e2; color: #b91c1c; }
.due.soon    { background: #fef3c7; color: #92400e; }
.due.later   { background: #f3f4f6; color: #4b5563; font-weight: 500; }
.due-empty   { color: #d1d5db; }
.due-date-small { font-size: 10px; opacity: .8; font-weight: 500; }

.prio { text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mut); }
.prio-hoch { color: var(--st-rot); font-weight: 700; }

/* ===== Status-Pill ===== */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  cursor: pointer; border: 1px solid transparent;
  transition: transform .1s;
}
.status-pill:hover { transform: scale(1.05); }
.status-pill.large { font-size: 12px; padding: 6px 14px; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-weiss { background: var(--st-weiss); color: #4b5563; border-color: var(--st-weiss-border); }
.st-leer { background: #f9fafb; color: #6b7280; border-color: #e5e7eb; }
.st-leer .dot { background: #9ca3af; }

.st-blau { background: #dbeafe; color: var(--st-blau); }
.st-gelb { background: #fef3c7; color: #92400e; }
.st-gruen { background: #dcfce7; color: #166534; }
.st-orange { background: #ffedd5; color: #9a3412; }
.st-rot { background: #fee2e2; color: #991b1b; }
.st-schwarz { background: #e5e7eb; color: var(--st-schwarz); }
.st-lila { background: #f3e8ff; color: #6b21a8; }

/* ===== Status-Wechsel-Menue ===== */
.status-menu {
  position: fixed; background: white;
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 6px; z-index: 100; min-width: 240px;
}
.status-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 5px; cursor: pointer; font-size: 13px;
}
.status-menu-item:hover { background: var(--bg); }
.status-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.status-menu-comment {
  padding: 8px 10px; border-top: 1px solid var(--border); margin-top: 4px;
}
.status-menu-comment input {
  width: 100%; border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 8px; font: inherit; font-size: 12px;
}

/* ===== Detail ===== */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.detail-col { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  overflow: hidden;
}
.card-h {
  padding: 10px 16px; background: #fafbfc;
  border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-mut); font-weight: 600;
}
.card-b { padding: 16px; }
.card-form { padding: 16px; background: white; border: 1px solid var(--border); border-radius: 8px; }

.row-form {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px;
  margin-bottom: 12px;
}
.row-form select, .row-form input {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 5px; font: inherit; font-size: 13px;
}

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.meta { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.meta dt { color: var(--text-mut); }
.meta dd { margin: 0; }

.muted { color: var(--text-mut); font-size: 12px; }

.history, .comments { list-style: none; padding: 0; margin: 0; }
.history li, .comments li {
  padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px;
}
.history li:last-child, .comments li:last-child { border-bottom: none; }
.history code {
  background: var(--bg); padding: 1px 5px; border-radius: 3px;
  font-size: 11px; color: var(--text);
}

/* GL-Decision Banner – Outcome-spezifisch */
.gl-banner {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}
.gl-banner-pending { background: #fef3c7; color: #78350f; border-color: #f59e0b; border-left-color: #d97706;
  display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.gl-banner-freigegeben { background: #dcfce7; color: #166534; border-color: #22c55e; border-left-color: #16a34a; }
.gl-banner-abgelehnt   { background: #fee2e2; color: #991b1b; border-color: #ef4444; border-left-color: #dc2626; }
.gl-banner-verschoben  { background: #ffedd5; color: #9a3412; border-color: #f97316; border-left-color: #ea580c; }
.gl-banner-info        { background: #dbeafe; color: #1e40af; border-color: #3b82f6; border-left-color: #2563eb; }
.gl-banner-erledigt    { background: #ecfdf5; color: #065f46; border-color: #10b981; border-left-color: #059669; }

/* Verlauf-Filter */
.hist-filter { display: flex; gap: 4px; }
.hist-btn { font-size: 10px; padding: 3px 8px; }
.hist-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.hist-item.hist-gl {
  background: #ecfeff; border-left: 3px solid #06b6d4;
  padding-left: 8px; margin-left: -8px;
}
.hist-item.hist-override {
  background: #fee2e2 !important; border-left: 3px solid #dc2626 !important;
  padding-left: 8px; margin-left: -8px;
  font-weight: 500;
}
.hist-item.hist-override .muted { color: #991b1b; }

/* ===== Sidebar einklappbar (V0.0.38+) ===== */
.layout.sidebar-collapsed { grid-template-columns: 56px 1fr; }
.layout.sidebar-collapsed .sidebar { width: 56px; overflow: hidden; }
.layout.sidebar-collapsed .brand-text,
.layout.sidebar-collapsed .nav-section,
.layout.sidebar-collapsed .nav-item span:not(.nav-icon):not(.badge-soon):not(.count),
.layout.sidebar-collapsed .nav-item .count,
.layout.sidebar-collapsed .user-block .uname,
.layout.sidebar-collapsed .user-block .urole,
.layout.sidebar-collapsed .user-block form { display: none; }
.layout.sidebar-collapsed .nav-item {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 4px; font-size: 18px;
  white-space: nowrap; overflow: hidden;
}

.layout.sidebar-collapsed .user-block { padding: 4px; text-align: center; }
.sidebar-toggle {
  background: transparent; border: none; color: var(--sidebar-text);
  cursor: pointer; padding: 0; font-size: 24px; line-height: 1;
  border-radius: 4px; transition: background 0.15s;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: #334155; color: white; }
.brand-with-bell { display: flex; align-items: center; gap: 8px; }
.brand-text { flex: 1; min-width: 0; }
.layout.sidebar-collapsed .brand-with-bell { gap: 0; padding: 8px 4px; }

/* ===== Matrix-Tabelle (admin_report_areas) ===== */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 220px); position: relative; border: 1px solid #e5e7eb; border-radius: 6px; background: white; }
.matrix-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.matrix-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f3f4f6; border-bottom: 2px solid #d1d5db;
  padding: 8px 6px; text-align: center; min-width: 90px;
  font-size: 11px; font-weight: 600;
}
.matrix-table thead th:first-child, .matrix-table tbody td:first-child {
  position: sticky; left: 0; z-index: 1; background: white;
  text-align: left; min-width: 220px; max-width: 280px;
}
.matrix-table thead th:first-child { z-index: 3; background: #f3f4f6; }
.matrix-table tbody td { padding: 5px 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.matrix-table tbody tr:nth-child(even) td { background: #fafbfc; }
.matrix-table tbody tr:nth-child(even) td:first-child { background: #f3f4f6; }
.matrix-table thead th:nth-child(even),
.matrix-table tbody td:nth-child(even) { background: #f9fafb; }
.matrix-table tbody tr:nth-child(even) td:nth-child(even) { background: #f3f4f6; }
.matrix-table tbody tr:hover td { background: #e0f2fe !important; }
.matrix-table tbody tr:hover td:first-child { background: #bae6fd !important; }
.matrix-cell-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; min-height: 32px; border-radius: 16px;
  border: 1px solid transparent; cursor: pointer; font-size: 14px;
  transition: transform 0.1s;
}
.matrix-cell-btn:hover { transform: scale(1.15); }
.matrix-cell-btn.on  { background: #0a7d2f; color: white; }
.matrix-cell-btn.off { background: #f5f5f5; color: #999; }


/* ===== Tickets-Highlight (V0.0.39) ===== */
.notif-tickets-title {
  border-left: 4px solid #ff8c00;
  padding-left: 8px;
  background: #fff7ed;
}
.notif-ticket {
  border-left: 4px solid #ff8c00;
}
.notif-ticket.aging-gelb   { border-left-color: #facc15; background: #fefce8; }
.notif-ticket.aging-orange { border-left-color: #fb923c; background: #fff7ed; }
.notif-ticket.aging-rot    { border-left-color: #ef4444; background: #fef2f2; }

.tag-aged { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; background: #fff7ed; color: #b45309; }
.tag-aged-gelb   { background: #fef9c3; color: #854d0e; }
.tag-aged-orange { background: #fed7aa; color: #9a3412; }
.tag-aged-rot    { background: #fecaca; color: #991b1b; }

/* Bell-Badge mit Aging-Hinweis (pulsiert rot wenn Tickets warten) */
.notif-bell-badge.has-aged {
  background: #ef4444 !important;
  animation: notif-pulse 1.8s ease-in-out infinite;
}
@keyframes notif-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); }
  50%     { box-shadow: 0 0 0 6px rgba(239,68,68,0);  }
}

/* Tickets-Inbox: Aging-Badge in der Zeile */
.ticket-aging { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; margin-left: 6px; }
.ticket-aging.aging-gelb   { background: #fef9c3; color: #854d0e; }
.ticket-aging.aging-orange { background: #fed7aa; color: #9a3412; }
.ticket-aging.aging-rot    { background: #fecaca; color: #991b1b; }

/* Ticket-Zeile mit Ticket-Border (in Tickets-Inbox + ggf. allgemeinen Listen) */
tr.is-ticket td:first-child { border-left: 4px solid #ff8c00; }
tr.is-ticket.aging-gelb   td:first-child { border-left-color: #facc15; }
tr.is-ticket.aging-orange td:first-child { border-left-color: #fb923c; }
tr.is-ticket.aging-rot    td:first-child { border-left-color: #ef4444; }

/* ===== Sidebar-Sektionen einklappbar (V0.0.41+) ===== */
.nav-section-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: 0;
  color: #94a3b8;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: 10px 14px 4px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.nav-section-toggle:hover { color: white; }
.nav-section-toggle .ns-chevron {
  font-size: 11px;
  color: #64748b;
  transition: transform 0.15s;
}
.nav-section-toggle:hover .ns-chevron { color: white; }
.nav-section-body { display: flex; flex-direction: column; gap: 0; }
.nav-section-body.collapsed { display: none; }
.layout.sidebar-collapsed .nav-section-toggle { display: none; }
