/* barox Support — App-Shell und Ticket-UI, aufbauend auf den Tokens aus
   /assets/design-system/barox-design-system.css (immer zuerst einbinden). */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy);
  color: var(--navy-20);
  display: flex;
  flex-direction: column;
}
.app-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.app-sidebar .brand-logo { height: 28px; width: auto; }
.app-nav { list-style: none; margin: 0; padding: 14px 0; flex: 1; }
.app-nav a {
  display: block;
  padding: 10px 20px;
  color: var(--navy-20);
  text-decoration: none;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.app-nav a:hover { color: var(--white); background: rgba(255, 255, 255, 0.06); }
.app-nav a.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--amber);
}
.app-sidebar .user-box {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.9rem;
}
.app-sidebar .user-box form { margin-top: 6px; }
.app-sidebar .user-box button {
  background: none;
  border: none;
  color: var(--navy-20);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.85rem;
}
.app-sidebar .user-box button:hover { color: var(--amber); }

.app-main { flex: 1; min-width: 0; }
.app-topbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-content { padding: 28px; }

/* ---------------------------- Login-Seite --------------------------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image: linear-gradient(160deg, var(--navy) 0%, #001a30 100%);
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hover);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card .brand-logo { height: 40px; margin-bottom: 18px; }

/* ------------------------------- Tabellen ------------------------------ */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.table th {
  background: var(--navy-10);
  color: var(--navy);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}
.table tbody tr:hover { background: var(--bg); }
.table a { text-decoration: none; font-weight: 500; }

/* -------------------------------- Badges -------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status-new { background: var(--navy-10); color: var(--navy); }
.badge-status-open { background: #e6f0ff; color: #0b4fa3; }
.badge-status-pending_customer { background: #fff4dd; color: var(--amber-dark); }
.badge-status-resolved { background: #e8f3e9; color: var(--success); }
.badge-status-closed { background: var(--line); color: var(--grey); }

.badge-priority-low { background: var(--line); color: var(--grey); }
.badge-priority-normal { background: var(--navy-10); color: var(--navy); }
.badge-priority-high { background: #fff4dd; color: var(--amber-dark); }
.badge-priority-urgent { background: #fdecea; color: var(--error); }

/* -------------------------------- Formulare ------------------------------ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-text);
  font-size: 0.95rem;
  background: var(--white);
  color: var(--ink);
}
.form-control:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-10); }
textarea.form-control { min-height: 140px; resize: vertical; }

/* ------------------------------ Nachrichten ------------------------------ */
.message {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 14px;
  border-left: 4px solid var(--navy-20);
}
.message.message-inbound { border-left-color: var(--navy); }
.message.message-outbound { border-left-color: var(--amber); }
.message.message-internal_note { border-left-color: var(--warning); background: #fffdf5; }
.message-meta { font-size: 0.82rem; color: var(--grey); margin-bottom: 8px; }
.message-body-plain { white-space: pre-wrap; }
.message-body p { margin: 0 0 10px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body ul, .message-body ol { margin: 8px 0; padding-left: 22px; }
.message-body a { color: var(--navy); }
.message-actions { margin-top: 8px; }

/* -------------------------------- Editor ---------------------------------- */
.editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.editor-toolbar button {
  background: none;
  border: none;
  border-radius: 4px;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  font-size: 0.9rem;
  color: var(--navy);
  cursor: pointer;
}
.editor-toolbar button:hover { background: var(--navy-10); }
.editor-toolbar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.editor-content {
  min-height: 140px;
  max-height: 420px;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: var(--font-text);
  font-size: 0.95rem;
  color: var(--ink);
}
.editor-content:focus { outline: none; }
.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--grey);
}
.editor-content p { margin: 0 0 10px; }
.editor-content ul, .editor-content ol { margin: 8px 0; padding-left: 22px; }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--navy);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}
.btn-link:hover { color: var(--navy-70, var(--navy)); }
.btn-link:disabled { color: var(--navy-40); cursor: default; }

/* ------------------------------ Paginierung ------------------------------ */
.pagination {
  display: flex;
  list-style: none;
  gap: 4px;
  margin: 0;
  padding: 0;
}
.pagination li a,
.pagination li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--line);
}
.pagination li a:hover { background: var(--navy-10); }
.pagination li.disabled span { color: var(--navy-40); background: var(--bg); }
.pagination li.active span { background: var(--navy); color: var(--white); border-color: var(--navy); }

.badge-tag {
  background: var(--navy-10);
  color: var(--navy);
  margin-right: 4px;
  margin-bottom: 4px;
}

.btn-link-danger {
  background: none;
  border: none;
  padding: 0;
  color: var(--error);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.btn-link-danger:hover { color: #7a1710; }

/* ------------------------------ Config-Button ------------------------------ */
.config-menu-trigger {
  flex-shrink: 0;
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 1.05rem;
  color: var(--grey);
}
.config-menu-trigger:hover { background: var(--bg); color: var(--navy); }
.config-menu-trigger[aria-expanded="true"] { background: var(--navy-10); color: var(--navy); border-color: var(--navy-40); }

/* ---------------------------------- Modal ---------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 45, 78, 0.45);
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
}
/* [hidden] via HTML-Attribut steuert die Sichtbarkeit; ohne dieses Attribut
   (vom JS entfernt) wird die Overlay-Flexbox aktiv. Ohne diese Regel würde
   die obige display-Eigenschaft das hidden-Attribut immer überschreiben. */
.modal-overlay:not([hidden]) { display: flex; }
.modal-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hover);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  position: relative;
}
.modal-panel h3 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--grey);
  padding: 4px;
}
.modal-close:hover { color: var(--navy); }
.config-menu-section + .config-menu-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.config-menu-section h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--grey);
}

/* --------------------------- Sortierbare Header --------------------------- */
.table th a.sortable {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.table th a.sortable:hover { color: var(--amber-dark); }
.table th .sort-indicator { font-size: 0.7rem; }

/* ---------------------------- KI-Einstellungen ---------------------------- */
.ai-provider-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.ai-provider-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 12px;
}
.ai-provider-fields {
  padding-left: 26px;
  border-left: 2px solid var(--navy-10);
  margin-left: 4px;
}
