/* ═══════════════════════════════════════════════════════════════
   HomeBrain Portal · Design System
   Aesthetic: Refined Dark Control Room · Amber/Sonnenwiese Accent
   ═══════════════════════════════════════════════════════════════ */

/* ── Variablen ────────────────────────────────────────────────── */
:root {
  --bg-base:        #0c0f16;
  --bg-surface:     #131720;
  --bg-card:        #1a2030;
  --bg-card-hover:  #1f2840;
  --bg-input:       #0f1320;

  --accent:         #f59e0b;
  --accent-dim:     rgba(245, 158, 11, 0.12);
  --accent-glow:    rgba(245, 158, 11, 0.25);

  --blue:           #60a5fa;
  --blue-dim:       rgba(96, 165, 250, 0.12);
  --green:          #34d399;
  --green-dim:      rgba(52, 211, 153, 0.12);
  --red:            #f87171;
  --red-dim:        rgba(248, 113, 113, 0.12);

  --text-primary:   #e8eaf0;
  --text-secondary: #7c8499;
  --text-muted:     #4a5168;

  --border:         rgba(255,255,255,0.06);
  --border-strong:  rgba(255,255,255,0.12);

  --sidebar-w:      220px;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;

  --font-main:  'Outfit', sans-serif;
  --font-mono:  'DM Mono', monospace;

  --transition: 0.18s ease;
}

/* ── Reset & Basis ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font-main);
  background:  var(--bg-base);
  color:       var(--text-primary);
  min-height:  100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ── App-Layout ───────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  background:   var(--bg-surface);
  border-right: 1px solid var(--border);
  display:      flex;
  flex-direction: column;
  position:     sticky;
  top:          0;
  height:       100vh;
  padding:      1.5rem 0;
}

.sidebar-brand {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand-icon {
  width:           34px;
  height:          34px;
  border-radius:   var(--radius-sm);
  background:      var(--accent-dim);
  border:          1px solid var(--accent-glow);
  display:         flex;
  align-items:     center;
  justify-content: center;
  color:           var(--accent);
  flex-shrink:     0;
}

.brand-name {
  font-size:   1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color:       var(--text-primary);
}

.sidebar-nav {
  flex:    1;
  padding: 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap:     2px;
}

.nav-item {
  display:       flex;
  align-items:   center;
  gap:           10px;
  padding:       0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color:         var(--text-secondary);
  font-weight:   400;
  font-size:     0.9rem;
  transition:    background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--border); color: var(--text-primary); opacity:1; }
.nav-item.active {
  background: var(--accent-dim);
  color:      var(--accent);
  font-weight: 500;
}

.sidebar-footer {
  padding:    1.25rem 1rem 0;
  border-top: 1px solid var(--border);
  display:    flex;
  align-items: center;
  gap:        10px;
}

.user-info {
  display:    flex;
  align-items: center;
  gap:        10px;
  flex:       1;
  min-width:  0;
}

.user-avatar {
  width:           32px;
  height:          32px;
  border-radius:   50%;
  background:      var(--accent-dim);
  border:          1px solid var(--accent-glow);
  display:         flex;
  align-items:     center;
  justify-content: center;
  color:           var(--accent);
  font-size:       0.8rem;
  font-weight:     600;
  flex-shrink:     0;
}

.user-details { min-width: 0; }

.user-name {
  display:    block;
  font-size:  0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow:   hidden;
  text-overflow: ellipsis;
}

.user-role {
  display:   block;
  font-size: 0.7rem;
  color:     var(--accent);
  font-family: var(--font-mono);
}

.logout-btn {
  color:         var(--text-muted);
  transition:    color var(--transition);
  padding:       4px;
  border-radius: var(--radius-sm);
  flex-shrink:   0;
}
.logout-btn:hover { color: var(--red); opacity:1; }

/* ── Hauptbereich ─────────────────────────────────────────────── */
.main-content { overflow-y: auto; }

.content-inner {
  padding:   2rem 2.5rem;
  max-width: 1100px;
}

/* ── Seitenköpfe ──────────────────────────────────────────────── */
.page-header {
  margin-bottom: 2rem;
}
.page-header h1 {
  font-size:   1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color:       var(--text-primary);
}
.page-header p {
  font-size: 0.9rem;
  color:     var(--text-secondary);
  margin-top: 0.25rem;
}

/* ── Karten ───────────────────────────────────────────────────── */
.card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       1.5rem;
}

/* ── Service-Grid ─────────────────────────────────────────────── */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.service-card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       1.25rem;
  cursor:        pointer;
  transition:    background var(--transition), border-color var(--transition),
                 transform var(--transition);
  display:       block;
  color:         inherit;
  text-decoration: none;
}
.service-card:hover {
  background:    var(--bg-card-hover);
  border-color:  var(--border-strong);
  transform:     translateY(-2px);
  opacity:       1;
}

.service-icon {
  width:           44px;
  height:          44px;
  border-radius:   var(--radius-md);
  display:         flex;
  align-items:     center;
  justify-content: center;
  margin-bottom:   1rem;
  font-size:       1.2rem;
}

