/* ══════════════════════════════════════════════════════════════
   DNSCircle — Admin Panel Styles
   Dark theme, professional DNS filtering admin UI
   ══════════════════════════════════════════════════════════════ */

:root {
  --bg-body:      #0f1117;
  --bg-sidebar:   #161822;
  --bg-card:      #1a1d2e;
  --bg-input:     #222538;
  --bg-hover:     #252940;
  --border:       #2a2e42;
  --border-light: #353a54;
  --text:         #e2e4ed;
  --text-muted:   #8b8fa7;
  --text-dim:     #5c6078;
  --accent:       #4f7cf7;
  --accent-hover: #6b93ff;
  --green:        #34d399;
  --green-bg:     #0d2e23;
  --red:          #f87171;
  --red-bg:       #2e1215;
  --amber:        #fbbf24;
  --amber-bg:     #2e2510;
  --blue:         #60a5fa;
  --blue-bg:      #0f1f3d;
  --purple:       #a78bfa;
  --purple-bg:    #1e1636;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-lg:    0 4px 12px rgba(0,0,0,.4);
  --transition:   150ms ease;
  --sidebar-w:    240px;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

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

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

.sidebar-brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  font-size: 24px;
  color: var(--accent);
}
.brand-icon.large { font-size: 48px; }

.brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: rgba(79,124,247,.12);
  color: var(--accent);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

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

.admin-info {
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
}
.admin-name { font-weight: 600; font-size: 13px; }
.admin-email { font-size: 11px; color: var(--text-muted); }

.logout-link { margin-top: 4px; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.top-bar-actions {
  display: flex;
  gap: 8px;
}

.content {
  padding: 24px 32px;
  flex: 1;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.stat-highlight { border-color: rgba(79,124,247,.3); }
.stat-highlight .stat-value { color: var(--accent); }

.stat-danger { border-color: rgba(248,113,113,.3); }
.stat-danger .stat-value { color: var(--red); }

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  font-size: 15px;
  font-weight: 700;
}

/* ── Grid layouts ───────────────────────────────────────────── */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 1100px) {
  .grid-2col { grid-template-columns: 1fr; }
}

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

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: rgba(0,0,0,.15);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }

.mono { font-family: var(--font-mono); font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge-green  { background: var(--green-bg);  color: var(--green);  border: 1px solid rgba(52,211,153,.2); }
.badge-red    { background: var(--red-bg);    color: var(--red);    border: 1px solid rgba(248,113,113,.2); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber);  border: 1px solid rgba(251,191,36,.2); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   border: 1px solid rgba(96,165,250,.2); }
.badge-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid rgba(167,139,250,.2); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

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

.btn-danger {
  background: var(--red-bg);
  border-color: rgba(248,113,113,.3);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(248,113,113,.15);
  border-color: var(--red);
}

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

.link { color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Detail header ──────────────────────────────────────────── */
.detail-header {
  margin-bottom: 20px;
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-card {
  max-width: 640px;
}
.form-body { padding: 24px; }

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 6px;
}

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,124,247,.15);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa7' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-error {
  background: var(--red-bg);
  border: 1px solid rgba(248,113,113,.3);
  color: var(--red);
}

/* ── Login ──────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 20%, #1a1f3d 0%, var(--bg-body) 70%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

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

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-brand h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-top: 8px;
}
.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}
.login-form .form-group { margin-bottom: 20px; }
.login-form .btn { margin-top: 8px; padding: 12px; font-size: 15px; }

/* ── HTMX loading indicator ─────────────────────────────────── */
.htmx-indicator {
  opacity: 0;
  transition: opacity .2s ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════════
   Light Ocean Theme (alternate)
   ══════════════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg-body:      #f0f4f8;
  --bg-sidebar:   #ffffff;
  --bg-card:      #ffffff;
  --bg-input:     #f5f7fa;
  --bg-hover:     #edf2f7;
  --border:       #e2e8f0;
  --border-light: #cbd5e1;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --text-dim:     #94a3b8;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --green:        #10b981;
  --green-bg:     #ecfdf5;
  --red:          #ef4444;
  --red-bg:       #fef2f2;
  --amber:        #f59e0b;
  --amber-bg:     #fffbeb;
  --blue:         #3b82f6;
  --blue-bg:      #eff6ff;
  --purple:       #8b5cf6;
  --purple-bg:    #f5f3ff;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:    0 4px 12px rgba(0,0,0,.08);
}

[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #1e3a5f 0%, #0f2744 100%);
  border-right: none;
  box-shadow: 2px 0 12px rgba(0,0,0,.1);
}
[data-theme="light"] .sidebar-brand { border-bottom-color: rgba(255,255,255,.1); }
[data-theme="light"] .brand-text { color: #fff; }
[data-theme="light"] .brand-icon { color: #60a5fa; }
[data-theme="light"] .nav-item { color: rgba(255,255,255,.65); }
[data-theme="light"] .nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
[data-theme="light"] .nav-item.active { background: rgba(59,130,246,.25); color: #60a5fa; }
[data-theme="light"] .sidebar-footer { border-top-color: rgba(255,255,255,.1); }
[data-theme="light"] .admin-name { color: #fff; }
[data-theme="light"] .admin-email { color: rgba(255,255,255,.5); }
[data-theme="light"] .logout-link { color: rgba(255,255,255,.5); }
[data-theme="light"] .logout-link:hover { color: #fff; }

[data-theme="light"] .top-bar { background: #fff; border-bottom-color: #e2e8f0; }
[data-theme="light"] .page-title { color: #1e293b; }

[data-theme="light"] thead th { background: #f8fafc; color: #475569; }
[data-theme="light"] tbody tr:hover { background: #f8fafc; }

[data-theme="light"] .badge-green  { background: #ecfdf5; color: #059669; border-color: rgba(16,185,129,.2); }
[data-theme="light"] .badge-red    { background: #fef2f2; color: #dc2626; border-color: rgba(239,68,68,.2); }
[data-theme="light"] .badge-amber  { background: #fffbeb; color: #d97706; border-color: rgba(245,158,11,.2); }
[data-theme="light"] .badge-blue   { background: #eff6ff; color: #2563eb; border-color: rgba(59,130,246,.2); }
[data-theme="light"] .badge-purple { background: #f5f3ff; color: #7c3aed; border-color: rgba(139,92,246,.2); }

[data-theme="light"] .btn { background: #fff; border-color: #e2e8f0; color: #334155; }
[data-theme="light"] .btn:hover { background: #f1f5f9; border-color: #94a3b8; color: #1e293b; }
[data-theme="light"] .btn-primary { background: #3b82f6; border-color: #3b82f6; color: #fff; }
[data-theme="light"] .btn-primary:hover { background: #2563eb; border-color: #2563eb; color: #fff; }

[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"],
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: #fff; border-color: #d1d5db; color: #1e293b;
}
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
}

[data-theme="light"] .login-body { background: radial-gradient(ellipse at 50% 20%, #dbeafe 0%, #f0f4f8 70%); }
[data-theme="light"] .login-card { background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
[data-theme="light"] .alert-error { background: #fef2f2; border-color: rgba(239,68,68,.2); color: #dc2626; }

/* Theme toggle button in sidebar */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
[data-theme="light"] .theme-toggle { color: rgba(255,255,255,.65); }
[data-theme="light"] .theme-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .brand-text, .admin-info, .nav-item span:not(.nav-icon), .theme-toggle span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .theme-toggle { justify-content: center; padding: 12px; }
  .main-content { margin-left: 60px; }
  .content { padding: 16px; }
  .top-bar { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}
