/* ==========================================================================
   VPN Self-Service — Dark Theme
   ========================================================================== */

:root {
  --bg:             #0a0a0b;
  --bg-subtle:      #0f0f10;
  --surface:        #141416;
  --surface-2:      #1a1a1e;
  --surface-hover:  #222226;
  --border:         #2a2a2e;
  --border-subtle:  #1f1f23;

  --text:           #e8e8ec;
  --text-muted:     #8b8b95;
  --text-faint:     #55555e;

  --accent:         #6366f1;
  --accent-hover:   #7577f5;
  --accent-glow:    rgba(99, 102, 241, 0.15);
  --accent-glow-strong: rgba(99, 102, 241, 0.25);

  --success:        #22c55e;
  --success-bg:     rgba(34, 197, 94, 0.1);
  --error:          #ef4444;
  --error-bg:       rgba(239, 68, 68, 0.1);

  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-full:    9999px;

  --font-body:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:      'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;

  --transition:     200ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
}

.view {
  display: none;
  min-height: 100dvh;
  align-items: center;
}

.view.active {
  display: flex;
}

.centered {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
}

.card-narrow {
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.card-wide {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 20px;
}

.card-header {
  text-align: center;
  margin-bottom: 28px;
}

.card-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 16px;
  color: var(--text);
}

.card-header p {
  margin-top: 6px;
  font-size: 14px;
}

.card-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

/* ==========================================================================
   Icon circles
   ========================================================================== */

.icon-circle {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-primary {
  background: var(--accent-glow);
  color: var(--accent);
}

.icon-success {
  background: var(--success-bg);
  color: var(--success);
}

.icon-error {
  background: var(--error-bg);
  color: var(--error);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input::placeholder {
  color: var(--text-faint);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  padding: 13px 24px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow-strong);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-outline {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
}

.btn-outline:hover {
  background: var(--surface-hover);
  border-color: var(--text-faint);
}

.btn-sm {
  font-size: 13px;
  padding: 7px 14px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ==========================================================================
   Spinner
   ========================================================================== */

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Subscription block
   ========================================================================== */

.subscription-block {
  margin-bottom: 24px;
}

.subscription-block label {
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.subscription-url {
  flex: 1;
  display: block;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  word-break: break-all;
  overflow-wrap: break-word;
}

.copy-toast {
  font-size: 12px;
  color: var(--success);
  margin-top: 6px;
  transition: opacity var(--transition);
}

/* ==========================================================================
   QR Code
   ========================================================================== */

.qr-block {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#qr-container {
  border-radius: var(--radius-md);
  background: #fff;
  padding: 12px;
  display: inline-block;
  line-height: 0;
}

#qr-container img,
#qr-container canvas {
  display: block;
  max-width: 200px;
  width: 100%;
  height: auto;
}

/* ==========================================================================
   Instructions
   ========================================================================== */

.instructions-card h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.instruction-intro {
  font-size: 14px;
  margin-top: 4px;
  margin-bottom: 20px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-num {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-full);
}

.step p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.step strong {
  color: var(--text);
  font-weight: 600;
}

.step code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.step .btn {
  margin-top: 8px;
}

/* ==========================================================================
   Utility classes
   ========================================================================== */

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-xs    { font-size: 12px; }
.text-sm    { font-size: 13px; }
.hidden     { display: none !important; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 480px) {
  .card {
    padding: 24px 20px;
    border-radius: var(--radius-md);
  }

  .card-header h1 {
    font-size: 20px;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .tab {
    flex: 1 1 calc(50% - 2px);
  }

  .container {
    padding: 16px 12px;
  }
}

/* ==========================================================================
   Subtle background glow
   ========================================================================== */

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 30%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}
