/* =============================================
   EdSit Hardwaremanagement — Haupt-Stylesheet
   Mobile-first, responsiv
   ============================================= */

:root {
  --primary:        #1e3a5f;
  --primary-light:  #2d5a8e;
  --primary-dark:   #122440;
  --accent:         #e67e22;
  --accent-hover:   #d35400;
  --success:        #27ae60;
  --danger:         #e74c3c;
  --warning:        #f39c12;
  --info:           #3498db;
  --sidebar-w:      260px;
  --topbar-h:       58px;
  --bg:             #f0f2f5;
  --white:          #ffffff;
  --card-bg:        #ffffff;
  --text:           #2c3e50;
  --text-muted:     #7f8c8d;
  --border:         #d1d9e0;
  --shadow-sm:      0 1px 4px rgba(0,0,0,0.08);
  --shadow:         0 2px 10px rgba(0,0,0,0.10);
  --shadow-lg:      0 4px 20px rgba(0,0,0,0.14);
  --radius:         8px;
  --radius-lg:      12px;
  --transition:     0.22s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

img { max-width: 100%; }

/* ---- Layout ---- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 0.72rem;
  opacity: 0.65;
  font-weight: 400;
}

.sidebar-section {
  padding: 12px 0 4px;
}

.sidebar-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
  padding: 0 18px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: rgba(255,255,255,0.82);
  font-size: 0.92rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 12px 0 8px;
}

/* ---- Overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}

.sidebar-overlay.show { display: block; }

/* ---- Main Area ---- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--primary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}

.topbar-toggle:hover { background: var(--bg); }

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-netz-standort {
  margin-left: auto;
  padding-right: 12px;
  flex-shrink: 0;
}
.topbar-netz-standort form {
  display: flex;
  align-items: center;
  gap: 5px;
}
.topbar-netz-sel {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  max-width: 180px;
  min-width: 120px;
}
.topbar-netz-sel:focus { outline: none; border-color: var(--primary); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.topbar-user .avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---- Content ---- */
.content {
  flex: 1;
  padding: 20px 16px;
  max-width: 1400px;
  width: 100%;
}

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Cards ---- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fafbfc;
}

.card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* ---- Stats / KPI Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: var(--info); }
.stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }

.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }

.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #229954; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d68910; }

.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: 0.82rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ---- Tables ---- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: #f5f7fa;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.92rem;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fb; }

.td-actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.form-group label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45, 90, 142, 0.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid   { border-color: var(--success); }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237f8c8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

textarea.form-control { min-height: 90px; resize: vertical; }

.form-text { font-size: 0.8rem; color: var(--text-muted); }
.form-error { font-size: 0.8rem; color: var(--danger); }

/* Durchsuchbare Auswahlfelder (progressive enhancement für select.searchable, siehe main.js) */
.ss-wrap { position: relative; }
.ss-input { cursor: text; }
.ss-list {
  position: fixed;
  z-index: 2000;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  max-height: 260px;
  overflow-y: auto;
  display: none;
}
.ss-list.open { display: block; }
.ss-group {
  padding: 6px 12px 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg);
}
.ss-item { padding: 8px 12px; font-size: 0.88rem; cursor: pointer; color: var(--text); }
.ss-item:hover, .ss-item.ss-active { background: var(--bg); }
.ss-item-empty { color: var(--text-muted); font-style: italic; }
.ss-empty { padding: 12px; font-size: 0.85rem; color: var(--text-muted); text-align: center; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ---- Alerts / Flash ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.alert-success { background: #d4edda; border-color: var(--success); color: #155724; }
.alert-danger  { background: #f8d7da; border-color: var(--danger);  color: #721c24; }
.alert-warning { background: #fff3cd; border-color: var(--warning); color: #856404; }
.alert-info    { background: #d1ecf1; border-color: var(--info);    color: #0c5460; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info    { background: #d1ecf1; color: #0c5460; }
.badge-primary { background: #d0dff2; color: var(--primary); }
.badge-muted   { background: #e9ecef; color: #6c757d; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; opacity: 0.4; }
.empty-state p { margin: 0 0 16px; }

/* ---- Search / Filter Bar ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.filter-bar .form-control { max-width: 280px; }

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-circle {
  width: 60px; height: 60px;
  background: var(--primary);
  border-radius: 16px;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  color: #fff;
}

.login-logo h1 { font-size: 1.4rem; color: var(--primary); margin: 0 0 4px; }
.login-logo p { color: var(--text-muted); margin: 0; font-size: 0.88rem; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
}

.page-link {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  text-decoration: none;
  background: var(--white);
}

.page-link:hover { background: var(--bg); text-decoration: none; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Confirm Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
  padding: 28px;
}

.modal h3 { margin: 0 0 12px; color: var(--text); }
.modal p  { color: var(--text-muted); margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---- Nav Gruppe (aufklappbar) ---- */
.nav-group { display: flex; flex-direction: column; }

.nav-group-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
}

.nav-group-arrow {
  transition: transform var(--transition);
}

.nav-group-arrow.open {
  transform: rotate(90deg);
}

.nav-sub {
  overflow: hidden;
}

.nav-sub-item {
  padding-left: 40px !important;
  font-size: 0.88rem !important;
  opacity: 0.9;
}

.nav-sub-item i {
  font-size: 0.75rem !important;
  opacity: 0.7;
}

.nav-sub-item.active {
  opacity: 1;
}

/* ---- Utilities ---- */
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.fw-bold      { font-weight: 700; }
.d-flex       { display: flex; }

/* Detail-Liste (Label / Wert) */
.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.detail-list dt { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; padding-top: 2px; }
.detail-list dd { margin: 0; font-size: 0.925rem; color: var(--text); word-break: break-word; }

/* Inaktive Tabellenzeile */
.row-inactive td { opacity: 0.55; }
.align-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.mt-1         { margin-top: 6px; }
.mt-2         { margin-top: 12px; }
.mt-3         { margin-top: 20px; }
.mb-0         { margin-bottom: 0; }
.ms-auto      { margin-left: auto; }

/* ---- Status colors ---- */
.status-aktiv       { color: var(--success); }
.status-inaktiv     { color: var(--text-muted); }
.status-defekt      { color: var(--danger); }
.status-ausserbetrieb { color: var(--warning); }

/* ============================================
   DESKTOP — ab 900px Sidebar immer sichtbar
   ============================================ */
@media (min-width: 900px) {
  .sidebar {
    transform: translateX(0);
    position: fixed;
  }

  .main-area {
    margin-left: var(--sidebar-w);
  }

  .topbar-toggle { display: none; }
  .sidebar-overlay { display: none !important; }

  .content { padding: 24px 28px; }

  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

@media (min-width: 1200px) {
  .form-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