.service-name {
  font-size:   0.95rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.service-desc {
  font-size: 0.8rem;
  color:     var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 1rem;
}

.service-footer {
  display:     flex;
  align-items: center;
  gap:         6px;
}

.status-dot {
  width:         6px;
  height:        6px;
  border-radius: 50%;
  flex-shrink:   0;
}
.status-online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-offline { background: var(--text-muted); }

.status-label {
  font-size:  0.75rem;
  color:      var(--text-secondary);
  font-family: var(--font-mono);
}

.service-badge {
  margin-left: auto;
  font-size:   0.65rem;
  font-family: var(--font-mono);
  padding:     2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-public   { background: var(--green-dim);  color: var(--green); }
.badge-assigned { background: var(--blue-dim);   color: var(--blue); }

/* ── Auth-Layout ──────────────────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display:    flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:    2rem 1rem;
  position:   relative;
  overflow:   hidden;
}

/* Dezentes Punktmuster im Hintergrund */
.auth-bg-dots {
  position:  absolute;
  inset:     0;
  background-image: radial-gradient(circle, rgba(245,158,11,0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.auth-box {
  width:         100%;
  max-width:     400px;
  background:    var(--bg-surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       2.5rem;
  position:      relative;
  z-index:       1;
}

.auth-brand {
  display:       flex;
  align-items:   center;
  gap:           10px;
  margin-bottom: 2rem;
  font-size:     1.1rem;
  font-weight:   600;
  color:         var(--text-primary);
}

.auth-brand-icon {
  width:           38px;
  height:          38px;
  border-radius:   var(--radius-md);
  background:      var(--accent-dim);
  border:          1px solid var(--accent-glow);
  display:         flex;
  align-items:     center;
  justify-content: center;
  color:           var(--accent);
}

.auth-footer {
  margin-top: 1.5rem;
  font-size:  0.75rem;
  color:      var(--text-muted);
  font-family: var(--font-mono);
  position:   relative;
  z-index:    1;
}

/* ── Formulare ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
  display:    block;
  font-size:  0.8rem;
  font-weight: 500;
  color:      var(--text-secondary);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

.form-input {
  width:         100%;
  background:    var(--bg-input);
  border:        1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding:       0.6rem 0.85rem;
  color:         var(--text-primary);
  font-family:   var(--font-main);
  font-size:     0.9rem;
  transition:    border-color var(--transition);
  outline:       none;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow:   0 0 0 3px var(--accent-dim);
}
.form-input::placeholder { color: var(--text-muted); }

.form-hint {
  font-size: 0.75rem;
  color:     var(--text-muted);
  margin-top: 0.3rem;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display:       inline-flex;
  align-items:   center;
  justify-content: center;
  gap:           6px;
  padding:       0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family:   var(--font-main);
  font-size:     0.875rem;
  font-weight:   500;
  cursor:        pointer;
  border:        1px solid transparent;
  transition:    all var(--transition);
  text-decoration: none;
  white-space:   nowrap;
}

.btn-primary {
  background: var(--accent);
  color:      #0c0f16;
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.9; color: #0c0f16; }

.btn-ghost {
  background:   transparent;
  border-color: var(--border-strong);
  color:        var(--text-secondary);
}
.btn-ghost:hover { background: var(--border); color: var(--text-primary); opacity:1; }

.btn-danger {
  background: transparent;
  border-color: var(--red-dim);
  color:      var(--red);
}
.btn-danger:hover { background: var(--red-dim); opacity:1; }

.btn-full { width: 100%; }
.btn-sm   { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* ── Flash-Meldungen ──────────────────────────────────────────── */
.flash-container { margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: 8px; }

.flash {
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  padding:       0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size:     0.875rem;
  border:        1px solid transparent;
}

.flash-success { background: var(--green-dim); border-color: rgba(52,211,153,0.2); color: var(--green); }
.flash-danger  { background: var(--red-dim);   border-color: rgba(248,113,113,0.2); color: var(--red); }
.flash-info    { background: var(--blue-dim);  border-color: rgba(96,165,250,0.2);  color: var(--blue); }
.flash-warning { background: var(--accent-dim); border-color: var(--accent-glow);  color: var(--accent); }

.flash-close {
  background: none;
  border:     none;
  color:      inherit;
  cursor:     pointer;
  font-size:  1.1rem;
  opacity:    0.6;
  padding:    0 4px;
}
.flash-close:hover { opacity: 1; }

/* ── Tabellen (Admin) ─────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width:           100%;
  border-collapse: collapse;
  font-size:       0.875rem;
}

thead th {
  background:    var(--bg-surface);
  padding:       0.75rem 1rem;
  text-align:    left;
  font-size:     0.75rem;
  font-weight:   500;
  color:         var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding:       0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  color:         var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── Chips & Badges ───────────────────────────────────────────── */
.chip {
  display:       inline-flex;
  align-items:   center;
  gap:           5px;
  font-size:     0.72rem;
  font-family:   var(--font-mono);
  padding:       2px 8px;
  border-radius: 20px;
  font-weight:   500;
}
.chip-green { background: var(--green-dim);  color: var(--green); }
.chip-red   { background: var(--red-dim);    color: var(--red); }
.chip-amber { background: var(--accent-dim); color: var(--accent); }
.chip-blue  { background: var(--blue-dim);   color: var(--blue); }

/* ── Statistik-Karten (Admin) ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       1.25rem;
}
.stat-label {
  font-size:  0.75rem;
  color:      var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  margin-bottom: 0.5rem;
}
.stat-value {
  font-size:   1.8rem;
  font-weight: 600;
  color:       var(--text-primary);
  letter-spacing: -0.02em;
}

/* ── Service-Formular ─────────────────────────────────────────── */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-picker-row input[type="color"] {
  width:         40px;
  height:        36px;
  border:        1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background:    var(--bg-input);
  cursor:        pointer;
  padding:       2px;
}

/* ── Sonstiges ────────────────────────────────────────────────── */
.divider {
  border:        none;
  border-top:    1px solid var(--border);
  margin:        1.25rem 0;
}

.text-center  { text-align: center; }
.text-sm      { font-size: 0.82rem; color: var(--text-secondary); }
.text-mono    { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-muted); }
.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.gap-2 { gap: 0.5rem; }
.flex  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height:   auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding:  1rem;
  }
  .sidebar-nav { flex-direction: row; }
  .content-inner { padding: 1.25rem; }
  .services-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
