/* ═══════════════════════════════════════════════════════════════════════════
   BIND9 Manager — Design System
   Dark mode premium · Glassmorphism · Inter + JetBrains Mono
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --bg-base:       #080c12;
  --bg-surface:    #0d1520;
  --bg-elevated:   #131c2e;
  --bg-card:       rgba(19, 28, 46, 0.8);
  --bg-glass:      rgba(255,255,255,0.04);
  --bg-glass-hover:rgba(255,255,255,0.07);

  --border:        rgba(255,255,255,0.08);
  --border-accent: rgba(0,210,190,0.3);

  /* Accent — teal/cyan */
  --accent:        #00d2be;
  --accent-dark:   #00a89a;
  --accent-light:  #33dece;
  --accent-glow:   rgba(0,210,190,0.2);

  /* Semantic */
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;
  --purple:        #8b5cf6;

  /* Text */
  --text-primary:   #e8edf5;
  --text-secondary: #8b9ab0;
  --text-muted:     #4a5568;
  --text-accent:    #00d2be;

  /* Layout */
  --sidebar-w:     260px;
  --sidebar-w-sm:  72px;
  --topbar-h:      60px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  /* Shadows */
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:     0 8px 32px rgba(0,0,0,0.5);
  --shadow-lg:     0 20px 60px rgba(0,0,0,0.6);
  --shadow-accent: 0 0 30px rgba(0,210,190,0.15);

  /* Transitions */
  --transition:    all 0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: all 0.35s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, rgba(0,210,190,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.05) 0%, transparent 60%),
              var(--bg-base);
}

.login-bg-orbs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orb-float 8s ease-in-out infinite;
}
.orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,210,190,0.12) 0%, transparent 70%);
  top: -100px; left: -100px;
  animation-delay: 0s;
}
.orb-2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(139,92,246,0.08) 0%, transparent 70%);
  bottom: -80px; right: -80px;
  animation-delay: -3s;
}
.orb-3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(59,130,246,0.08) 0%, transparent 70%);
  top: 50%; right: 20%;
  animation-delay: -6s;
}
@keyframes orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -20px) scale(1.05); }
}

.login-card {
  width: 100%;
  max-width: 400px;
  margin: 24px;
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--shadow-accent);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}
.login-logo .logo-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px rgba(0,210,190,0.4));
}
.login-logo h1 {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.login-logo p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper { position: relative; }
.input-wrapper input { padding-right: 40px; }
.toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  transition: opacity 0.2s;
  padding: 0;
}
.toggle-password:hover { opacity: 1; }

.login-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fca5a5;
  font-size: 13px;
}

.btn-full { width: 100%; }

.login-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.sidebar-logo { font-size: 24px; flex-shrink: 0; }
.sidebar-title { flex: 1; min-width: 0; }
.sidebar-name { display: block; font-weight: 800; font-size: 15px; color: var(--accent); letter-spacing: -0.3px; }
.sidebar-sub  { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-glass-hover); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 20px 6px;
  transition: var(--transition);
}
.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(0,210,190,0.1);
  color: var(--accent);
  border: 1px solid var(--border-accent);
}
.nav-item.active .nav-icon { filter: drop-shadow(0 0 6px rgba(0,210,190,0.5)); }

.nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-label { flex: 1; transition: var(--transition); }
.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.nav-badge {
  font-size: 10px;
  color: var(--success);
  flex-shrink: 0;
}
.nav-badge.down { color: var(--danger); }
.nav-badge-live {
  font-size: 9px;
  font-weight: 700;
  color: var(--danger);
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.5px;
  animation: pulse-badge 2s infinite;
  opacity: 0;
  flex-shrink: 0;
}
.nav-badge-live.active { opacity: 1; }
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #000;
  flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: 13px; color: var(--text-primary); }
.user-role {
  display: block;
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

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

/* ── Collapsed Sidebar Header ────────────────────────────────────────────── */
.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 8px;
  gap: 10px;
  min-height: 80px;
}
.sidebar.collapsed .sidebar-title { display: none; }
.sidebar.collapsed .sidebar-logo  { font-size: 26px; }
.sidebar.collapsed .sidebar-toggle {
  /* Clearly visible toggle to re-expand */
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass-hover);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ── Collapsed Sidebar Footer ────────────────────────────────────────────── */
.sidebar.collapsed .sidebar-footer {
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  gap: 8px;
}
.sidebar.collapsed .user-details { display: none; }
.sidebar.collapsed .user-info { flex: none; gap: 0; }
.sidebar.collapsed .btn-logout {
  font-size: 16px;
  padding: 5px;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}
