/* GLOBAL STYLES */
:root {
  --vitus-blau: rgb(155, 184, 192);
  --vitus-blau-hover: rgb(112, 151, 152);
  --vitus-grau: #e0e1de;

  --bg-page: var(--vitus-grau);
  --bg-surface: #ffffff;
  --bg-surface-muted: #f8f9fa;
  --bg-surface-alt: #f7f7f7;
  --text-primary: #1f2933;
  --border-subtle: #dee2e6;
  --border-input: #ced4da;
  --border-strong: #ddd;
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-elevated: 0 2px 8px rgba(0, 0, 0, 0.1);
  --focus-ring: 0 0 0 3px rgba(155, 184, 192, 0.15);
  --dropdown-bg: var(--vitus-blau);
  --dropdown-bg-hover: var(--vitus-blau-hover);
}

html[data-theme="dark"] {
  --bg-page: #111827;
  --bg-surface: #1f2937;
  --bg-surface-muted: #283549;
  --bg-surface-alt: #31405a;
  --text-primary: #e5e7eb;
  --border-subtle: #3d4d63;
  --border-input: #4b5d75;
  --border-strong: #4b5d75;
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-elevated: 0 2px 8px rgba(0, 0, 0, 0.4);
  --focus-ring: 0 0 0 3px rgba(155, 184, 192, 0.25);
  --dropdown-bg: #243246;
  --dropdown-bg-hover: #1c2a3d;
}

body {
  font-family: Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  overflow-x: hidden;
}

a {
  color: var(--vitus-blau);
  text-decoration: none;
}

a:hover {
  color: var(--vitus-blau-hover);
}

/* HEADER */
header {
  background: var(--vitus-blau-hover);
  color: #fff;
  padding: 15px 30px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.user-icon {
  font-size: 1.1em;
  color: #fff;
  filter: brightness(0) invert(1);
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--dropdown-bg);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.user-info:hover .user-dropdown {
  opacity: 1;
  visibility: visible;
}

.user-dropdown a {
  display: block;
  padding: 10px 20px;
  color: white;
  text-decoration: none;
  white-space: nowrap;
}

.user-dropdown a:hover {
  background: var(--dropdown-bg-hover);
  color: white;
}

/* NAVIGATION */
.nav-left a {
  position: relative;
  color: #fff;
  margin-right: 20px;
  text-decoration: none;
}

.nav-left a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease-in-out;
}

.nav-left a:hover::after {
  transform: scaleX(1);
}

/* CONTAINER und CARDS */
.container {
  padding: 30px;
}

.card {
  background: var(--bg-surface);
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
}

.card h2,
.card h3 {
  margin-top: 0;
}

/* CARD HEADER WITH ACTION BUTTON */
.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: nowrap;
  margin-bottom: 12px;
}

.card-header-flex h2 {
  margin: 0;
  flex: 1;
}

.card-header-flex .btn {
  margin-left: auto;
  white-space: nowrap;
}

/* BUTTONS */
.btn {
  position: relative;
  display: inline-block;
  padding: 10px 36px;
  background: var(--vitus-blau);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: white;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s ease;
}

.btn:hover {
  background: var(--vitus-blau-hover);
  color: white;
}

