/* Octa – Oberfläche im Windows-10-Stil:
   klare rechteckige Flächen, dezente Schatten, zurückhaltende Farben. */

:root {
  --accent: #0078d7;
  --accent-dark: #106ebe;
  --bg: #f3f3f3;
  --surface: #ffffff;
  --border: #d9d9d9;
  --text: #1f1f1f;
  --text-muted: #605e5c;
  --online: #107c10;
  --warning: #ca5010;
  --critical: #d13438;
  --offline: #a4262c;
  --paused: #605e5c;
  --unknown: #8a8886;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Segoe UI Web (West European)", -apple-system,
    BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent);
  color: #fff;
  height: 48px;
  padding: 0 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar .brand {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.topbar .brand small { font-weight: 400; opacity: 0.85; margin-left: 8px; }
.topbar a { color: #fff; }

.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 10px;
  line-height: 1;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.15); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 48px 0 0 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 45;
}
.sidebar-backdrop.visible { display: block; }

.layout { display: flex; min-height: calc(100vh - 48px); }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #e6e6e6;
  border-right: 1px solid var(--border);
  padding-top: 8px;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar a:hover { background: #dcdcdc; text-decoration: none; }
.sidebar a.active {
  background: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar a .fa-solid, .sidebar a .fa-regular {
  width: 18px;
  text-align: center;
  color: var(--text-muted);
}
.sidebar a.active .fa-solid { color: var(--accent); }
.sidebar .nav-section {
  margin: 12px 16px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.content { flex: 1; padding: 20px 24px; min-width: 0; }

.page-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
}
.page-sub { color: var(--text-muted); margin: 0 0 16px; }

/* ---- Karten und Kacheln ---------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
}

.tile-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  padding: 12px 16px;
  min-width: 150px;
  flex: 1;
}
.tile .tile-value { font-size: 26px; font-weight: 600; line-height: 1.2; }
.tile .tile-label { color: var(--text-muted); font-size: 12px; }
.tile.tile-online { border-top-color: var(--online); }
.tile.tile-warning { border-top-color: var(--warning); }
.tile.tile-critical { border-top-color: var(--critical); }
.tile.tile-offline { border-top-color: var(--offline); }
.tile.tile-muted { border-top-color: var(--paused); }

/* ---- Tabellen -------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.octa {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}
table.octa th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  background: #fafafa;
  font-weight: 600;
  white-space: nowrap;
}
table.octa td {
  padding: 7px 10px;
  border-bottom: 1px solid #ececec;
  vertical-align: middle;
}
table.octa tr:hover td { background: #f5f9fd; }
table.octa .muted { color: var(--text-muted); }

/* ---- Status-Badges --------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge-online { background: var(--online); }
.badge-warning { background: var(--warning); }
.badge-critical { background: var(--critical); }
.badge-offline { background: var(--offline); }
.badge-paused { background: var(--paused); }
.badge-unknown { background: var(--unknown); }

.badge-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 400;
}

/* ---- Formulare ------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 12px 20px;
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="number"],
.field input[type="url"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #8a8886;
  background: #fff;
  font: inherit;
  color: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.field .hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.field-checkbox { display: flex; align-items: center; gap: 8px; }
.field-checkbox label { margin: 0; font-weight: 400; color: var(--text); }

/* ---- Buttons --------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: #8a8886;
}
.btn-secondary:hover { background: #f0f0f0; color: var(--text); }
.btn-danger { background: var(--critical); border-color: var(--critical); }
.btn-danger:hover { background: #a4262c; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.inline-form { display: inline; }

/* ---- Flash-Meldungen ------------------------------------------------- */

.flash {
  padding: 10px 14px;
  margin-bottom: 16px;
  border-left: 4px solid var(--accent);
  background: #eff6fc;
}
.flash-success { border-left-color: var(--online); background: #f1faf1; }
.flash-error { border-left-color: var(--critical); background: #fdf3f4; }
.flash-info { border-left-color: var(--accent); background: #eff6fc; }

/* ---- Login ----------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  width: 100%;
  max-width: 380px;
  margin: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  padding: 32px;
}
.login-box h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
.login-box .sub { color: var(--text-muted); margin-bottom: 20px; }

/* ---- Sonstiges ------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input {
  padding: 5px 8px;
  border: 1px solid #8a8886;
  font: inherit;
}

.token-reveal {
  background: #fffbe6;
  border: 1px solid #e8d44d;
  padding: 14px;
  margin-bottom: 16px;
  font-family: Consolas, monospace;
  word-break: break-all;
}

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

.pagination { display: flex; gap: 8px; margin-top: 12px; }

canvas#chart { width: 100%; height: 180px; }

/* ---- Layout-Fallbacks (unabhängig vom Tailwind-CDN) ------------------ */

.grid { display: grid; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
@media (min-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Responsive: Tablets und Smartphones ----------------------------- */

@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }

  /* Sidebar als Off-Canvas-Menü */
  .sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    width: 250px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.25);
  }
  .sidebar.open { transform: translateX(0); }

  .content { padding: 12px; }
  .topbar { padding: 0 8px; }
  .topbar .brand small { display: none; }
  .page-title { font-size: 19px; }
}

@media (max-width: 600px) {
  .topbar-user .user-label { display: none; }

  .tile { min-width: calc(50% - 6px); flex: 1 1 calc(50% - 6px); }
  .tile .tile-value { font-size: 21px; }

  .kv { grid-template-columns: 1fr; gap: 0 12px; }
  .kv dt { margin-top: 8px; }

  .card { padding: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > a.btn, .toolbar > div { align-self: flex-start; }
  .toolbar .filters { width: 100%; }
  .toolbar .filters select, .toolbar .filters input { flex: 1; min-width: 0; }

  table.octa { font-size: 12px; }
  table.octa th, table.octa td { padding: 6px 6px; }
}
