/* ===========================
   CSS VARIABLES
   =========================== */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-900: #111827;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ===========================
   GLOBAL RESET
   =========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===========================
   RESPONSIVE UTILITIES
   =========================== */
@media (max-width: 767px) {
  .header-nav a {
    font-size: 14px;
    padding: 6px 12px;
  }
}

/* ===========================
   GLOBAL FOOTER
   =========================== */
.global-footer {
  background-color: white;
  border-top: 1px solid var(--gray-200);
  padding: 32px 20px;
  margin-top: auto;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  margin-bottom: 16px;
}

.footer-links a {
  color: var(--gray-600);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-links .separator {
  color: var(--gray-300);
  margin: 0 12px;
}

.footer-copyright {
  color: var(--gray-600);
  font-size: 14px;
}

.footer-copyright p {
  margin: 0;
}

@media (max-width: 767px) {
  .footer-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .footer-links .separator {
    display: none;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--gray-50);
  color: var(--gray-900);
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* ===========================
   LAYOUT
   =========================== */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

@media (min-width: 768px) {
  .container {
    padding: 40px;
  }
}

/* ===========================
   DASHBOARD HEADER
   =========================== */
.header,
.dashboard-header {
  background-color: white;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h2,
.dashboard-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
}

.header-actions {
  display: flex;
  gap: 16px;
}

.header-actions a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.header-actions a:hover {
  text-decoration: underline;
}

/* ===========================
   CARD
   =========================== */
.card {
  background: white;
  border-radius: 8px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-logo {
  display: block;
  margin: 0 auto 24px auto;
  max-width: 250px;
  width: 100%;
  height: auto;
}

@media (min-width: 768px) {
  .card {
    padding: 48px 40px;
  }
  
  .card-logo {
    max-width: 250px;
  }
}

@media (max-width: 767px) {
  .card-logo {
    max-width: 180px;
  }
}

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
  color: var(--gray-900);
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--gray-900);
}

.subtitle {
  text-align: center;
  color: var(--gray-600);
  font-size: 16px;
  margin-bottom: 32px;
}

.subtitle.pricing {
  margin-top: 20px;
  margin-bottom: 24px;
  font-weight: 600;
  font-size: 17px;
  color: var(--primary);
}

/* Feature USPs - Compact Badges */
.features-compact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
  padding: 0 12px;
}

.feature-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--gray-700);
  font-weight: 500;
  white-space: nowrap;
}

.feature-badge .feature-icon {
  font-size: 16px;
  line-height: 1;
}

.feature-badge .feature-text {
  line-height: 1;
}

@media (max-width: 480px) {
  .features-compact {
    flex-direction: column;
    align-items: stretch;
  }
  
  .feature-badge {
    justify-content: center;
  }
}

.info-text {
  text-align: center;
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 32px;
}

.small-text {
  text-align: center;
  font-size: 14px;
  color: var(--gray-600);
  margin-top: 16px;
}

/* ===========================
   FORMS
   =========================== */
