/* =====================================================
   OnlyLANs - Dark Theme CSS
   Self-contained, no external dependencies
   ===================================================== */

/* ── CSS Variables ── */
:root, [data-theme="dark"] {
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-tertiary:   #21262d;
  --bg-hover:      #30363d;
  --border:        #30363d;
  --text:          #e6edf3;
  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #6e7681;
  --primary:       #58a6ff;
  --accent:        #58a6ff;
  --accent-hover:  #79b8ff;
  --success:       #3fb950;
  --warning:       #d29922;
  --danger:        #f85149;
  --info:          #58a6ff;

  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 56px;
  --radius:        8px;
  --radius-sm:     4px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --transition:    0.2s ease;
}

[data-theme="light"] {
  --bg-primary:    #f6f8fa;
  --bg-secondary:  #ffffff;
  --bg-tertiary:   #eaeef2;
  --bg-hover:      #d0d7de;
  --border:        #d0d7de;
  --text:          #1f2328;
  --text-primary:  #1f2328;
  --text-secondary:#57606a;
  --text-muted:    #6e7781;
  --primary:       #0969da;
  --accent:        #0969da;
  --accent-hover:  #0550ae;
  --success:       #1a7f37;
  --warning:       #9a6700;
  --danger:        #cf222e;
  --info:          #0969da;
  --shadow:        0 4px 24px rgba(0,0,0,0.1);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

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

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .logo-text { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.logo-icon { font-size: 22px; }
.logo-text  { color: var(--accent); }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-hover); }

.nav-links {
  list-style: none;
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--bg-tertiary);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-icon { font-size: 18px; min-width: 24px; text-align: center; }
.nav-label { font-size: 14px; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

.logout-link { color: var(--danger); }
.logout-link:hover { color: var(--danger); background: rgba(248,81,73,0.1); }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

.sidebar-toggle-mobile {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
}

/* ── Content Area ── */
.content-area {
  padding: 24px;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.card-body { padding: 20px; }

.card-warning { border-color: var(--warning); }
.card-warning .card-header { border-bottom-color: var(--warning); }

.mt-4 { margin-top: 16px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card { padding: 20px; }
.stat-card .stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.stat-title  { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.stat-icon   { font-size: 20px; opacity: 0.6; }
.stat-value  { font-size: 32px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-sub    { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }

/* ── Progress Bar ── */
.progress-bar-wrap {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── Status Dots ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-right: 4px;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

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

.table th,
.table td {
  padding: 10px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.empty-msg {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { opacity: 0.85; text-decoration: none; }

.btn-primary  { background: var(--accent);   color: #0d1117; border-color: var(--accent); }
.btn-success  { background: var(--success);  color: #0d1117; border-color: var(--success); }
.btn-danger   { background: var(--danger);   color: #fff;    border-color: var(--danger); }
.btn-warning  { background: var(--warning);  color: #0d1117; border-color: var(--warning); }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}
.form-control::placeholder { color: var(--text-muted); }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.form-check { display: flex; align-items: center; gap: 8px; }
.check-input { width: 16px; height: 16px; cursor: pointer; }
.check-label { margin-bottom: 0; color: var(--text-secondary); font-size: 13px; }

.form-vertical .form-group { margin-bottom: 20px; }
.form-inline { display: flex; flex-direction: column; }

/* ── Alerts / Flash ── */
.flash-container { margin-bottom: 16px; }

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin-bottom: 8px;
  font-size: 14px;
  transition: opacity 0.3s ease;
}

.alert-success { background: rgba(63,185,80,0.15);  border-color: var(--success); color: var(--success); }
.alert-danger  { background: rgba(248,81,73,0.15);  border-color: var(--danger);  color: var(--danger); }
.alert-warning { background: rgba(210,153,34,0.15); border-color: var(--warning); color: var(--warning); }
.alert-info    { background: rgba(88,166,255,0.15); border-color: var(--info);    color: var(--info); }

.alert-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.7;
}
.alert-close:hover { opacity: 1; }

/* ── Info Grid ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.info-value { font-size: 14px; color: var(--text-primary); word-break: break-all; }

/* ── Quick Links ── */
.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.quick-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 16px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  cursor: pointer;
}

.quick-link-card:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.quick-icon { font-size: 28px; }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-dialog {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-sm { max-width: 400px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* ── Logs ── */
.logs-pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-secondary);
  max-height: 400px;
  overflow-y: auto;
}

/* ── Utility ── */
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.small        { font-size: 12px; }
.mono         { font-family: 'SFMono-Regular', Consolas, monospace; }
.text-center  { text-align: center; }
.flex-wrap    { flex-wrap: wrap; }

/* ── Login Page ── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo { justify-content: center; font-size: 22px; margin-bottom: 8px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; }

.login-form .form-control { max-width: none; }

.login-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .sidebar-toggle-mobile { display: block; }
  .sidebar-toggle { display: none; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .quick-links-grid { grid-template-columns: 1fr 1fr; }
  .content-area { padding: 16px; }

  .table th, .table td { padding: 8px 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .quick-links-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 24px; }
}