/* DATATABLES */
table.dataTable {
  background: var(--bg-surface);
  border-collapse: collapse;
  width: 100%;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll .dataTables_wrapper {
  width: 100%;
  max-width: 100%;
}

.table-scroll table.dataTable {
  min-width: 760px;
}

table.dataTable thead th,
table.dataTable tbody td {
  color: var(--text-primary);
  border-color: var(--border-subtle) !important;
}

.history-maxwidth-col {
  max-width: 20vw;
  overflow-x: auto;
}

.history-nobreak-col {
  white-space: nowrap;
}

/* History row tints */
table.dataTable tbody tr.row-event-service td {
  background-color: rgba(230, 160, 40, 0.10) !important;
}
table.dataTable tbody tr.row-event-created td {
  background-color: rgba(46, 160, 100, 0.10) !important;
}
table.dataTable tbody tr.row-event-shipment td {
  background-color: rgba(80, 140, 200, 0.10) !important;
}
table.dataTable tbody tr.row-event-problem td {
  background-color: rgba(210, 60, 50, 0.10) !important;
}
table.dataTable tbody tr.row-event-resolved td {
  background-color: rgba(46, 160, 100, 0.08) !important;
}

html[data-theme="dark"] table.dataTable tbody tr.row-event-service td {
  background-color: rgba(230, 160, 40, 0.14) !important;
}
html[data-theme="dark"] table.dataTable tbody tr.row-event-created td {
  background-color: rgba(46, 160, 100, 0.14) !important;
}
html[data-theme="dark"] table.dataTable tbody tr.row-event-shipment td {
  background-color: rgba(80, 140, 200, 0.14) !important;
}
html[data-theme="dark"] table.dataTable tbody tr.row-event-problem td {
  background-color: rgba(210, 60, 50, 0.14) !important;
}
html[data-theme="dark"] table.dataTable tbody tr.row-event-resolved td {
  background-color: rgba(46, 160, 100, 0.12) !important;
}

.dt-center {
  text-align: center;
  vertical-align: middle;
}

.dt-button.btn-danger {
  background: #c0392b !important;
  color: #fff !important;
  border-radius: 4px !important;
}

.dt-button.btn-danger:hover {
  background: #e74c3c !important;
}

/* LOGIN */
.login-box {
  width: 360px;
  margin: 120px auto;
  background: var(--bg-surface);
  padding: 30px;
  border-radius: 6px;
  box-shadow: var(--shadow-elevated);
  text-align: center;
}

.login-box input {
  width: -webkit-fill-available;
}

/* FORMS */
input,
select,
textarea {
  padding: 8px 14px;
  border: 1px solid var(--border-input);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

html[data-theme="dark"] select {
  color-scheme: dark;
}

html[data-theme="dark"] option,
html[data-theme="dark"] optgroup {
  background-color: var(--bg-surface-muted);
  color: var(--text-primary);
}

/* STATUS INDICATORS */
.status {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.green {
  background: #2ecc71;
}

.yellow {
  background: #f1c40f;
}

.red {
  background: #e74c3c;
}

/* ANALYTICS */
.analytics-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.analytics-tabs .btn[disabled] {
  background: var(--vitus-blau-hover);
  cursor: default;
}

.analytics-panel {
  display: none;
}

.analytics-panel.analytics-panel-visible {
  display: block;
}

/* CARD HEADER & ACTIONS */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.card-summary {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-width: 0;
}

.summary-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-right: 16px;
  min-width: 0;
}

.summary-label {
  font-weight: 700;
  white-space: nowrap;
}

.summary-value {
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* INFO BOX */
.info-box {
  background: var(--bg-surface-muted);
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  border-left: 4px solid var(--vitus-blau);
}

.info-box strong {
  color: var(--vitus-blau-hover);
  font-size: 1.1em;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status-badge-ok {
  background: rgba(46, 204, 113, 0.12);
  color: #239b56;
}

.status-badge-danger {
  background: rgba(231, 76, 60, 0.12);
  color: #c0392b;
}

/* FORM SECTIONS */
.form-section {
  margin-bottom: 20px;
}

.form-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-section input,
.form-section select,
.form-section textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 1em;
  box-sizing: border-box;
}

.form-section input:focus,
.form-section select:focus,
.form-section textarea:focus,
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  outline: none;
  border-color: var(--vitus-blau) !important;
  box-shadow: var(--focus-ring);
}

/* CHECKBOX GRID */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  padding: 16px;
  background: var(--bg-surface-muted);
  border-radius: 6px;
  margin-top: 8px;
}

.checkbox-card {
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 44px;
  box-sizing: border-box;
  margin-bottom: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox-card:hover {
  border-color: var(--vitus-blau);
  background: var(--bg-surface-alt);
}

.checkbox-card input[type="checkbox"] {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto;
  justify-self: center;
  cursor: pointer;
}

.checkbox-card span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.3;
  text-align: center;
}

.checkbox-card input[type="checkbox"]:checked ~ span {
  color: var(--vitus-blau-hover);
}

/* FORM ACTIONS */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  color: var(--text-primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  color: var(--text-primary) !important;
}

.form-actions .btn {
  margin: 0;
}

.btn.btn-secondary {
  background: #6c757d;
}

.btn.btn-secondary:hover {
  background: #5a6268;
}

@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .card {
    padding: 12px;
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 10px;
  }

  .nav-left {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .nav-left a {
    margin-right: 0;
  }

  .card-header-flex {
    flex-wrap: wrap;
  }

  .btn {
    padding: 10px 16px;
  }

  .device-checkbox,
  #select-all {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 480px) {
  header {
    position: static;
  }
}
