/* ==============================================================================
   VPN Control Panel: Bespoke Design System & Tokens
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0a0c10;
  --bg-surface: #12151c;
  --bg-surface-hover: #181d26;
  --bg-elevated: #1f2532;
  --border-subtle: #242b38;
  --border-active: #3a455a;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.15);
  --accent-amber: #f59e0b;
  --accent-cobalt: #3b82f6;
  --accent-rose: #f43f5e;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-active);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Pulse Beacon */
.pulse-beacon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-animation 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulse-animation {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(1.2);
  }
}

/* Glass & Border Utilities */
.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.surface-card:hover {
  border-color: var(--border-active);
}

/* Tab Switching */
.nav-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.nav-tab.active {
  color: #ffffff;
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

/* Buttons */
.btn-primary {
  background: var(--accent-cobalt);
  color: #ffffff;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-active);
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-danger {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.18);
  border-color: var(--accent-rose);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-emerald {
  background: var(--accent-emerald-glow);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-cobalt {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-cobalt);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-rose {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Domain Chips */
.domain-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.domain-chip:hover {
  border-color: var(--accent-cobalt);
  background: var(--bg-surface-hover);
}

/* Custom Minimalist Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-active);
  transition: 0.2s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-emerald);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

/* Modal Overlay & Transitions */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(10px) scale(0.98);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-content.connection-center {
  width: min(1200px, calc(100vw - 32px));
  max-width: 1200px;
  max-height: min(900px, calc(100vh - 24px));
}

.connection-scroll {
  max-height: calc(100vh - 210px);
  overflow-y: auto;
  padding-right: 4px;
}

.connection-list {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.connection-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #0a0c10;
}

.connection-option + .connection-option {
  border-top: 1px solid var(--border-subtle);
}

.connection-platform {
  width: 34px;
  color: #7f8ca3;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.connection-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.play-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  color: #7f8ca3;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: color 0.15s ease;
}

.play-link svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.play-link:hover,
.play-link:focus-visible {
  color: #e2e8f0;
}

.android-password-row {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #7f8ca3;
  font-size: 10px;
}

.android-password-row code {
  color: #fbbf24;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.android-password-row button {
  color: #60a5fa;
}

.android-password-row button:hover {
  text-decoration: underline;
}

.play-link:focus-visible {
  outline: 1px solid #60a5fa;
  outline-offset: 3px;
  border-radius: 2px;
}

.connection-config {
  min-width: 0;
  padding: 12px;
  background: #0a0c10;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.connection-code {
  min-width: 0;
  max-height: 132px;
  overflow: auto;
  white-space: pre-wrap;
  padding: 9px;
  color: #c4ccda;
  background: #12151c;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  line-height: 1.5;
}

.connection-qr {
  flex: 0 0 auto;
  padding: 10px;
  background: #f8fafc;
  border-radius: 7px;
}

.connection-qr canvas,
.connection-qr img {
  display: block;
  width: 512px;
  height: 512px;
}

.connection-qr:empty {
  display: none;
}

.connection-advanced {
  padding: 12px;
  background: #0a0c10;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.connection-advanced summary {
  color: #aab4c5;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 640px) {
  .connection-center {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    margin: 8px;
    padding: 18px !important;
  }

  .connection-scroll {
    max-height: calc(100vh - 190px);
  }

  .connection-option {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .connection-option button {
    width: 100%;
    justify-content: center;
  }

  .connection-qr {
    margin: 0 auto;
  }

  .connection-qr canvas,
  .connection-qr img {
    width: min(512px, calc(100vw - 76px));
    height: auto;
  }

  .connection-config > .flex:last-child {
    flex-direction: column;
  }
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slide-in 0.2s ease forwards;
}

@keyframes slide-in {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
