/* =====================================================================
   admin.css — Panel de administración
   Tema dark compartido con el webmail, ampliado con componentes
   específicos (dashboard, tablas, charts SVG, modales, toasts).
   ===================================================================== */

:root {
  --bg-0: #070b15;
  --bg-1: #0a0e1a;
  --bg-2: #101729;
  --bg-3: #162037;
  --bg-hover: #1a2542;

  --border: #1f2a44;
  --border-strong: #2a375a;

  --text: #e6ecff;
  --text-2: #a7b0c8;
  --text-3: #6b7592;

  --accent: #60a5fa;
  --accent-2: #3b82f6;
  --accent-glow: rgba(96, 165, 250, 0.18);

  --good: #34d399;
  --warn: #fbbf24;
  --bad:  #f87171;
  --info: #818cf8;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
  --shadow: 0 10px 30px rgba(0,0,0,.45);

  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.admin-body {
  background: radial-gradient(1200px 600px at 80% -10%, #17244a33 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 110%, #0b3a6b33 0%, transparent 60%),
              var(--bg-0);
}

#admin-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ========================= SIDEBAR ========================= */
.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: .3px; }
.brand-sub   { font-size: 11px; color: var(--text-3); letter-spacing: .3px; }

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: all .15s ease;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--accent-glow), transparent 80%);
  color: var(--text);
  border-color: var(--border);
  box-shadow: inset 0 0 0 1px #ffffff08;
}
.nav-ico {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 22px; height: 22px;
  color: var(--accent);
  font-size: 15px;
  opacity: .85;
}

.admin-sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.me-email { font-size: 12.5px; color: var(--text); font-weight: 600; word-break: break-all; }
.me-back  { font-size: 11.5px; color: var(--text-3); text-decoration: none; }
.me-back:hover { color: var(--accent); }

/* ========================= MAIN ========================= */
.admin-main { display: flex; flex-direction: column; min-width: 0; }

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(10px);
}
.admin-topbar h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.server-time { font-size: 12px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }

.admin-view { padding: 28px; max-width: 1600px; width: 100%; }

/* ========================= BUTTONS ========================= */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-success {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s ease;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #041021;
  box-shadow: 0 3px 10px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-2); color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-3); border-color: var(--border-strong); }
.btn-ghost {
  background: transparent; color: var(--text-2); border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%); color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); }
.btn-success {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%); color: #fff;
}
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.btn-icon:hover { background: var(--bg-2); color: var(--text); }
.btn-icon.danger:hover { color: var(--bad); border-color: var(--bad); }

/* ========================= CARDS ========================= */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; font-weight: 700; }

/* Dashboard grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  position: relative;
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(140px 80px at 100% 0%, var(--accent-glow), transparent 70%);
  pointer-events: none;
}
.kpi-label { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-sub   { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.kpi.good::before { background: radial-gradient(140px 80px at 100% 0%, #34d39933, transparent 70%); }
.kpi.warn::before { background: radial-gradient(140px 80px at 100% 0%, #fbbf2433, transparent 70%); }
.kpi.bad::before  { background: radial-gradient(140px 80px at 100% 0%, #f8717133, transparent 70%); }

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ========================= TABLES ========================= */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 700;
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--bg-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { font-variant-numeric: tabular-nums; text-align: right; }
table.data .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ========================= FORM CONTROLS ========================= */
.form-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.form-row label { color: var(--text-2); font-size: 13px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { min-height: 80px; resize: vertical; }
.input-inline { display: flex; gap: 8px; }
.input-inline input { flex: 1; }

.search-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.search-bar input { flex: 1; }

/* ========================= BADGES / STATUS ========================= */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  letter-spacing: .3px;
}
.badge.good { background: #10b98122; color: var(--good); border-color: #10b98144; }
.badge.warn { background: #fbbf2422; color: var(--warn); border-color: #fbbf2444; }
.badge.bad  { background: #ef444422; color: var(--bad);  border-color: #ef444444; }
.badge.info { background: #818cf822; color: var(--info); border-color: #818cf844; }

.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.dot.good { background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.bad  { background: var(--bad);  box-shadow: 0 0 8px var(--bad); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

/* ========================= GAUGE BAR (pure CSS) ========================= */
.gauge {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.gauge-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--info) 100%);
  transition: width .4s ease;
}
.gauge-fill.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.gauge-fill.bad  { background: linear-gradient(90deg, #f87171, #dc2626); }
.gauge-value { font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 54px; text-align: right; }

/* ========================= MINI SPARK CHART (SVG) ========================= */
.spark { height: 60px; width: 100%; }

/* ========================= LOG VIEWER ========================= */
.log-viewer {
  background: #05090f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-height: 60vh;
  overflow-y: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: #c6d0f0;
}
.log-viewer .line { white-space: pre-wrap; word-break: break-word; }
.log-viewer .line.postfix { color: #9fd4ff; }
.log-viewer .line.dovecot { color: #c5f3b5; }
.log-viewer .line.rspamd  { color: #f8bfc9; }
.log-viewer .line.error   { color: var(--bad); }

/* ========================= TOASTS ========================= */
.toasts {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 10000; pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 260px; max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease-out;
}
.toast.success { border-left-color: var(--good); }
.toast.error   { border-left-color: var(--bad); }
.toast.warn    { border-left-color: var(--warn); }
.toast .t-title { font-weight: 700; margin-bottom: 2px; }
.toast .t-msg   { color: var(--text-2); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ========================= MODAL ========================= */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(3, 6, 14, 0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  animation: fadeIn .15s ease-out;
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: min(520px, 92vw);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: modalIn .18s ease-out;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-2);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; font-size: 13.5px; color: var(--text-2); }
.modal-body pre { background: var(--bg-0); padding: 10px; border-radius: 6px; overflow-x: auto; font-size: 12px; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--bg-0);
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalIn { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ========================= UTILITIES ========================= */
.row { display: flex; gap: 12px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.mono  { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.text-right { text-align: right; }
.spacer { flex: 1; }
.small  { font-size: 12px; }
.nowrap { white-space: nowrap; }
.break  { word-break: break-all; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Services list */
.svc-list { display: flex; flex-direction: column; gap: 8px; }
.svc-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg-2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.svc-item .svc-name { font-weight: 600; font-size: 13px; }

/* Responsive sidebar */
@media (max-width: 800px) {
  :root { --sidebar-w: 72px; }
  .brand-text, .nav-item span:not(.nav-ico), .admin-sidebar-footer { display: none; }
  .admin-sidebar { padding: 14px 6px; }
  .nav-item { justify-content: center; }
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 10px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty h3 { color: var(--text-2); margin-bottom: 8px; }

/* DNS instructions block */
.dns-table {
  width: 100%;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  border-collapse: collapse;
  margin-top: 10px;
}
.dns-table th, .dns-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left;
  word-break: break-all;
}
.dns-table th { color: var(--text-3); font-size: 11px; text-transform: uppercase; }

/* Steps de creación de dominio */
.steps-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.steps-list .step { padding: 6px 8px; border-radius: 4px; margin-bottom: 4px; font-size: 13px; }
.steps-list .step.ok { background: rgba(76, 175, 80, 0.1); color: #4CAF50; }
.steps-list .step.fail { background: rgba(244, 67, 54, 0.1); color: #F44336; }
.success { color: #4CAF50; padding: 8px 12px; background: rgba(76,175,80,0.08); border-radius: 6px; }
.dns-val { font-size: 11px; word-break: break-all; max-width: 300px; display: inline-block; }
.dns-table code { font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 2px 6px; background: rgba(255,255,255,0.05); border-radius: 3px; }
