/* ==========================================================================
   Design System & Tokens (Dark Glassmorphism + Neon Emerald)
   ========================================================================== */
:root {
  --bg-main: #0a0e17;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-input: rgba(15, 23, 42, 0.8);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(16, 185, 129, 0.4);
  --border-cyan: rgba(6, 182, 212, 0.4);

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

  --accent-emerald: #10b981;
  --accent-wa-green: #25d366;
  --accent-cyan: #06b6d4;
  --accent-red: #ef4444;

  --glow-emerald: 0 0 25px rgba(16, 185, 129, 0.25);
  --glow-cyan: 0 0 25px rgba(6, 182, 212, 0.2);

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Ambient Background Glows
   ========================================================================== */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

.glow-1 {
  top: -10%;
  left: -5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #059669 0%, transparent 70%);
}

.glow-2 {
  bottom: -15%;
  right: -5%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #0284c7 0%, transparent 70%);
}

.glow-3 {
  top: 40%;
  left: 45%;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #0f766e 0%, transparent 70%);
  opacity: 0.18;
}

/* ==========================================================================
   Layout & Container
   ========================================================================== */
.app-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  padding: 24px 16px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================================
   Navbar
   ========================================================================== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-wa-green), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-wa-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-normal);
}

.status-pill:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(255, 255, 255, 0.15);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #eab308; /* yellow checking */
}

.status-online .status-dot {
  background-color: var(--accent-wa-green);
  box-shadow: 0 0 8px var(--accent-wa-green);
}

.status-offline .status-dot {
  background-color: var(--accent-red);
}

.status-waking .status-dot {
  background-color: #f97316;
  box-shadow: 0 0 8px #f97316;
  animation: dot-pulse 1.2s infinite ease-in-out;
}

@keyframes dot-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   Glass Panel Card
   ========================================================================== */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
}

.main-card {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero-section {
  text-align: center;
}

.main-heading {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #a7f3d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.sub-heading {
  color: var(--text-secondary);
  font-size: 0.92rem;
  max-width: 520px;
  margin: 0 auto;
}

/* ==========================================================================
   Step Indicator
   ========================================================================== */
.steps-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  gap: 12px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.45;
  transition: var(--transition-normal);
}

.step-item.active {
  opacity: 1;
}

.step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.step-item.active .step-circle {
  background: linear-gradient(135deg, var(--accent-wa-green), var(--accent-cyan));
  color: #042f2e;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(37, 211, 102, 0.4);
}

.step-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.step-item.active .step-label {
  color: #fff;
}

.step-line {
  flex: 1;
  max-width: 45px;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.step-line.active {
  background: var(--accent-wa-green);
  box-shadow: 0 0 8px rgba(37, 211, 102, 0.5);
}

/* ==========================================================================
   Drop Zone & Image Upload
   ========================================================================== */
.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  background: rgba(15, 23, 42, 0.4);
  cursor: pointer;
  transition: var(--transition-normal);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent-wa-green);
  background: rgba(16, 185, 129, 0.05);
  box-shadow: var(--glow-emerald);
}

.upload-icon-bubble {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent-wa-green);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.upload-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.upload-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.browse-link {
  color: var(--accent-cyan);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.format-tags {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.tag-highlight {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-wa-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Image Preview inside Dropzone */
.preview-container {
  position: relative;
  display: inline-block;
  max-height: 280px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.preview-container img {
  display: block;
  max-height: 280px;
  max-width: 100%;
  object-fit: contain;
}

.preview-guide-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
}

.overlay-badge {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  color: var(--accent-wa-green);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(37, 211, 102, 0.4);
}

.preview-info {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.file-details {
  text-align: left;
}

.file-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.file-dim {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Method Selector (Tabs)
   ========================================================================== */
.method-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.selector-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.tab-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
}

.tab-btn:hover {
  background: rgba(30, 41, 59, 0.7);
  color: #fff;
}

.tab-btn.active {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--accent-wa-green);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 15px rgba(37, 211, 102, 0.15);
}

.phone-input-group {
  margin-top: 6px;
}

.phone-input-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-with-prefix {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: var(--transition-fast);
}

.input-with-prefix:focus-within {
  border-color: var(--accent-wa-green);
  box-shadow: var(--glow-emerald);
}

.phone-prefix {
  color: var(--accent-wa-green);
  font-weight: 700;
  margin-right: 6px;
}

.input-with-prefix input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  padding: 10px 0;
  font-size: 0.95rem;
  font-family: monospace;
}

.input-help {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.action-row {
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent-wa-green) 0%, #059669 100%);
  color: #03231c;
  font-family: var(--font-heading);
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
  transition: var(--transition-normal);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(37, 211, 102, 0.45);
}

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

.btn-secondary {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger-outline {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-top: 10px;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fff;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* ==========================================================================
   VIEW 2: QR Scanner Box & Animation
   ========================================================================== */
.scan-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.qr-frame {
  position: relative;
  width: 260px;
  height: 260px;
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.2);
  overflow: hidden;
}

.qr-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Glowing laser scanner animation line */
.laser-scanner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #25d366, #06b6d4, transparent);
  box-shadow: 0 0 12px #25d366, 0 0 20px #06b6d4;
  animation: scanLaser 2.4s ease-in-out infinite alternate;
  z-index: 5;
}

@keyframes scanLaser {
  0% {
    top: 5%;
  }
  100% {
    top: 92%;
  }
}

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: #0f172a;
}

.ring-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(16, 185, 129, 0.2);
  border-top-color: var(--accent-wa-green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.spinner-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.scan-instructions {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 420px;
}

.scan-instructions strong {
  color: #fff;
}

/* Pairing Code View */
.pairing-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

.pairing-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.code-display {
  font-family: monospace;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--accent-wa-green);
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(37, 211, 102, 0.3);
  margin-bottom: 14px;
}

/* Status Log Card */
.status-log-card {
  width: 100%;
  max-width: 460px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.log-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulsing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-wa-green);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(37, 211, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
  }
}

.log-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.log-message {
  font-size: 0.9rem;
  color: #fff;
  font-weight: 500;
}

/* ==========================================================================
   VIEW 3: Success Box
   ========================================================================== */
.success-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  padding: 15px 0;
}

.success-checkmark {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  border: 2px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.success-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}

.success-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 480px;
}

.security-guarantee-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  max-width: 480px;
}

.shield-icon {
  margin-top: 2px;
}

.shield-text h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: #a7f3d0;
  margin-bottom: 4px;
}

.shield-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   Modal Settings
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: #fff;
}

.modal-info {
  font-size: 0.86rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent-wa-green);
  box-shadow: var(--glow-emerald);
}

.field-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}

.footer a {
  color: var(--accent-wa-green);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.disclaimer {
  font-size: 0.72rem;
  opacity: 0.7;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive Mobile Adjustments
   ========================================================================== */
@media (max-width: 640px) {
  .main-card {
    padding: 24px 16px;
  }
  
  .main-heading {
    font-size: 1.45rem;
  }

  .qr-frame {
    width: 220px;
    height: 220px;
  }

  .code-display {
    font-size: 1.7rem;
    letter-spacing: 0.15em;
  }
}
