/* TicketSystem – Custom Styles (Light + Dark Mode) */

/* ── Allgemein ─────────────────────────────────────────── */
body {
  background-color: #f0f2f5;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

[data-bs-theme="dark"] body {
  background-color: #0f1117;
}

.container-fluid {
  flex: 1;
}

/* ── Auth-Seiten ─────────────────────────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
}

[data-bs-theme="dark"] .auth-body {
  background: linear-gradient(135deg, #1a1d23 0%, #0d1117 100%);
}

.auth-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 1rem;
}

.auth-card {
  border-radius: 1rem;
  overflow: hidden;
}

.auth-header {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  color: white;
}

[data-bs-theme="dark"] .auth-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #0d2137 100%);
}

.auth-header h3,
.auth-header p { color: white !important; }

/* ── Navbar ──────────────────────────────────────────────── */
.navbar {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%) !important;
  transition: background 0.2s ease;
}

[data-bs-theme="dark"] .navbar {
  background: linear-gradient(135deg, #1a2535 0%, #0d1520 100%) !important;
  border-bottom: 1px solid #2a3546;
}

.navbar-brand {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

/* ── Darkmode Toggle Button ──────────────────────────────── */
.btn-darkmode {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.9);
  border-radius: 2rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.btn-darkmode:hover {
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.7);
}

/* ── Statistik-Karten ──────────────────────────────────── */
.stat-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-radius: 0.75rem;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15) !important;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.85rem;
}

.stat-icon {
  flex-shrink: 0;
}

/* ── Karten ──────────────────────────────────────────────── */
.card {
  border-radius: 0.75rem;
  transition: background-color 0.2s ease;
}

.card-header {
  border-radius: 0.75rem 0.75rem 0 0 !important;
}

[data-bs-theme="dark"] .card {
  background-color: #161b27;
  border-color: #2a3546 !important;
}

[data-bs-theme="dark"] .card-header {
  background-color: #1a2133 !important;
  border-color: #2a3546 !important;
}

[data-bs-theme="dark"] .card-footer {
  background-color: #1a2133 !important;
  border-color: #2a3546 !important;
}

/* ── Hintergrundfarben im Dark Mode ──────────────────────── */
[data-bs-theme="dark"] .bg-light {
  background-color: #1a2133 !important;
}

[data-bs-theme="dark"] .table-light {
  --bs-table-bg: #1e2740;
  --bs-table-color: #c9d1d9;
}

[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: #1a2133;
  --bs-table-hover-bg: rgba(255,255,255,0.04);
  color: #c9d1d9;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: rgba(13, 110, 253, 0.08);
}

/* ── Inputs & Formulare ──────────────────────────────────── */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #1e2740;
  border-color: #2a3a54;
  color: #c9d1d9;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #1e2740;
  border-color: #0d6efd;
  color: #e6edf3;
  box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.25);
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: #5a6a82;
}

[data-bs-theme="dark"] .input-group-text {
  background-color: #1a2133;
  border-color: #2a3a54;
  color: #8b949e;
}

/* ── Dropdowns ───────────────────────────────────────────── */
[data-bs-theme="dark"] .dropdown-menu {
  background-color: #1a2133;
  border-color: #2a3546;
}

[data-bs-theme="dark"] .dropdown-item {
  color: #c9d1d9;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: #1e2a3d;
  color: #e6edf3;
}

[data-bs-theme="dark"] .dropdown-divider {
  border-color: #2a3546;
}

[data-bs-theme="dark"] .dropdown-header {
  color: #8b949e;
}

/* ── Alerts ──────────────────────────────────────────────── */
[data-bs-theme="dark"] .alert-success {
  background-color: #0d2818;
  border-color: #1a4731;
  color: #3fb950;
}

[data-bs-theme="dark"] .alert-danger {
  background-color: #2d0f0f;
  border-color: #5c1a1a;
  color: #f85149;
}

[data-bs-theme="dark"] .alert-warning {
  background-color: #2d1f00;
  border-color: #5c3d00;
  color: #e3b341;
}

[data-bs-theme="dark"] .alert-info {
  background-color: #0d2233;
  border-color: #1a4155;
  color: #58a6ff;
}

/* ── Tabellen ────────────────────────────────────────────── */
.table > :not(caption) > * > * {
  padding: 0.75rem 1rem;
}

