/* ============================================================
   Mail Admin – Application Stylesheet
   Design: dark sidebar + light content, card-based layout
   ============================================================ */

:root {
  --sidebar-bg:    #1e293b;
  --sidebar-hover: #334155;
  --sidebar-text:  #94a3b8;
  --sidebar-active:#e2e8f0;
  --sidebar-accent:#3b82f6;
  --sidebar-w:     260px;

  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --text:     #0f172a;
  --muted:    #64748b;

  --primary:  #2563eb;
  --primary-h:#1d4ed8;
  --danger:   #dc2626;
  --danger-h: #b91c1c;
  --success:  #16a34a;
  --warning:  #d97706;
  --info:     #0891b2;

  --radius:   8px;
  --radius-lg:12px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  line-height: 1.6;
}

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

/* ── Layout ─────────────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--sidebar-accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sidebar-brand-name { color: #fff; font-size: .95rem; font-weight: 600; }
.sidebar-brand-sub  { color: var(--sidebar-text); font-size: .72rem; }

.sidebar-section {
  padding: 8px 12px 4px;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #475569;
  font-weight: 600;
  margin-top: 8px;
}

.sidebar-nav { padding: 4px 10px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: .875rem;
  transition: background .15s, color .15s;
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-active); text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.15); color: #93c5fd; }
.nav-item .icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.05);
}
.avatar {
  width: 30px; height: 30px;
  background: var(--sidebar-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.user-pill-name { color: #e2e8f0; font-size: .8rem; font-weight: 500; }
.user-pill-role { color: var(--sidebar-text); font-size: .7rem; }

/* ── Main content ─────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-body { padding: 28px; flex: 1; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 1.4rem; font-weight: 700; }
.page-subtitle { font-size: .85rem; color: var(--muted); margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body { padding: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* ── Tables ──────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:hover { background: #f8fafc; }
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }

.btn-primary  { background: var(--primary);  color: #fff; border-color: var(--primary);  }
.btn-primary:hover  { background: var(--primary-h); border-color: var(--primary-h); }
.btn-danger   { background: var(--danger);   color: #fff; border-color: var(--danger);   }
.btn-danger:hover   { background: var(--danger-h); border-color: var(--danger-h); }
.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover  { background: var(--bg); }
.btn-ghost    { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover    { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-xs { padding: 3px 8px; font-size: .75rem; }

/* ── Forms ───────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-hint { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.input-row { display: flex; gap: 8px; }
.input-row .form-control { flex: 1; }
.input-addon {
  padding: 9px 12px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--muted);
  display: flex; align-items: center;
  white-space: nowrap;
}

/* ── Badges / Status ─────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: #f1f5f9; color: #475569; }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.dot-green  { background: #22c55e; }
.dot-yellow { background: #f59e0b; }
.dot-red    { background: #ef4444; }

/* ── Alerts / Flash ──────────────────────────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .875rem;
  margin-bottom: 16px;
}
.alert-success { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.alert-error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert-icon    { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.alert-close   { margin-left: auto; cursor: pointer; opacity: .6; }
.alert-close:hover { opacity: 1; }

/* ── DNS status grid ─────────────────────────────────────── */

.dns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.dns-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.dns-item-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.dns-item-status { font-size: 1.4rem; margin: 4px 0; }
.dns-item.ok    { border-color: #86efac; background: #f0fdf4; }
.dns-item.fail  { border-color: #fca5a5; background: #fef2f2; }
.dns-item.check { border-color: #fcd34d; background: #fffbeb; }

/* ── Code / DNS records ──────────────────────────────────── */

.code-block {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .8rem;
  font-family: var(--mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Modal ───────────────────────────────────────────────── */

.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  max-width: 480px;
  width: 100%;
  margin: 16px;
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 600; font-size: 1rem; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Auth pages ──────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 36px;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 52px; height: 52px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 12px;
}
.auth-title   { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; text-align: center; }
.auth-subtitle { color: var(--muted); font-size: .875rem; text-align: center; }
.auth-footer  { text-align: center; margin-top: 20px; font-size: .85rem; color: var(--muted); }

/* ── Empty state ─────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-body  { font-size: .875rem; margin-bottom: 16px; }

/* ── Misc ─────────────────────────────────────────────────── */

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.text-muted   { color: var(--muted); }
.text-sm      { font-size: .85rem; }
.text-xs      { font-size: .75rem; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.font-mono    { font-family: var(--mono); font-size: .85em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-4  { margin-bottom: 16px; }
.mt-4  { margin-top: 16px; }
.w-full{ width: 100%; }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
