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

:root {
  --primary-color: #FF6B35;
  --secondary-color: #004E89;
  --success-color: #2ecc71;
  --error-color: #e74c3c;
  --warning-color: #f39c12;
  --text-dark: #222;
  --text-light: #666;
  --bg-light: #f8f9fa;
  --border-color: #ddd;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

html, body {
  width: 100%;
  height: 100%;
  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;
}

body {
  background: linear-gradient(135deg, var(--secondary-color) 0%, #0a3d62 100%);
  color: var(--text-dark);
  overflow-x: hidden;
}

.portal-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}

/* ============ HEADER ============ */
.header {
  text-align: center;
  padding: 20px 16px;
  color: white;
  background: linear-gradient(135deg, var(--secondary-color) 0%, #0a3d62 100%);
  border-bottom: 3px solid var(--primary-color);
}

.wifika-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tagline {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.95;
  letter-spacing: 0.5px;
}

/* ============ CONTENT ============ */
.portal-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Video Section */
.video-section {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 400px;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #000;
}

.intro-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(0, 78, 137, 0.1) 100%);
  pointer-events: none;
}

/* Audio Section */
.audio-section {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

#playAudio {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
}

.play-icon {
  margin-right: 8px;
  display: inline-block;
}

/* Form Section */
.form-section {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.form-section h2 {
  font-size: 1.4rem;
  color: var(--text-dark);
  margin-bottom: 16px;
  text-align: center;
}

.token-input-group {
  margin-bottom: 16px;
}

.token-input {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  text-transform: uppercase;
}

.token-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.token-input::placeholder {
  color: #999;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: #ff5722;
  box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
  box-shadow: var(--shadow);
}

.btn-secondary:hover {
  background: #003a6d;
  box-shadow: var(--shadow-lg);
}

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 1.05rem;
  min-height: 48px;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 2px solid white;
  animation: spin 0.8s linear infinite;
}

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

/* Packages Section */
.packages-section {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.packages-section h3 {
  font-size: 1.2rem;
  color: var(--text-dark);
  margin-bottom: 16px;
  text-align: center;
}

.packages-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.package {
  background: linear-gradient(135deg, var(--bg-light) 0%, white 100%);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  text-align: center;
  transition: all 0.3s ease;
}

.package:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-color);
}

.package-duration {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.package-speed {
  display: block;
  font-size: 0.85rem;
  color: var(--text-light);
}

/* Messages */
.message-area,
.error-area,
.success-area {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  display: none;
  animation: slideIn 0.3s ease;
}

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

.message-area {
  background: #e3f2fd;
  color: #1976d2;
  border-left: 4px solid #1976d2;
}

.error-area {
  background: #ffebee;
  color: #c62828;
  border-left: 4px solid #c62828;
}

.success-area {
  background: #e8f5e9;
  color: #2e7d32;
  border-left: 4px solid #2e7d32;
}

.message-area.show,
.error-area.show,
.success-area.show {
  display: block;
}

/* Status Section */
.status-section {
  background: #e8f5e9;
  border: 2px solid var(--success-color);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  animation: slideIn 0.3s ease;
}

.status-section h3 {
  color: var(--success-color);
  margin-bottom: 12px;
  text-align: center;
}

.status-info {
  background: white;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.95rem;
}

.status-info p {
  margin: 8px 0;
  display: flex;
  justify-content: space-between;
}

.status-info strong {
  color: var(--text-dark);
}

.status-info span {
  color: var(--primary-color);
  font-weight: 600;
}

/* ============ FOOTER ============ */
.footer {
  text-align: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  font-size: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

/* ============ RESPONSIVE ============ */
@media (min-width: 640px) {
  .portal-content {
    padding: 24px;
    max-width: 600px;
    margin: 0 auto;
  }

  .video-section {
    max-height: 500px;
  }

  .wifika-title {
    font-size: 3rem;
  }

  .packages-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
}

/* ============ DARK MODE ============ */
@media (prefers-color-scheme: dark) {
  :root {
    --text-dark: #f5f5f5;
    --text-light: #aaa;
    --bg-light: #2a2a2a;
  }

  body {
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    color: var(--text-dark);
  }

  .form-section,
  .packages-section,
  .status-section {
    background: #2a2a2a;
    color: var(--text-dark);
    border-color: #444;
  }

  .token-input {
    background: #1a1a1a;
    border-color: #444;
    color: var(--text-dark);
  }

  .token-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2);
  }

  .package {
    background: #1a1a1a;
    border-color: #444;
  }

  .status-info {
    background: #1a1a1a;
  }
}

/* ============ LANDSCAPE MODE ============ */
@media (max-height: 600px) and (orientation: landscape) {
  .header {
    padding: 10px 16px;
  }

  .wifika-title {
    font-size: 1.8rem;
  }

  .tagline {
    display: none;
  }

  .video-section {
    max-height: 250px;
    aspect-ratio: auto;
  }

  .portal-content {
    padding: 12px;
  }

  .form-section,
  .packages-section {
    padding: 12px;
  }

  .form-section h2 {
    font-size: 1.1rem;
    margin-bottom: 10px;
  }
}

/* ============ SAFE AREAS (iPhone Notch) ============ */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .header {
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }

  .footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
