/* ── Adminportal – Optik angelehnt an den Manager (manager/header.html,
   manager/sidebar.html) ─────────────────────────────────────────────────── */

:root {
  --adm-header-bg: #454b50;
  --adm-sidebar-bg: #495057;
  --adm-sidebar-hover: #3e444a;
  --adm-page-bg: #f4f5f7;
}

body {
  padding-top: 50px;
  background: var(--adm-page-bg);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.adm-header {
  background-color: var(--adm-header-bg);
  height: 50px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
}
.adm-header img {
  width: 40px;
  height: 40px;
  margin-right: 12px;
  object-fit: contain;
}
.adm-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
}
.modal { z-index: 1150; }
.modal-backdrop { z-index: 1140; }

.adm-loading-bar {
  position: fixed;
  top: 50px;
  left: 0;
  height: 3px;
  width: 0;
  background: #0d6efd;
  z-index: 1101;
  opacity: 0;
  transition: width 0.4s ease, opacity 0.3s;
}
.adm-loading-bar.active { width: 70%; opacity: 1; }
.adm-loading-bar.done { width: 100%; opacity: 0; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.adm-sidebar {
  position: fixed;
  top: 50px;
  bottom: 0;
  left: 0;
  width: 250px;
  background-color: var(--adm-sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  transition: width 0.3s;
  z-index: 1000;
}
.adm-sidebar.collapsed { width: 70px; }
.adm-sidebar .nav-items {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.adm-sidebar .nav-link {
  color: #fff;
  display: flex;
  align-items: center;
  padding: 10px 20px;
  min-height: 44px;
  white-space: nowrap;
  transition: background-color 0.2s;
}
.adm-sidebar .nav-link i {
  font-size: 1.2rem;
  margin-right: 10px;
}
.adm-sidebar .nav-link:hover { background-color: var(--adm-sidebar-hover); }
.adm-sidebar .nav-link.active { background-color: var(--adm-header-bg); }
.adm-sidebar.collapsed .nav-link span { display: none; }
.adm-sidebar .toggle-btn { padding: 10px 20px; }

.content {
  margin-left: 250px;
  padding: 16px 20px 24px 16px;
  transition: margin-left 0.3s;
  min-width: 0;
}
body.sidebar-collapsed .content { margin-left: 70px; }

@media (max-width: 768px) {
  .adm-sidebar { width: 70px; }
  .adm-sidebar .nav-link span { display: none; }
  .content { margin-left: 70px; }
  .adm-title { font-size: 1.25rem; }
}

/* ── Allgemeine Seitenbausteine ─────────────────────────────────────────── */
.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.adm-card {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 16px;
}
.adm-card h6 {
  font-weight: 600;
  margin-bottom: 12px;
}
.under-construction {
  background: #fff;
  border: 2px dashed #ced4da;
  border-radius: 8px;
  padding: 48px 16px;
  text-align: center;
  color: #6c757d;
}
.under-construction i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

/* Dashboard-Kacheln */
.tile {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 10px;
  padding: 20px;
  height: 100%;
}
.tile .tile-label {
  color: #6c757d;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tile .tile-value {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tile .tile-sub { color: #6c757d; font-size: 0.9rem; }

/* Status-Kacheln (Server -> Dashboard): farbiger linker Rand je Zustand,
   Probleme zusaetzlich mit getoentem Hintergrund, damit sie sofort auffallen. */
.status-tile {
  display: block;
  background: #fff;
  border: 1px solid #dee2e6;
  border-left: 6px solid #adb5bd;
  border-radius: 8px;
  padding: 12px 14px;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.status-tile:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); color: inherit; }
.status-tile .st-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: #6c757d; }
.status-tile .st-value { font-size: 1.35rem; font-weight: 700; line-height: 1.25; word-break: break-word; }
.status-tile .st-sub { font-size: 0.82rem; color: #6c757d; word-break: break-word; }
.status-tile.lvl-ok { border-left-color: #198754; }
.status-tile.lvl-info { border-left-color: #0d6efd; }
.status-tile.lvl-warning { border-left-color: #ffc107; background: #fffbea; }
.status-tile.lvl-error { border-left-color: #dc3545; background: #fff1f2; }
.status-tile.lvl-error .st-value { color: #b02a37; }
.status-tile .st-icon { float: right; font-size: 1.3rem; opacity: 0.5; }
.status-tile .progress { height: 8px; margin-top: 6px; }

/* Tabellen */
.adm-table-wrap {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: auto;
}
.adm-table { margin-bottom: 0; font-size: 0.92rem; }
.adm-table thead th {
  background: #f8f9fa;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  vertical-align: middle;
}
.adm-table th.sortable { cursor: pointer; user-select: none; }
.adm-table th.sortable:hover { background: #eef0f2; }
.adm-table th .sort-ind { opacity: 0.4; font-size: 0.75rem; margin-left: 4px; }
.adm-table th.sorted .sort-ind { opacity: 1; }
.adm-table td { vertical-align: middle; }
.adm-table tbody tr.clickable { cursor: pointer; }
.adm-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm-table .center { text-align: center; }
.th-rot {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  max-height: 160px;
  font-weight: 600;
}

/* Backup-Liste im Account: .adm-table-wrap schneidet wegen overflow:auto
   alles ab, was ueber den Kasten hinausragt - bei nur einem Backup war das
   Aktionen-Dropdown dadurch nicht vollstaendig sichtbar. Mindesthoehe so
   gewaehlt, dass das Dropdown (6 Eintraege) unter der ersten Zeile ganz
   hineinpasst. */
.backup-table-wrap { min-height: 360px; }

.prod-yes { color: #198754; font-size: 1.1rem; }
.prod-no { color: #adb5bd; font-size: 1rem; }
.prod-test {
  background: #ffc107;
  color: #212529;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
}

/* Paket-Matrix */
.matrix-table td, .matrix-table th { min-width: 150px; }
.matrix-table td:first-child, .matrix-table th:first-child {
  position: sticky;
  left: 0;
  background: #f8f9fa;
  z-index: 2;
  min-width: 200px;
  font-weight: 500;
}
.matrix-table tr.section-row td {
  background: #e9ecef !important;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.matrix-table .form-check-input { width: 1.3em; height: 1.3em; cursor: pointer; }

/* ── Accountdetails ─────────────────────────────────────────────────────── */
.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.account-head h2 { font-size: 1.6rem; font-weight: 700; margin: 0; }
.account-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1200px) {
  .account-layout { grid-template-columns: minmax(0, 1fr); }
}
.account-main .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.account-main .nav-tabs .nav-link { white-space: nowrap; }
.account-main .tab-body {
  background: #fff;
  border: 1px solid #dee2e6;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: 16px;
}

/* Chat / Historie */
.chat-panel {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  /* Schlanker: hoechstens 520 px statt der vollen Fensterhoehe */
  height: min(520px, calc(100vh - 130px));
  position: sticky;
  top: 66px;
}
.chat-panel .chat-head {
  padding: 6px 12px;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
  font-size: 0.9rem;
}
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fafbfc;
}
.chat-msg {
  background: #e7f1ff;
  border-radius: 8px 8px 8px 2px;
  padding: 4px 8px;
  max-width: 92%;
  align-self: flex-start;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.3;
}
.chat-msg.system {
  background: #f1f3f5;
  color: #495057;
  align-self: stretch;
  max-width: none;
  border-radius: 4px;
  font-size: 0.78rem;
}
.chat-msg.ticket { background: #fff3cd; }
.chat-meta { font-size: 0.68rem; color: #6c757d; margin-bottom: 0; }
.chat-input { border-top: 1px solid #dee2e6; padding: 6px 8px; }
.chat-input textarea { font-size: 0.82rem; }
@media (max-width: 1200px) {
  .chat-panel { height: 380px; position: static; }
}

/* Produktverwaltung im Account */
.product-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f3f5;
  flex-wrap: wrap;
}
.product-row .p-name { flex: 1 1 160px; min-width: 0; }
.product-row .form-select { width: auto; min-width: 140px; }
.price-box .price-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.price-box .price-total {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dirty-hint { color: #b35c00; font-size: 0.85rem; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  padding-top: 0;
  background: #2b2f33;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: min(92vw, 420px);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.35);
  padding: 28px;
}
.login-card img { width: 110px; height: auto; display: block; margin: 0 auto 10px; }
.login-card .login-title {
  text-align: center;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

/* ── Tickets (pages/tickets.js) ─────────────────────────────────────────── */
.adm-sidebar .nav-link .nav-badge {
  margin-left: auto;
  background: #dc3545;
  color: #fff;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
}
.adm-sidebar .nav-link .nav-badge + .nav-badge { margin-left: 4px; }
.adm-sidebar .nav-link .nav-badge.nb-open { background: #0d6efd; }
.adm-sidebar.collapsed .nav-link { position: relative; }
.adm-sidebar.collapsed .nav-link .nav-badge {
  display: inline-block !important;
  position: absolute;
  top: 4px;
  right: 8px;
  padding: 0 5px;
}
/* Eingeklappt nur ein Zaehler: rot, wenn es neue Tickets gibt, sonst blau. */
.adm-sidebar.collapsed .nav-link .nav-badge[style*="display: none"] { display: none !important; }
.adm-sidebar.collapsed .nav-link.has-new .nav-badge.nb-open { display: none !important; }
.tk-dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 0.9rem; }
.tk-dl dt { color: #6c757d; font-weight: 500; }
.tk-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.tk-shot { max-width: 100%; border: 1px solid #dee2e6; border-radius: 6px; cursor: zoom-in; }
.col-lg-8 > .tab-content > .tab-body {
  background: #fff;
  border: 1px solid #dee2e6;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: 16px;
}
.tk-conv { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.tk-msg { max-width: 88%; border-radius: 10px; padding: 8px 12px; background: #f1f3f5; border: 1px solid #e3e6e9; align-self: flex-start; }
.tk-msg.out { align-self: flex-end; background: #e7f1ff; border-color: #cfe2ff; }
.tk-msg.created { background: #fff8e6; border-color: #ffe7a3; max-width: 100%; }
.tk-meta { font-size: 0.78rem; color: #6c757d; margin-bottom: 2px; }
.tk-subject { font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; }
.tk-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.tk-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tk-file { font-size: 0.8rem; background: #fff; border: 1px solid #dee2e6; border-radius: 6px; padding: 2px 8px; text-decoration: none; }
.tk-reply { border-top: 1px solid #dee2e6; padding-top: 12px; }
.tk-jentry { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f3f5; }
.tk-jicon { width: 28px; height: 28px; border-radius: 50%; background: #f1f3f5; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #495057; }
.tk-jentry.note .tk-jicon { background: #fff3cd; }
.tk-jentry.status .tk-jicon { background: #cfe2ff; }
.tk-jentry.mail_in .tk-jicon { background: #d1e7dd; }
.min-w-0 { min-width: 0; }
