/* Design tokens */
:root {
  --bg-body: #0f172a;
  --surface-0: #f6f8fb;
  --surface-1: #ffffff;
  --surface-2: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-subtle: #e5e7eb;
  --text-strong: #0b1220;
  --text-muted: #5f6b85;
  --brand: #0ea5e9;
  --brand-strong: #0284c7;
  --accent: #7c3aed;
  --success: #0ea76a;
  --warning: #eab308;
  --danger: #e11d48;
  --info: #2563eb;
  --card-radius: 14px;
  --shadow-soft: 0 14px 40px rgba(15, 23, 42, 0.08);
  --shadow-light: 0 4px 16px rgba(15, 23, 42, 0.06);
  --spacing: 16px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.12), transparent 25%),
              radial-gradient(circle at 80% 10%, rgba(124, 58, 237, 0.12), transparent 20%),
              var(--surface-0);
  color: var(--text-strong);
  padding-top: 64px;
}

main.container {
  position: relative;
  /* Removed z-index to prevent stacking context issues with lightbox */
}

.navbar {
  box-shadow: var(--shadow-light);
  background: linear-gradient(90deg, #0f172a 0%, #0b1220 100%) !important;
}

/* Ensure fixed navbar stays below lightbox overlays */
.navbar.fixed-top {
  z-index: 1030 !important;
}

/* Global lightbox styles - must be above all fixed elements */
.lightbox-overlay {
  z-index: 99999 !important;
}
.lightbox-close,
.lightbox-arrow {
  z-index: 100000 !important;
}

.navbar-brand {
  letter-spacing: 0.4px;
  font-weight: 700;
}

.card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
}

.card-header {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.12), rgba(124, 58, 237, 0.12));
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.28);
}

.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.btn-soft {
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.24);
  color: var(--brand-strong);
}

.table-modern {
  border-radius: var(--card-radius);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
}

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

.table-modern thead th {
  background: #0f172a;
  color: #f8fafc;
  border-bottom: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 12px 16px;
  text-align: left;
}

.table-modern tbody tr {
  border-bottom: 1px solid var(--border-subtle);
}

.table-modern tbody tr:last-child {
  border-bottom: none;
}

.table-modern tbody tr:hover {
  background: rgba(14, 165, 233, 0.05);
}

.table-modern td, .table-modern th {
  vertical-align: middle;
  padding: 12px 16px;
}

.table-modern td {
  border-bottom: 1px solid var(--border-subtle);
}

.badge-status {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  border: 1px solid transparent;
}

.badge-status.active { background: rgba(14, 167, 106, 0.14); color: #0f5132; border-color: rgba(14, 167, 106, 0.24); }
.badge-status.inactive { background: rgba(226, 232, 240, 0.7); color: #334155; border-color: rgba(148, 163, 184, 0.5); }
.badge-status.maintenance { background: rgba(234, 179, 8, 0.16); color: #854d0e; border-color: rgba(234, 179, 8, 0.4); }
.badge-status.offline { background: rgba(225, 29, 72, 0.12); color: #9f1239; border-color: rgba(225, 29, 72, 0.32); }
.badge-status.syncing { background: rgba(37, 99, 235, 0.12); color: #1d4ed8; border-color: rgba(37, 99, 235, 0.3); }

.input-chip {
  background: rgba(15, 23, 42, 0.06);
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
}

.form-control, .form-select {
  border-radius: 10px;
  border-color: var(--border-subtle);
  padding: 10px 12px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(14, 165, 233, 0.25);
}

.form-label {
  font-weight: 600;
  color: var(--text-muted);
}

.alert-soft {
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.04);
}

.toast-lite {
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-light);
  background: var(--surface-1);
}

.toast-lite .toast-header {
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
}

/* Activity Toggle Button */
.activity-toggle {
  position: fixed;
  right: 18px;
  top: 88px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.activity-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-soft), 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.activity-toggle .activity-icon {
  font-size: 1.3rem;
}

.activity-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Activity Panel - Slide in from right */
.activity-panel {
  position: fixed;
  right: -320px;
  top: 88px;
  width: 300px;
  max-height: calc(100vh - 120px);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
  padding: 12px;
  overflow-y: auto;
  z-index: 100;
  transition: right 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-panel.open {
  right: 18px;
}

.activity-header {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
}

.activity-item {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.02);
}

.activity-item .title { font-weight: 600; }
.activity-item .meta { font-size: 0.82rem; color: var(--text-muted); }

.activity-item.success { border-color: rgba(14, 167, 106, 0.25); }
.activity-item.warning { border-color: rgba(234, 179, 8, 0.4); }
.activity-item.danger { border-color: rgba(225, 29, 72, 0.32); }

.search-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  box-shadow: var(--shadow-light);
}

.control-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 991px) {
  body { padding-top: 56px; }
  .activity-panel { display: none !important; }
  .activity-toggle { display: none !important; }
}

.map-container { height: 420px; width: 100%; border-radius: var(--card-radius); overflow: hidden; box-shadow: var(--shadow-light); }
