/* ParsDNS admin panel — self-contained styles, no external resources. */

@font-face {
  font-family: "Vazirmatn";
  src: url("/assets/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/assets/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/assets/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #eef2f7;
  --bg-grad-1: #4f46e5;
  --bg-grad-2: #06b6d4;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-soft: #64748b;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #121a2b;
    --surface-2: #0e1626;
    --border: #233149;
    --text: #e6edf7;
    --text-soft: #93a4bd;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.hidden { display: none !important; }

/* ---------------- Loading splash ---------------- */
#splash {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 1000;
}
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(99, 102, 241, 0.2); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Login ---------------- */
#login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(6, 182, 212, 0.35), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(79, 70, 229, 0.45), transparent 55%),
    linear-gradient(135deg, var(--bg-grad-1), var(--bg-grad-2));
  background-size: 200% 200%;
  animation: drift 18s ease infinite;
}
@keyframes drift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.login-card {
  width: 100%; max-width: 410px; background: var(--surface);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: 38px 34px 30px; position: relative;
  animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }
.brand .logo {
  width: 76px; height: 76px;
  filter: drop-shadow(0 8px 18px rgba(79, 70, 229, 0.35));
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.brand h1 { margin: 4px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.brand p { margin: 0; color: var(--text-soft); font-size: 13.5px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 7px; font-weight: 500; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap svg { position: absolute; inset-inline-start: 13px; width: 18px; height: 18px; color: var(--text-soft); }
.input-wrap input {
  width: 100%; padding: 13px 42px 13px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
  font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.input-wrap input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: none; border-radius: var(--radius-sm); padding: 13px 18px;
  font-size: 15px; font-weight: 600; color: #fff; width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  transition: transform .1s, box-shadow .2s, opacity .2s;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
}
.btn:hover { box-shadow: 0 10px 26px rgba(79, 70, 229, 0.42); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .65; cursor: progress; }
.login-error {
  background: rgba(239, 68, 68, 0.1); color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 13.5px; margin-bottom: 14px;
}
.login-foot { text-align: center; margin-top: 18px; color: var(--text-soft); font-size: 12px; }

/* ---------------- App shell ---------------- */
#dashboard { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.topbar .logo { width: 34px; height: 34px; }
.topbar .title { font-weight: 700; font-size: 18px; }
.topbar .badge {
  font-size: 11.5px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
  background: rgba(16, 185, 129, .14); color: var(--success);
}
.topbar .badge.warn { background: rgba(245, 158, 11, .16); color: var(--warning); }
.topbar .grow { flex: 1; }
.topbar .user { color: var(--text-soft); font-size: 13.5px; }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; color: var(--text); font-size: 13px; display: inline-flex; gap: 6px; align-items: center;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

.shell { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 232px; background: var(--surface); border-inline-start: 1px solid var(--border);
  padding: 16px 12px; flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 12px;
  color: var(--text-soft); font-size: 14.5px; font-weight: 500; margin-bottom: 4px; transition: .15s;
}
.nav-item svg { width: 19px; height: 19px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 8px 18px rgba(79,70,229,.28); }
.content { flex: 1; padding: 24px; overflow: auto; }
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--text-soft); font-size: 13.5px; margin: 0 0 20px; }

/* ---------------- Cards / stats ---------------- */
.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--text-soft); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 8px; letter-spacing: -0.5px; }
.stat .value small { font-size: 14px; color: var(--text-soft); font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--success); } .dot.blue { background: var(--accent); }
.dot.indigo { background: var(--primary); } .dot.red { background: var(--danger); }
.dot.amber { background: var(--warning); }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

/* ---------------- Tables ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.btn-sm {
  width: auto; padding: 9px 15px; font-size: 13.5px;
  box-shadow: 0 6px 14px rgba(79,70,229,.26);
}
.btn-ghost {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: none;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); box-shadow: none; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: start; color: var(--text-soft); font-weight: 600; font-size: 12.5px;
  padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; direction: ltr; unicode-bidi: plaintext; }
.trunc {
  display: inline-block; max-width: 44ch; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  direction: ltr; unicode-bidi: plaintext; cursor: default;
}
@media (max-width: 1200px) { .trunc { max-width: 30ch; } }
@media (max-width: 760px)  { .trunc { max-width: 16ch; } }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 600; display: inline-block;
}
.tag.upstream { background: rgba(6,182,212,.15); color: #0e7490; }
.tag.local { background: rgba(79,70,229,.15); color: var(--primary); }
.tag.block { background: rgba(239,68,68,.14); color: var(--danger); }
.tag.perm { background: rgba(16,185,129,.15); color: var(--success); }
.tag.temp { background: rgba(245,158,11,.16); color: #b45309; }
.tag.off { background: rgba(100,116,139,.18); color: var(--text-soft); }
.row-actions { display: flex; gap: 6px; }
.row-actions button {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px; color: var(--text-soft);
}
.row-actions button:hover { color: var(--primary); border-color: var(--primary); }
.row-actions button.del:hover { color: var(--danger); border-color: var(--danger); }
.empty { text-align: center; color: var(--text-soft); padding: 36px 10px; }

/* ---------------- Forms / modal ---------------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg); animation: rise .25s cubic-bezier(.16,1,.3,1); max-height: 92vh; overflow: auto;
}
.modal h3 { margin: 0; padding: 20px 22px; border-bottom: 1px solid var(--border); font-size: 17px; }
.modal .body { padding: 20px 22px; }
.modal .foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-start; }
.form-row { margin-bottom: 15px; }
.form-row label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 14.5px;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,.13);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { display: flex; align-items: center; gap: 9px; }
.switch input { width: auto; }
.hint { color: var(--text-soft); font-size: 12px; margin-top: 5px; }

/* ---------------- Toasts ---------------- */
#toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 500; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary);
  border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow-lg); font-size: 13.5px; min-width: 240px;
  animation: rise .2s ease;
}
.toast.ok { border-inline-start-color: var(--success); }
.toast.err { border-inline-start-color: var(--danger); }

/* ---------------- Settings ---------------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.seg button { background: transparent; border: none; padding: 8px 16px; border-radius: 9px; color: var(--text-soft); font-weight: 600; font-size: 13.5px; }
.seg button.active { background: linear-gradient(135deg,var(--primary),var(--accent)); color: #fff; }

/* ---------------- Responsive ---------------- */
@media (max-width: 880px) {
  .two-col, .settings-grid { grid-template-columns: 1fr; }
  .shell { flex-direction: column; }
  .sidebar { width: 100%; display: flex; gap: 6px; overflow-x: auto; padding: 10px; border-inline-start: none; border-bottom: 1px solid var(--border); }
  .nav-item { white-space: nowrap; margin-bottom: 0; }
  .nav-item span.lbl { display: none; }
  .nav-item svg { width: 22px; height: 22px; }
  .content { padding: 16px; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar .user { display: none; }
}
