/* ============================================================
   Abolita VPN — Glassmorphism stylesheet
   Dark + Light dual theme, RTL/LTR aware, mobile-first.
   ============================================================ */

:root {
  /* Dark theme (default) */
  --bg-1: #0a0e1a;
  --bg-2: #0f1428;
  --fg: #e6e9f2;
  --fg-muted: #97a0c2;
  --glass-bg: rgba(20, 26, 48, 0.45);
  --glass-bg-soft: rgba(28, 36, 64, 0.32);
  --glass-border: rgba(167, 139, 250, 0.22);
  --glass-border-soft: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --glass-halo: 0 0 24px rgba(167, 139, 250, 0.18);
  --accent-1: #a78bfa;       /* violet */
  --accent-2: #22d3ee;       /* cyan   */
  --accent-3: #f472b6;       /* pink   */
  --accent-grad: linear-gradient(135deg, #a78bfa 0%, #22d3ee 100%);
  --danger: #ff6b6b;
  --ok: #4ade80;
  --input-bg: rgba(12, 16, 32, 0.5);
  --input-border: rgba(167, 139, 250, 0.35);
  --input-focus: rgba(34, 211, 238, 0.5);
  --mono-font: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --body-font: 'Vazirmatn', 'Inter', system-ui, sans-serif;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --transition: 0.28s cubic-bezier(0.4, 0.0, 0.2, 1);
}

[data-theme="light"] {
  --bg-1: #e8ecf6;
  --bg-2: #f3f6fd;
  --fg: #1a1f33;
  --fg-muted: #5d6585;
  --glass-bg: rgba(255, 255, 255, 0.42);
  --glass-bg-soft: rgba(255, 255, 255, 0.35);
  --glass-border: rgba(120, 100, 220, 0.22);
  --glass-border-soft: rgba(0, 0, 0, 0.06);
  --glass-shadow: 0 8px 32px rgba(80, 90, 130, 0.12);
  --glass-halo: 0 0 24px rgba(167, 139, 250, 0.18);
  --input-bg: rgba(255, 255, 255, 0.75);
  --input-border: rgba(120, 100, 220, 0.22);
  --input-focus: rgba(34, 211, 238, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  font-family: var(--body-font);
  color: var(--fg);
  background: var(--bg-1);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(ellipse at top, var(--bg-2), var(--bg-1) 60%);
  transition: background var(--transition), color var(--transition);
}

[dir="ltr"] body { font-family: 'Inter', 'Vazirmatn', system-ui, sans-serif; }

/* ============================================================
   Animated background orbs
   ============================================================ */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: floatOrb 20s ease-in-out infinite;
}
.orb-1 { width: 520px; height: 520px; background: #a78bfa; top: -120px; left: -120px; animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; background: #22d3ee; top: 25%; right: -100px; animation-delay: -5s; }
.orb-3 { width: 460px; height: 460px; background: #f472b6; bottom: -140px; left: 25%; animation-delay: -10s; }
.orb-4 { width: 320px; height: 320px; background: #6366f1; top: 50%; left: -80px; animation-delay: -15s; opacity: 0.5; }
.orb-5 { width: 360px; height: 360px; background: #a78bfa; top: 70%; right: 10%; animation-delay: -8s; opacity: 0.35; }
.orb-6 { width: 380px; height: 380px; background: #22d3ee; top: 35%; left: 35%; animation-delay: -3s; opacity: 0.3; }

[data-theme="light"] .orb { opacity: 0.4; filter: blur(110px); }

@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 50px) scale(0.95); }
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   Glass primitive
   ============================================================ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 2;
}

.glass-soft {
  background: var(--glass-bg-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-md);
}

/* ============================================================
   Layout: views
   ============================================================ */
.view {
  width: 100%;
  max-width: 1080px;
  padding: 24px;
  z-index: 2;
  position: relative;
}
.hidden { display: none !important; }

/* ============================================================
   Login
   ============================================================ */
.view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 32px;
  text-align: center;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--glass-bg-soft);
  box-shadow: var(--glass-halo);
}
.brand-text h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p {
  color: var(--fg-muted);
  font-size: 14px;
  margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; text-align: start; }
.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
}
.field input,
.field textarea,
input.mono {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: 15px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field textarea { font-family: var(--mono-font); font-size: 13px; resize: vertical; min-height: 70px; direction: ltr; text-align: left; }
.field input:focus,
.field textarea:focus,
input.mono:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}
input.mono {
  font-family: var(--mono-font);
  font-size: 13px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--fg);
  direction: ltr;
  text-align: left;
  overflow-x: auto;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent-grad);
  color: #0a0e1a;
  box-shadow: 0 6px 20px rgba(167, 139, 250, 0.35);
}
.btn-primary:hover { box-shadow: 0 8px 28px rgba(167, 139, 250, 0.5); transform: translateY(-1px); }
.btn-ghost {
  background: var(--glass-bg-soft);
  color: var(--fg);
  border: 1px solid var(--glass-border);
  font-weight: 600;
}
.btn-ghost:hover {
  background: var(--accent-1);
  color: #0a0e1a;
  border-color: var(--accent-1);
  box-shadow: 0 4px 14px rgba(167, 139, 250, 0.3);
}

