/* ========================================
   Home Page - WhatsApp Pairing
   ======================================== */

:root {
  --color-gold: #FFD700;
  --color-gold-dark: #DAA520;
  --color-green: #228B22;
  --color-green-light: #32CD32;
  --color-bg: #F2F4F7;
  --color-bg-gradient: linear-gradient(180deg, #F2F4F7 0%, #E8ECF1 100%);
  --color-surface: rgba(0, 0, 0, 0.03);
  --color-surface-hover: rgba(0, 0, 0, 0.06);
  --color-text: #1a1a2e;
  --color-text-secondary: #5a6070;
  --color-text-muted: #9ca3af;
  --color-border: rgba(0, 0, 0, 0.08);
  --font-primary: 'Poppins', 'Noto Sans', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-glow-gold: 0 0 20px rgba(255, 215, 0, 0.15);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-primary);
  background: var(--color-bg);
  background-image: var(--color-bg-gradient);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ===== App Container ===== */
.app-container { max-width: 420px; margin: 0 auto; padding: 1rem 1rem 2rem; min-height: 100vh; position: relative; }

/* ===== Header ===== */
.app-header { padding: 1.25rem 0 0.5rem; position: relative; }
.header-top-row { display: flex; align-items: flex-start; justify-content: space-between; }
.header-brand { flex: 1; }
.app-title { font-size: 1.65rem; font-weight: 800; color: #005A9C; line-height: 1.15; margin: 0; }
.app-subtitle { font-size: 0.8rem; color: #5a6070; font-weight: 500; margin-top: 0.05rem; letter-spacing: 0.3px; }

/* ===== Globe Switcher ===== */
.globe-switcher { position: relative; flex-shrink: 0; margin-top: 0.25rem; }
.globe-trigger {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--color-border); background: var(--color-surface);
  font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease; backdrop-filter: blur(10px);
}
.globe-trigger:hover { border-color: var(--color-gold); box-shadow: 0 0 12px rgba(255, 215, 0, 0.2); transform: scale(1.08); }
.globe-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 170px;
  background: rgba(20, 20, 40, 0.95); backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 215, 0, 0.15); border-radius: 14px; padding: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.06);
  z-index: 100; animation: dropdown-appear 0.2s ease;
}
@keyframes dropdown-appear { from { opacity: 0; transform: translateY(-6px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.globe-option {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 0.6rem 0.75rem;
  border-radius: 10px; border: none; background: transparent;
  color: var(--color-text-secondary); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.2s ease;
}
.globe-option:hover { background: rgba(255, 255, 255, 0.06); color: var(--color-text); }
.globe-option.active { background: rgba(255, 215, 0, 0.1); color: var(--color-gold); }
.option-flag { font-size: 1.15rem; }
.option-name { flex: 1; text-align: left; }
.option-check { font-size: 0.8rem; color: var(--color-gold); font-weight: 700; }

/* ===== Main Content ===== */
.main-content { margin-top: 1rem; animation: step-fade-in 0.4s ease; }
@keyframes step-fade-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Step Card ===== */
.step-card {
  background: var(--color-surface); backdrop-filter: blur(20px);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 2rem 1.5rem; box-shadow: var(--shadow-card); text-align: center;
}
.step-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--color-text); }

/* ===== Description ===== */
.link-copy { margin-bottom: 2rem; }
.copy-highlight { font-size: 1.15rem; font-weight: 700; color: #D84315; margin-bottom: 0.5rem; line-height: 1.5; }
.copy-sub { font-size: 0.9rem; color: #005A9C; font-weight: 500; }

/* ===== Phone Input ===== */
.phone-input-group { display: flex; gap: 8px; margin-bottom: 1.5rem; width: 100%; }
.phone-prefix-wrap { flex-shrink: 0; position: relative; display: flex; align-items: stretch; }
.prefix-flag-btn { display: flex; align-items: center; gap: 2px; padding: 0 8px; border: 1px solid var(--color-border); border-right: none; border-radius: 12px 0 0 12px; background: var(--color-surface); cursor: pointer; font-size: 1.2rem; line-height: 1; transition: background 0.2s; }
.prefix-flag-btn:hover { background: var(--color-surface-hover); }
.prefix-chevron { font-size: 0.65rem; color: var(--color-text-muted); margin-top: 1px; }
.prefix-field { width: 58px; padding: 0.9rem 0.4rem; border-radius: 0 12px 12px 0; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font-size: 1rem; text-align: center; font-weight: 600; outline: none; }
.prefix-field:focus { border-color: var(--color-gold); }
.prefix-flag-btn:focus-within, .phone-prefix-wrap:focus-within .prefix-flag-btn { border-color: var(--color-gold); }
.prefix-dropdown { position: absolute; top: calc(100% + 4px); left: 0; width: 240px; background: #fff; border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 200; overflow: hidden; }
.prefix-search { width: 100%; padding: 0.6rem 0.8rem; border: none; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; outline: none; background: #fafafa; }
.prefix-list { max-height: 200px; overflow-y: auto; }
.prefix-item { display: flex; align-items: center; gap: 8px; padding: 0.5rem 0.8rem; cursor: pointer; font-size: 0.9rem; transition: background 0.15s; }
.prefix-item:hover { background: var(--color-surface-hover); }
.prefix-item-name { flex: 1; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prefix-item-dial { color: var(--color-text-secondary); font-weight: 600; font-size: 0.85rem; }
.phone-field { flex: 1; min-width: 0; padding: 0.9rem 1rem; border-radius: 12px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font-size: 1rem; outline: none; transition: border-color 0.3s ease, box-shadow 0.3s ease; }
.phone-field:focus { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15); }
.phone-field::placeholder { color: var(--color-text-muted); }

/* ===== Pairing Code ===== */
.pairing-section { margin-bottom: 1.5rem; }
.pairing-label { font-size: 0.85rem; color: var(--color-text-secondary); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.pairing-code { display: flex; justify-content: center; gap: 6px; margin-bottom: 1.25rem; }
.code-char {
  width: 42px; height: 52px; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; font-family: 'Courier New', monospace; color: #1a1a1a;
  background: #f0fdf4; border: 2px solid #4CAF50; border-radius: 10px;
  box-shadow: 0 4px 6px rgba(76, 175, 80, 0.15);
}
.code-char.space { width: 16px; border: none; background: transparent; }

.polling-status { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.85rem; color: var(--color-green); }
.polling-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-green); animation: polling-pulse 1.5s ease-in-out infinite; }
@keyframes polling-pulse { 0%,100%{opacity:0.3;transform:scale(0.8)} 50%{opacity:1;transform:scale(1.2)} }

/* ===== Success Section ===== */
.success-section { margin-bottom: 1.5rem; padding: 1.5rem; background: #f0fdf4; border-radius: 16px; border: 1px solid #bbf7d0; }
.success-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.success-text { font-size: 1.2rem; font-weight: 700; color: #166534; margin-bottom: 0.5rem; }
.success-sub { font-size: 0.9rem; color: #15803d; }

/* ===== Primary Button ===== */
.btn-primary {
  width: 100%; padding: 0.95rem 2rem; border-radius: var(--radius-md); border: none;
  background: linear-gradient(135deg, var(--color-gold), #FFA500); color: #1a1a2e;
  font-size: 1.05rem; font-weight: 700; cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease; box-shadow: var(--shadow-glow-gold);
}
.btn-primary:hover { transform: scale(1.03); box-shadow: 0 0 30px rgba(255, 215, 0, 0.4); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; animation: none; }
.pulse-animation { animation: btn-pulse 2s ease-in-out infinite; }
.pulse-animation:disabled { animation: none; }
@keyframes btn-pulse { 0%,100% { transform: scale(1); box-shadow: var(--shadow-glow-gold); } 50% { transform: scale(1.05); box-shadow: 0 0 35px rgba(255, 215, 0, 0.45); } }

/* ===== Error Message ===== */
.error-msg { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 10px; background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; font-size: 0.9rem; font-weight: 500; text-align: center; }

/* ===== Tutorial ===== */
.tutorial-section { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px dashed var(--color-border); display: flex; flex-direction: column; align-items: center; }
.tutorial-text { font-size: 16px; color: #005A9C; font-weight: 800; margin-bottom: 1rem; text-align: center; }
.tutorial-video-wrapper { position: relative; width: 100%; max-width: 320px; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); background: #e2e8f0; }
.tutorial-gif { width: 100%; height: auto; max-height: 100%; object-fit: contain; display: block; margin: 0 auto; }
.tutorial-gif.fallback-bg { background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app-container { padding: 0.75rem 0.75rem 1.5rem; }
  .step-card { padding: 1.5rem 1rem; }
  .app-title { font-size: 1.3rem; }
}
