/* ===== MEMBRANE V2 ADMIN THEME ===== */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1e2a3f;
  --accent: #e94560;
  --accent-hover: #ff6b7f;
  --text-primary: #e8e8e8;
  --text-secondary: #8892a4;
  --text-muted: #5a647a;
  --border: #2a3550;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --sidebar-width: 240px;
  --header-height: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  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;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h1 {
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 700;
}
.logo-fire { font-size: 1.3rem; }
.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

#nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: rgba(233,69,96,0.08);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(233,69,96,0.12);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-unknown .status-dot { background: var(--text-muted); }
.status-online .status-dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-degraded .status-dot { background: var(--warning); }
.status-offline .status-dot { background: var(--danger); }

/* ===== MAIN ===== */
#main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

#main-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
#view-title {
  font-size: 1.15rem;
  font-weight: 600;
}
.clock {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

#content-area {
  padding: 24px;
  max-width: 1400px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card-stat {
  text-align: center;
  padding: 24px;
}
.card-stat .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.card-stat .stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.card-stat .stat-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

/* ===== TABLES ===== */
.table-container {
  overflow-x: auto;
  margin-bottom: 16px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--accent);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:hover td {
  background: rgba(233,69,96,0.04);
}
tr.clickable {
  cursor: pointer;
}
tr.clickable:hover td {
  background: rgba(233,69,96,0.08);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-online { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-offline { background: rgba(231,76,60,0.15); color: var(--danger); }
.badge-unknown { background: rgba(90,100,122,0.2); color: var(--text-muted); }
.badge-active { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-inactive { background: rgba(90,100,122,0.2); color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #c0392b; }
.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font);
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-group textarea {
  min-height: 80px;
  resize: vertical;
}
.form-group .inline-flex {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--text-muted);
  border-radius: 22px;
  transition: 0.3s;
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-body {
  padding: 20px;
}

/* ===== SQL CONSOLE ===== */
.sql-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #c9d1d9;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.85rem;
  resize: vertical;
  line-height: 1.5;
  tab-size: 2;
}
.sql-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.sql-result {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  font-size: 0.8rem;
}
.sql-error {
  color: var(--danger);
  padding: 8px 12px;
  background: rgba(231,76,60,0.1);
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: var(--radius-sm);
}
.sql-hint {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-bottom: 8px;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-bar input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== TOASTS ===== */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 0.82rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== UTILITIES ===== */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar {
    width: 60px;
    overflow: hidden;
  }
  .sidebar-header h1, .sidebar-subtitle, .nav-item span:not(.nav-icon), .sidebar-footer {
    display: none;
  }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-icon { font-size: 1.2rem; }
  #main-content { margin-left: 60px; }
  #main-header { padding: 0 12px; }
  #content-area { padding: 12px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
}