form {
  margin-bottom: 16px;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input::placeholder {
  color: var(--gray-600);
}

.session-selector {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-size: 15px;
  background-color: white;
  color: var(--gray-900);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.session-selector:hover {
  border-color: var(--primary-dark);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.session-selector:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea {
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
  background-color: var(--gray-50);
  color: var(--gray-900);
  resize: none;
  overflow-y: auto;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
  width: 100%;
  height: 48px;
  min-height: 44px;
  padding: 0 24px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background-color: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background-color: var(--gray-50);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
  margin-top: 24px;
}

.btn-danger:hover {
  background-color: var(--danger-dark);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Text link */
.text-link {
  display: block;
  text-align: center;
  margin: 16px 0;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.text-link:hover {
  text-decoration: underline;
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 24px;
}

@media (max-width: 767px) {
  .button-group {
    flex-direction: column;
  }
}

/* ===========================
   STATUS & SESSION INFO
   =========================== */
.status-header {
  text-align: center;
  margin-bottom: 32px;
}

.status-header.active {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.status-indicator {
  font-size: 24px;
}

.session-info {
  background-color: var(--gray-50);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.session-info p {
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--gray-900);
}

.session-info p:last-child {
  margin-bottom: 0;
}

.session-info .info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.session-info .info-row label {
  margin-bottom: 0;
}

/* Region Dropdown */
.region-dropdown {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background-color: white;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  cursor: pointer;
  min-width: 150px;
}

.region-dropdown:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Setup Instructions */
.setup-instructions {
  background-color: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 16px;
  margin: 20px 0;
  text-align: center;
}

.setup-title {
  margin-bottom: 12px;
  font-size: 15px;
  color: #92400e;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s;
}

.btn-link:hover {
  background: var(--primary);
  color: white;
}

/* How It Works */
.how-it-works {
  margin-top: 24px;
  text-align: left;
  background-color: var(--gray-50);
  border-radius: 8px;
  padding: 20px;
}

.how-title {
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--gray-900);
}

.how-it-works ol {
  margin: 0;
  padding-left: 20px;
}

.how-it-works li {
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.5;
}

.how-it-works li:last-child {
  margin-bottom: 0;
}

/* WireGuard Setup Screen */
.setup-section {
  margin-bottom: 32px;
  text-align: left;
}

.setup-section h3 {
  margin-top: 0;
  margin-bottom: 16px;
  text-align: center;
}

.download-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.download-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background-color: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  text-decoration: none;
  color: var(--gray-900);
  font-weight: 500;
  transition: all 0.2s;
}

.download-btn:hover {
  background-color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.platform-icon {
  font-size: 28px;
  line-height: 1;
}

.platform-name {
  font-size: 16px;
}

.setup-steps {
  margin: 0;
  padding-left: 20px;
  text-align: left;
}

.setup-steps li {
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--gray-700);
  line-height: 1.6;
}

.setup-steps li:last-child {
  margin-bottom: 0;
}

/* ===========================
   CONFIG DISPLAY
   =========================== */
.config-container {
  margin-bottom: 16px;
}

#config-text {
  height: 200px;
  font-size: 12px;
}

@media (min-width: 768px) {
  #config-text {
    height: 240px;
  }
}

/* ===========================
   USAGE HISTORY
   =========================== */
.usage-summary {
  background-color: var(--gray-50);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.usage-summary p {
  margin-bottom: 8px;
  font-size: 15px;
}

.usage-summary p:last-child {
  margin-bottom: 0;
}

.session-item {
  background-color: var(--gray-50);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.session-item p {
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--gray-600);
}

.session-item p:first-child {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.session-item p:last-child {
  margin-bottom: 0;
}

#sessions-list:empty::after {
  content: 'No sessions yet';
  display: block;
  text-align: center;
  color: var(--gray-600);
  font-style: italic;
  padding: 32px 0;
}

/* ===========================
   ERROR MESSAGES
   =========================== */
.error-message {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

/* ===========================
   FOOTER MESSAGE
   =========================== */
.footer-message {
  text-align: center;
  font-size: 14px;
  color: var(--gray-600);
  margin-top: 24px;
  line-height: 1.5;
}

/* ===========================
   QR CODE MODAL
   =========================== */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background-color: white;
  border-radius: 12px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--gray-900);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 32px;
  font-weight: 300;
  color: var(--gray-600);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--gray-900);
}

#qr-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 20px;
}

.qr-instructions {
  margin-top: 20px;
  padding: 16px;
  background-color: var(--blue-50);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-800);
}

.qr-instructions strong {
  color: var(--blue-600);
}

.qr-note {
  margin-top: 12px;
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.5;
}

.qr-modal-content {
  max-width: 500px;
}

/* Responsive QR modal */
@media (max-width: 480px) {
  .modal-content {
    padding: 24px 16px;
  }
  
  #qr-canvas {
    max-width: 90%;
  }
}

/* ===========================
   ANIMATIONS
   =========================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.3s ease-out;
}

/* ===========================
   USAGE HISTORY PAGE STYLES
   =========================== */
.usage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.usage-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.usage-header .btn-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.summary-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.summary-card h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-card .value {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
}

.monthly-breakdown {
  margin-bottom: 32px;
}

.monthly-breakdown h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.month-card {
  background: white;
  padding: 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: transform 0.2s, box-shadow 0.2s;
}

.month-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.month-card h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 12px;
}

.month-card p {
  font-size: 14px;
  color: var(--gray-600);
  margin: 4px 0;
}

.month-card .month-cost {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 8px;
}

.sessions-section h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.filter-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-controls label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  margin-right: 8px;
}

.filter-controls select {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  color: var(--gray-900);
  background: white;
  cursor: pointer;
}

.sessions-table-container {
  overflow-x: auto;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.sessions-table {
  width: 100%;
  border-collapse: collapse;
}

.sessions-table thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}

.sessions-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sessions-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
  color: var(--gray-900);
}

.sessions-table tbody tr:last-child td {
  border-bottom: none;
}

.sessions-table tbody tr:hover {
  background: var(--gray-50);
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.active {
  background: #dbeafe;
  color: #1e40af;
}

.status-badge.ended {
  background: #d1fae5;
  color: #065f46;
}

.no-sessions {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-600);
}

.no-sessions p {
  font-size: 16px;
  margin-bottom: 24px;
}

@media (max-width: 767px) {
  .usage-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .usage-header .btn-group {
    width: 100%;
    justify-content: stretch;
  }
  
  .usage-header .btn-group .btn {
    flex: 1;
  }
  
  .summary-cards {
    grid-template-columns: 1fr;
  }
  
  .monthly-grid {
    grid-template-columns: 1fr;
  }
  
  .filter-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .sessions-table-container {
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
  }
  
  .sessions-table {
    min-width: 600px;
  }
}