.breadcrumb {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.service-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: default;
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-active  { background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse-dot 2s infinite; }
.dot-down    { background: var(--danger); }
.dot-unknown { background: var(--text-muted); }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--success); }
  50% { box-shadow: 0 0 12px var(--success); }
}

.page-content { flex: 1; padding: 24px; overflow-y: auto; }

/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #000;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,210,190,0.35);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-glass-hover);
  border-color: var(--border-accent);
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239,68,68,0.2);
}

.btn-success {
  background: rgba(34,197,94,0.12);
  color: #86efac;
  border-color: rgba(34,197,94,0.3);
}
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,0.2); }

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-glass); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-icon {
  padding: 7px;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  justify-content: center;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 14px;
  transition: var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select {
  cursor: pointer;
  /* Safari / Cross-browser reset */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Custom dropdown arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b9ab0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  padding-right: 38px !important;
  min-height: 40px;
  line-height: 1.4;
}
textarea { resize: vertical; min-height: 80px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}
.card:hover { border-color: rgba(255,255,255,0.12); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── Stats Cards ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-accent); }
.stat-card:hover::before { opacity: 1; }

.stat-icon { font-size: 24px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--bg-elevated);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: var(--transition); }
tbody tr:hover { background: var(--bg-glass-hover); }
tbody tr:last-child { border-bottom: none; }
td { padding: 12px 16px; color: var(--text-primary); vertical-align: middle; }
td.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-success { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.badge-warning { background: rgba(245,158,11,0.15); color: #fcd34d; border: 1px solid rgba(245,158,11,0.3); }
.badge-info    { background: rgba(59,130,246,0.15); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }
.badge-accent  { background: rgba(0,210,190,0.12);  color: var(--accent); border: 1px solid var(--border-accent); }
.badge-purple  { background: rgba(139,92,246,0.15); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.3); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: overlay-in 0.2s ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: modal-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden;
}
@keyframes modal-in { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal.modal-lg { max-width: 800px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: toast-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
  font-size: 13px;
  font-weight: 500;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
.toast-out { animation: toast-out 0.2s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }
.toast-success { border-color: rgba(34,197,94,0.3); }
.toast-danger  { border-color: rgba(239,68,68,0.3); }
.toast-warning { border-color: rgba(245,158,11,0.3); }
.toast-icon { font-size: 18px; flex-shrink: 0; }

/* ── Loading States ───────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 200px;
  color: var(--text-muted);
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-large {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state-icon { font-size: 48px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state-desc { font-size: 13px; max-width: 300px; }

/* ── Form Layouts ─────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-col-span-2 { grid-column: span 2; }

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── Page Headers ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header-left {}
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
  font-family: inherit;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Search/Filter Bar ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar input { max-width: 300px; }
.filter-bar select { max-width: 180px; }

/* ── Log Viewer ───────────────────────────────────────────────────────────── */
.log-viewer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  background: #060a0f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #c9d1d9;
}
.log-line-error   { color: #fca5a5; }
.log-line-warning { color: #fcd34d; }
.log-line-info    { color: #93c5fd; }
.log-line-debug   { color: #a5b4fc; }
.log-heartbeat    { color: var(--text-muted); font-style: italic; }
.log-connected    { color: var(--success); }

/* ── DNSSEC Key Card ──────────────────────────────────────────────────────── */
.key-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.key-card-header { display: flex; align-items: center; gap: 12px; }
.key-type-badge {}
.key-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.key-meta-item { display: flex; flex-direction: column; }
.key-meta-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.key-meta-value { font-size: 12px; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; }

/* ── Action Group ─────────────────────────────────────────────────────────── */
.action-group { display: flex; gap: 8px; align-items: center; }

/* ── Confirm Danger ───────────────────────────────────────────────────────── */
.danger-zone {
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(239,68,68,0.05);
}
.danger-zone-title { color: #fca5a5; font-weight: 700; margin-bottom: 8px; font-size: 13px; }

/* ── Zone type colors ─────────────────────────────────────────────────────── */
.zone-forward { color: var(--accent); }
.zone-reverse { color: var(--purple); }

/* ── Service control buttons ──────────────────────────────────────────────── */
.service-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Code block ───────────────────────────────────────────────────────────── */
.code-block {
  background: #060a0f;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #c9d1d9;
  overflow-x: auto;
  white-space: pre;
}

/* ── Progress / inline status ─────────────────────────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.status-row:last-child { border-bottom: none; }
.status-row-label { color: var(--text-secondary); font-size: 13px; }
.status-row-value { font-weight: 600; font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mac · iPad · iPhone
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar Backdrop (tablet/mobile) ─────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-backdrop.active { opacity: 1; }

/* ── iPad (769px – 1024px) ────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Sidebar overlays content on tablet (never pushes it) */
  .main-content { margin-left: var(--sidebar-w-sm) !important; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Forms */
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }

  /* Page header wraps */
  .page-header { flex-wrap: wrap; }

  /* Backdrop visible when sidebar expanded on tablet */
  .sidebar-backdrop { display: block; }
}

/* ── Mobile — iPhone (≤ 768px) ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* ·· Sidebar: slide-in drawer ·· */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    z-index: 200;
    box-shadow: none;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), width 0.3s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  /* Collapsed class has no effect on mobile (drawer is either open or closed) */
  .sidebar.collapsed { width: var(--sidebar-w); }
  .sidebar.collapsed .sidebar-header { flex-direction: row; align-items: center; justify-content: space-between; padding: 20px 16px; min-height: 64px; }
  .sidebar.collapsed .sidebar-title  { display: flex; }
  .sidebar.collapsed .sidebar-logo   { font-size: 24px; }
  .sidebar.collapsed .sidebar-toggle { width: auto; height: auto; background: none; }
  .sidebar.collapsed .sidebar-footer { flex-direction: row; align-items: center; padding: 16px; gap: 10px; }
  .sidebar.collapsed .user-details   { display: block; }
  .sidebar.collapsed .user-info      { flex: 1; gap: 10px; }
  .sidebar.collapsed .btn-logout     { font-size: 18px; padding: 6px; }
  .sidebar.collapsed .nav-label      { opacity: 1; width: auto; overflow: visible; }
  .sidebar.collapsed .nav-section-label { opacity: 1; height: auto; padding: 12px 20px 6px; }

  /* ·· Backdrop ·· */
  .sidebar-backdrop { display: block; }

  /* ·· Main content: full width ·· */
  .main-content { margin-left: 0 !important; }

  /* ·· Topbar ·· */
  .mobile-menu-btn { display: flex; }
  .topbar { padding: 0 12px; }
  .topbar-right { gap: 6px; }
  #service-status-text { display: none; }  /* hide text, keep dot indicator */

  /* ·· Page content ·· */
  .page-content { padding: 14px; }

  /* ·· Page header ·· */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .page-actions .btn { flex: 1; justify-content: center; min-width: 120px; }
  .page-title { font-size: 20px; }

  /* ·· Stats grid ·· */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card  { padding: 14px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }

  /* ·· Forms ·· */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-col-span-2 { grid-column: span 1; }

  /* ·· Inputs: prevent iOS zoom (16px+), touch-friendly height ·· */
  input, textarea {
    font-size: 16px !important;
    min-height: 44px;
  }
  select {
    font-size: 16px !important;
    min-height: 44px;
  }

  /* ·· Buttons: touch-friendly ·· */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; font-size: 12px; }
  .nav-item { padding: 12px 16px; }

  /* ·· Cards ·· */
  .card { padding: 14px; }
  .card-header { margin-bottom: 14px; }

  /* ·· Tables: horizontal scroll ·· */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }
  table { min-width: 540px; }
  td, th { padding: 10px 12px; }

  /* ·· Filter bar: stack ·· */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-bar input,
  .filter-bar select { max-width: 100%; }

  /* ·· Modals: slide up from bottom ·· */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: modal-mobile-up 0.35s cubic-bezier(0.32,0.72,0,1);
  }
  @keyframes modal-mobile-up {
    from { transform: translateY(100%); opacity: 0.5; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .modal.modal-lg { max-width: 100%; }

  /* ·· Log viewer ·· */
  .log-viewer { height: 320px; font-size: 11px; }

  /* ·· Service controls: full width buttons ·· */
  .service-controls { flex-direction: column; }
  .service-controls .btn { width: 100%; justify-content: center; }

  /* ·· DNSSEC key card ·· */
  .key-meta { grid-template-columns: 1fr; }

  /* ·· Toasts ·· */
  .toast-container { bottom: 16px; right: 12px; left: 12px; }
  .toast { min-width: unset; max-width: 100%; }
}

/* ── Small iPhones (≤ 390px) ──────────────────────────────────────────────── */
@media (max-width: 390px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card  { padding: 12px; }
  .stat-value { font-size: 20px; }
  .page-content { padding: 10px; }
  .topbar { padding: 0 10px; }
  .breadcrumb { font-size: 14px; }
}

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes fade-in  { from { opacity: 0; }                            to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(20px);} to { opacity: 1; transform: translateY(0); } }
.animate-fade-in  { animation: fade-in  0.3s ease; }
.animate-slide-up { animation: slide-up 0.35s cubic-bezier(0.4,0,0.2,1); }