/* Light theme: ghost buttons need a darker fill for contrast against white cards */
[data-theme="light"] .btn-ghost {
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.35);
}
[data-theme="light"] .btn-ghost:hover {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.icon-btn:hover {
  background: var(--glass-bg-soft);
  border-color: var(--glass-border-soft);
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  margin-bottom: 24px;
  border-radius: var(--radius-md);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-grad);
  box-shadow: 0 0 12px var(--accent-1);
  animation: pulseDot 2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-sun { display: none; }
.icon-moon { display: inline-block; }
[data-theme="light"] .icon-sun { display: inline-block; }
[data-theme="light"] .icon-moon { display: none; }

/* ============================================================
   Hero card (config + subs)
   ============================================================ */
.hero { margin-bottom: 24px; }
.hero-card { padding: 28px 26px; }
.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.hero-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.host-pill {
  padding: 6px 12px;
  background: var(--glass-bg-soft);
  border: 1px solid var(--glass-border-soft);
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg-muted);
  font-family: var(--mono-font);
}

.row { margin-bottom: 18px; }
.row-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input { flex: 1; }

.row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.sub-card {
  background: var(--glass-bg-soft);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-md);
  padding: 14px;
}
.sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sub-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.sub-card .mono { background: transparent; border: none; padding: 6px 0; font-size: 11px; color: var(--fg-muted); }

/* QR */
.qr-wrap {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.qr-box {
  background: #fff;
  padding: 12px;
  border-radius: var(--radius-md);
  box-shadow: var(--glass-shadow);
  min-width: 200px;
  min-height: 200px;
  display: grid;
  place-items: center;
}
.qr-box canvas, .qr-box img { display: block; width: 180px; height: 180px; }
.qr-cap { font-size: 12px; color: var(--fg-muted); }

/* ============================================================
   Config section
   ============================================================ */
.config {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
.config-card, .info-card { padding: 24px 22px; }
.config-card h3, .info-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 18px;
}
.config-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field.field-wide { grid-column: 1 / -1; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
}
.status-msg { font-size: 13px; color: var(--ok); min-height: 18px; }
.status-msg.error { color: var(--danger); }

.info-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.info-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--glass-border-soft);
}
.info-list span { color: var(--fg-muted); }
.info-list code {
  font-family: var(--mono-font);
  color: var(--accent-2);
  font-size: 12px;
  word-break: break-all;
  text-align: end;
}
.info-note {
  margin-top: 16px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.7;
}
.info-note strong { color: var(--accent-1); display: block; margin-bottom: 4px; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--fg-muted);
  padding: 24px 0;
}

/* ============================================================
   Error / status messages
   ============================================================ */
.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .view { padding: 14px; }
  .topbar { padding: 12px 16px; }
  .hero-card, .config-card, .info-card { padding: 20px 16px; }
  .config { grid-template-columns: 1fr; }
  .config-form { grid-template-columns: 1fr; }
  .row-grid { grid-template-columns: 1fr; }
  .topbar-brand { font-size: 14px; }
  .icon-btn { padding: 6px 10px; font-size: 12px; }
  .brand-text h1 { font-size: 24px; }
  .login-card { padding: 30px 22px; }
}

/* RTL specifics */
[dir="rtl"] .info-list code { text-align: start; }
[dir="rtl"] .copy-row { flex-direction: row; }

/* Loading state */
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
