/* =========================================
   HardBlockVPN Modern Design System
   ========================================= */

/* CSS Variables */
:root {
  /* Colors */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --secondary: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Dark theme */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #3b82f6;

  /* Borders */
  --border-color: #334155;
  --border-light: #475569;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'JetBrains Mono', monospace;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(135deg, var(--bg-primary) 0%, #1a202c 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: transform var(--transition);
}

.logo:hover {
  transform: scale(1.02);
}

.logo-img {
  height: 60px;
  width: auto;
  object-fit: contain;
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.main-nav {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all var(--transition);
  font-weight: 500;
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.nav-link i {
  font-size: 1.1rem;
}

.notification-link {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Main Content */
.app-main {
  flex: 1;
  padding: var(--space-xl) var(--space-md);
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

/* Messages */
.messages-container {
  margin-bottom: var(--space-xl);
}

.message {
  background: var(--bg-tertiary);
  border-left: 4px solid var(--primary);
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  animation: slideInRight 0.3s ease;
  box-shadow: var(--shadow);
}

.message-icon {
  color: var(--primary);
  font-size: 1.25rem;
}

.message-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}

.message-close:hover {
  color: var(--text-primary);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.card-title i {
  color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn i {
  font-size: 1rem;
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: var(--warning);
  color: var(--bg-primary);
}

.btn-warning:hover {
  background: #d97706;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Legacy classes for compatibility */
.btn.gray {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn.gray:hover {
  background: var(--border-light);
}

.muted {
  color: var(--text-muted);
}

/* Forms */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.form-input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all var(--transition);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.form-help {
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-error {
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  color: var(--danger);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
}

.badge-primary {
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary-light);
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th {
  background: var(--bg-tertiary);
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Grid layouts */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-sm); }
.p-2 { padding: var(--space-md); }
.p-3 { padding: var(--space-lg); }
.p-4 { padding: var(--space-xl); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }

.hidden { display: none; }
.visible { display: block; }

/* Footer */
.app-footer {
  background: rgba(30, 41, 59, 0.5);
  border-top: 1px solid var(--border-color);
  padding: var(--space-lg);
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-content p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: color var(--transition);
}

.footer-link:hover {
  color: var(--primary);
}

/* Hero sections */
.hero {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-tertiary) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  margin-bottom: var(--space-2xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--success));
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Stats cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all var(--transition);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.stat-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ===== Nodes status cards (Menu/Login) ===== */
.nodes-head{
  margin-top: 14px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.nodes-updated{
  font-size: 12px;
  color: var(--text-muted);
}

.nodes-grid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  text-align: left;
}

.node-card{
  display:block;
  text-decoration:none;
  color:inherit;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,0.03);
  box-shadow: var(--shadow);
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.node-card:hover{
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(255,255,255,0.05);
}

.node-top{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}

.node-name{
  font-weight: 800;
  font-size: 16px;
}

.node-pill{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255,255,255,0.10);
}

.pill-up{ background: rgba(16,185,129,0.12); }
.pill-down{ background: rgba(239,68,68,0.12); }

.dot{
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display:inline-block;
}

.dot-up{ background: var(--success); box-shadow: 0 0 12px rgba(16,185,129,.35); }
.dot-down{ background: var(--danger);  box-shadow: 0 0 12px rgba(239,68,68,.28); }

.node-mid{
  margin-top: 10px;
  display:flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-secondary);
}

.node-tier{ font-weight: 700; color: var(--text-primary); }
.node-speed{ opacity: .9; white-space: nowrap; }

.node-bot{
  margin-top: 10px;
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.node-latency{ white-space: nowrap; opacity: .9; }
.node-hint{ text-align: right; opacity: .85; }

.node-card.up{
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.10) inset, var(--shadow);
}

.node-card.down{
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.12) inset, var(--shadow);
}

.node-skeleton{
  min-height: 110px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.07), rgba(255,255,255,0.03));
  background-size: 200% 100%;
  animation: sk 1.2s infinite;
}

@keyframes sk {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Loading states */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-nav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .nav-link {
    padding: var(--space-sm);
    font-size: 0.875rem;
    flex: 0 0 auto;
  }

  .hero {
    padding: var(--space-lg);
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  /* Mobile button adjustments */
  .flex.gap-2 {
    flex-direction: column;
  }

  .flex.gap-2 > * {
    width: 100%;
  }

  .btn {
    justify-content: center;
    min-height: 48px; /* Touch target size */
  }

  /* Mobile support section */
  .support-contact-card .flex {
    flex-direction: column;
    align-items: flex-start;
  }

  .support-contact-card .btn {
    width: 100%;
    margin-top: var(--space-sm);
  }

  /* Fix button margins on mobile */
  .flex.gap-2 .btn {
    margin: 0;
    width: 100%;
  }

  .flex.gap-2.flex-wrap .btn {
    margin: var(--space-xs) 0;
  }

  /* Prevent horizontal overflow */
  body {
    overflow-x: hidden;
  }

  .app-container {
    overflow-x: hidden;
  }

  .container {
    overflow-x: hidden;
  }
}

@media (max-width: 480px) {
  :root {
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
  }

  .app-main {
    padding: var(--space-sm);
  }

  .card {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }

  .card-header {
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-sm);
  }

  .btn {
    padding: var(--space-sm) var(--space-md);
  }

  .logo-img {
    height: 48px;
    width: auto;
  }

  .logo-text {
    font-size: 1.25rem;
  }

  .main-nav {
    gap: 2px;
  }

  .nav-link {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
  }

  .hero {
    padding: var(--space-md);
  }

  .hero-icon {
    font-size: 2rem;
  }

  .logo-large {
    width: 80px;
    height: 80px;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease;
}

.animate-slide-up {
  animation: slideUp 0.5s ease;
}

.animate-slide-down {
  animation: slideDown 0.5s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection */
::selection {
  background: rgba(59, 130, 246, 0.3);
  color: white;
}

/* Focus outline */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .app-header,
  .app-footer,
  .btn,
  .notification-badge {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}