/* ── Ticket-Ansicht ──────────────────────────────────────── */
.ticket-description {
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Kommentare ──────────────────────────────────────────── */
.comment-bubble {
  background: #f8f9fa;
  border-radius: 0.5rem 0.75rem 0.75rem 0.75rem;
  border: 1px solid #e9ecef;
}

[data-bs-theme="dark"] .comment-bubble {
  background: #1e2740;
  border-color: #2a3a54;
}

.comment-internal .comment-bubble {
  background: #fffde7;
  border-color: #ffc107;
}

[data-bs-theme="dark"] .comment-internal .comment-bubble {
  background: #2d2000;
  border-color: #5c3d00;
}

/* Zitat-Block in Kommentaren */
.comment-quote {
  border-left: 4px solid #0d6efd;
  background: rgba(13,110,253,.07);
  padding: .4rem .75rem;
  margin-bottom: .5rem;
  border-radius: 0 .4rem .4rem 0;
  color: #6c757d;
  font-size: .9em;
}
[data-bs-theme="dark"] .comment-quote {
  background: rgba(13,110,253,.13);
  border-color: #4d8ef7;
}

.comment-item {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Breadcrumb ──────────────────────────────────────────── */
[data-bs-theme="dark"] .breadcrumb-item a {
  color: #58a6ff;
}

[data-bs-theme="dark"] .breadcrumb-item.active {
  color: #8b949e;
}

/* ── List Groups ─────────────────────────────────────────── */
[data-bs-theme="dark"] .list-group-item {
  background-color: #161b27;
  border-color: #2a3546;
  color: #c9d1d9;
}

/* ── Nav Tabs ────────────────────────────────────────────── */
[data-bs-theme="dark"] .nav-tabs {
  border-color: #2a3546;
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
  color: #8b949e;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  background-color: #161b27;
  border-color: #2a3546 #2a3546 #161b27;
  color: #e6edf3;
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  font-size: 0.85rem;
}

[data-bs-theme="dark"] .footer {
  background-color: #161b27 !important;
  border-color: #2a3546 !important;
  color: #8b949e;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Passwort-Stärke ─────────────────────────────────────── */
.password-strength {
  height: 1.5rem;
}

/* ── Stat-Icon Farben im Dark Mode ───────────────────────── */
[data-bs-theme="dark"] .bg-primary-subtle {
  background-color: #0d2448 !important;
}

[data-bs-theme="dark"] .bg-success-subtle {
  background-color: #0d2818 !important;
}

[data-bs-theme="dark"] .bg-info-subtle {
  background-color: #0d2233 !important;
}

[data-bs-theme="dark"] .bg-danger-subtle {
  background-color: #2d0f0f !important;
}

[data-bs-theme="dark"] .bg-warning-subtle {
  background-color: #2d1f00 !important;
}

/* ── Text-Farben ─────────────────────────────────────────── */
[data-bs-theme="dark"] .text-dark {
  color: #e6edf3 !important;
}

[data-bs-theme="dark"] .text-muted {
  color: #8b949e !important;
}

/* ── Code-Elemente ───────────────────────────────────────── */
[data-bs-theme="dark"] code {
  color: #79c0ff;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

[data-bs-theme="dark"] ::-webkit-scrollbar-track { background: #1a2133; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4a60; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4a5a72; }

/* ── Übergangsanimation ──────────────────────────────────── */
*, *::before, *::after {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Transitions für Elemente die keine brauchen deaktivieren */
.badge, .btn, .progress-bar, canvas {
  transition: none !important;
}

/* ── Rollenfarben ───────────────────────────────────────── */
.role-badge-systemverwalter {
  color: #2b1a00 !important;
  background: linear-gradient(135deg, #fff3b0 0%, #ffd700 42%, #b8860b 100%) !important;
  border: 1px solid #b8860b;
  box-shadow: 0 0 0 .05rem rgba(184, 134, 11, .35), 0 .15rem .4rem rgba(0,0,0,.18);
  font-weight: 700;
}

[data-bs-theme="dark"] .role-badge-systemverwalter {
  color: #1f1400 !important;
  background: linear-gradient(135deg, #fff6bf 0%, #ffd700 45%, #c99612 100%) !important;
  border-color: #ffd700;
}

/* ─────────────────────────────────────────────────────────────────────────
   Utility-Klassen (extrahiert aus inline style="..." für bessere Wartung)
   ─────────────────────────────────────────────────────────────────────── */

/* Font-Sizes */
.fs-xxxs   { font-size: 0.65rem; }
.fs-xxs    { font-size: 0.70rem; }
.fs-xs     { font-size: 0.75rem; }
.fs-3rem   { font-size: 3rem; }

/* Fixed Widths */
.w-32      { width: 32px; }
.w-36      { width: 36px; }
.w-40      { width: 40px; }
.w-96      { width: 96px; }
.w-120     { width: 120px; }
.w-140     { width: 140px; }
.w-160     { width: 160px; }
.w-190     { width: 190px; }
.w-220     { width: 220px; }
.mw-200    { max-width: 200px; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Chart-Container (feste Höhe, responsive Breite) */
.chart-container       { position: relative; height: 240px; }
.chart-container-sm    { position: relative; height: 180px; }

/* Farb-Swatches: für dynamische Farben in PHP (style="--swatch: #..."). */
.color-swatch          { background: var(--swatch, transparent); }
.color-swatch-border   { border-color: var(--swatch, transparent); }

/* Progress-Bar: für dynamische Breite (style="--pct: 75%"). */
.progress-dynamic      { width: var(--pct, 0%); }

/* Toast-Container (war vorher inline-style) */
.toast-container-fixed {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
    pointer-events: none;
}

/* Login-Card Suchfeld (war: --bs-bg-opacity:.15) */
.search-glass-bg       { --bs-bg-opacity: 0.15; }

/* ── iOS PWA Safe-Area: Notch / Statusbar / Home-Indicator ─────────────── */
/* Problem: Mit apple-mobile-web-app-status-bar-style="black-translucent"
   wird die iOS-Statusbar transparent über den Inhalt gelegt. Ohne Padding
   läuft der Navbar-Inhalt unter Uhrzeit/Akku-Symbole. */
@supports (padding: max(0px)) {
  /* Body-Background bis in die Safe-Area, damit Statusbar nicht weiß bleibt */
  html, body {
    background-color: var(--bs-body-bg, #fff);
  }

  /* Bootstrap-Navbar: oben in die Safe-Area hineinpaddeln. Da .navbar einen
     farbigen Gradient-Background hat, färbt sie automatisch bis zur Display-
     Oberkante – kein leerer weißer Streifen. */
  .navbar {
    padding-top:    max(0.5rem, env(safe-area-inset-top));
    padding-left:   max(1rem,   env(safe-area-inset-left));
    padding-right:  max(1rem,   env(safe-area-inset-right));
  }

  /* Auth-Seiten ohne Navbar (login, register, forgot/reset password):
     .auth-body soll seitliche Notches / Statusbar / Home-Indicator
     respektieren, damit das Login-Card nicht unter Systemleisten rutscht. */
  .auth-body {
    padding-top:    env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left:   env(safe-area-inset-left);
    padding-right:  env(safe-area-inset-right);
    box-sizing: border-box;
  }

  /* Im PWA-Standalone-Modus (vom Homescreen gestartet): zusätzlich unten
     Padding für den iOS Home-Indicator-Balken. */
  @media (display-mode: standalone) {
    body {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}

/* ── Support-Chat (Konsole und Kunden-Fenster) ─────────────────────────────── */
.chat-list-title { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--bs-secondary-color); padding: .3rem .5rem; }
.chat-list-item { padding: .45rem .6rem; }
.chat-main { min-height: 62vh; }
.chat-tab-close { font-size: .6rem; }
.chat-messages { height: 52vh; overflow-y: auto; padding: 1rem; background: var(--bs-tertiary-bg); }
.chat-msg { max-width: 82%; margin-bottom: .6rem; }
.chat-msg-meta { font-size: .72rem; color: var(--bs-secondary-color); margin-bottom: .15rem; }
.chat-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; padding: .45rem .7rem; border-radius: .7rem; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); }
.chat-msg-own { margin-left: auto; }
.chat-msg-own .chat-msg-meta { text-align: right; }
.chat-msg-own .chat-msg-text { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
.chat-msg-note .chat-msg-text { background: var(--bs-warning-bg-subtle); border-color: var(--bs-warning-border-subtle); color: var(--bs-body-color); }
.chat-msg-system { max-width: 100%; text-align: center; }
.chat-msg-system .chat-msg-text { display: inline-block; background: transparent; border: 0; padding: 0; font-size: .78rem; color: var(--bs-secondary-color); }
.chat-kb-results { max-height: 12rem; overflow-y: auto; }

/* Kunden-Chatfenster */
.chat-widget { position: fixed; right: 1rem; bottom: 1rem; z-index: 1070; }
.chat-widget-panel { width: 370px; max-width: calc(100vw - 2rem); height: 560px; max-height: calc(100vh - 6rem); display: flex; flex-direction: column; }
.chat-widget-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.chat-widget-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.chat-widget-messages { flex: 1 1 auto; height: auto; min-height: 8rem; }
.chat-widget-inline { position: static; }
.chat-widget-inline .chat-widget-panel { width: 100%; max-width: 100%; height: 70vh; max-height: none; }
.chat-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 576px) {
  .chat-widget:not(.chat-widget-inline) { right: .5rem; left: .5rem; bottom: .5rem; text-align: right; }
  .chat-widget:not(.chat-widget-inline) .chat-widget-panel { width: 100%; max-width: 100%; text-align: left; }
}

/* ── Lange Klappmenüs in der Kopfzeile ────────────────────────────────────── */
/* Das Verwaltungsmenü hat je nach Rechten bis zu 19 Einträge und war damit höher
   als der Bildschirm. Bootstrap lässt Klappmenüs nicht von sich aus scrollen –
   man musste also die Seite scrollen, und die bewegte sich unter dem Menü weg.
   max-height gibt dem Menü eine eigene Bildlaufleiste, overscroll-behavior
   verhindert, dass die Bewegung an den Seitenhintergrund weitergereicht wird,
   sobald das Menü oben oder unten angekommen ist. */
.navbar .dropdown-menu {
    max-height: calc(100vh - 4.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Auf schmalen Bildschirmen klappt die ganze Navigation auf; auch sie bekommt
   eine eigene Bildlaufleiste, statt die Seite in die Länge zu ziehen. */
@media (max-width: 991.98px) {
    .navbar-collapse {
        max-height: calc(100vh - 4.5rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    /* Im aufgeklappten Zustand bringt das innere Menü keine zweite Leiste mehr mit. */
    .navbar-collapse .dropdown-menu {
        max-height: none;
        overflow-y: visible;
    }
}
