/* ==========================================================================
   CLOUDY AUTHENTICATION DESIGN SYSTEM (v1.0)
   Feuille de style centralisee pour connexion, inscription, recuperation.
   Zero zoom CSS hack, responsive mobile-first, dark glassmorphism premium.
   ========================================================================== */

:root {
  --cloudy-bg: #040914;
  --cloudy-bg-soft: #07111f;
  --cloudy-card: rgba(10, 16, 32, 0.82);
  --cloudy-card-border: rgba(174, 212, 255, 0.14);
  --cloudy-blue: #0ea5e9;
  --cloudy-blue-glow: rgba(14, 165, 233, 0.35);
  --cloudy-cyan: #38bdf8;
  --cloudy-indigo: #6366f1;
  --cloudy-violet: #8b5cf6;
  --cloudy-green: #22c55e;
  --cloudy-text: #f8fbff;
  --cloudy-muted: #94a3b8;
  --cloudy-surface: rgba(8, 13, 26, 0.86);
  --cloudy-surface-focus: rgba(12, 20, 42, 0.95);
}

/* --- Base Layout & Background (Clean viewport, no zoom hack) --- */
html, body {
  min-height: 100%;
  background-color: var(--cloudy-bg) !important;
  color: var(--cloudy-text) !important;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  overflow-x: hidden;
}

body.cloudy-auth-page {
  background:
    radial-gradient(circle at 18% 12%, rgba(14, 165, 233, 0.18), transparent 36%),
    radial-gradient(circle at 85% 82%, rgba(99, 102, 241, 0.16), transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(34, 197, 94, 0.035), transparent 48%),
    var(--cloudy-bg) !important;
}

/* --- Ambient Glow Blobs --- */
.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

.auth-blob-1 {
  top: -12%;
  left: -10%;
  width: 460px;
  height: 460px;
  background: rgba(14, 165, 233, 0.55);
  animation: authBlobAnim1 14s infinite ease-in-out;
}

.auth-blob-2 {
  bottom: -12%;
  right: -10%;
  width: 480px;
  height: 480px;
  background: rgba(99, 102, 241, 0.45);
  animation: authBlobAnim2 16s infinite ease-in-out;
}

@keyframes authBlobAnim1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(25px, -20px) scale(1.08); }
}

@keyframes authBlobAnim2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-25px, 20px) scale(1.08); }
}

/* --- Auth Glass Card --- */
.auth-card,
.glass-card {
  background: linear-gradient(155deg, rgba(13, 21, 39, 0.90), rgba(6, 12, 24, 0.82)) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid var(--cloudy-card-border) !important;
  border-radius: 24px !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 0 45px rgba(14, 165, 233, 0.08) !important;
  position: relative;
  z-index: 10;
}

.animate-in {
  animation: authFadeInUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

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

/* --- Segmented Navigation Switch (Connexion / Inscription) --- */
.auth-tabs-nav {
  display: flex;
  background: rgba(6, 11, 22, 0.75);
  border: 1px solid rgba(174, 212, 255, 0.12);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 20px;
  position: relative;
  gap: 4px;
}

.auth-tab-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cloudy-muted);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  min-height: 42px;
}

.auth-tab-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.auth-tab-link.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(99, 102, 241, 0.22));
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.2);
}

/* --- Form Fields & Inputs --- */
.ios-input,
.auth-input {
  background: var(--cloudy-surface) !important;
  border: 1px solid rgba(174, 212, 255, 0.14) !important;
  border-radius: 14px !important;
  color: var(--cloudy-text) !important;
  padding: 13px 16px !important;
  min-height: 48px !important;
  width: 100% !important;
  font-size: 14.5px !important;
  transition: all 0.2s ease !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03) !important;
}

.ios-input:focus,
.auth-input:focus {
  background: var(--cloudy-surface-focus) !important;
  border-color: rgba(56, 189, 248, 0.75) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18), 0 8px 24px rgba(14, 165, 233, 0.12) !important;
}

.ios-input[aria-invalid="true"],
.auth-input[aria-invalid="true"] {
  border-color: rgba(239, 68, 68, 0.75) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16) !important;
}

.ios-input.pl-12,
input.ios-input.pl-12,
.auth-input.pl-12 {
  padding-left: 3.25rem !important;
}

.ios-input.pr-12,
input.ios-input.pr-12,
.auth-input.pr-12 {
  padding-right: 3.25rem !important;
}

/* --- Field Icons & Hit Area Alignment --- */
.auth-field-icon {
  position: absolute;
  left: 1.15rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 14.5px;
  transition: color 0.2s ease;
}

.relative:focus-within .auth-field-icon {
  color: var(--cloudy-cyan);
}

.auth-eye-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  border-radius: 10px;
  z-index: 3;
  transition: all 0.2s ease;
  background: transparent;
  border: none;
}

.auth-eye-btn:hover {
  color: #f8fbff;
  background: rgba(255, 255, 255, 0.08);
}

/* --- Buttons --- */
.btn-primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  border-radius: 14px !important;
  font-weight: 700 !important;
  min-height: 48px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100% !important;
  font-size: 15px !important;
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  cursor: pointer !important;
  border: none !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #38bdf8 0%, #1d4ed8 100%) !important;
  box-shadow: 0 16px 36px rgba(14, 165, 233, 0.40), 0 0 24px rgba(56, 189, 248, 0.25) !important;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: scale(0.985);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

.btn-google {
  background: rgba(10, 16, 32, 0.85) !important;
  border: 1px solid rgba(174, 212, 255, 0.16) !important;
  border-radius: 14px !important;
  min-height: 48px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 12px !important;
  width: 100% !important;
  color: #f8fbff !important;
  font-size: 14.5px !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
  cursor: pointer !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
}

.btn-google:hover {
  background: rgba(18, 28, 54, 0.95) !important;
  border-color: rgba(56, 189, 248, 0.4) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  transform: translateY(-1px);
}

.btn-google:active {
  transform: scale(0.985);
}

.btn-google:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

/* --- Smart WhatsApp Madagascar Input Component --- */
.wa-input-group {
  display: flex;
  align-items: stretch;
  background: var(--cloudy-surface);
  border: 1px solid rgba(174, 212, 255, 0.14);
  border-radius: 14px;
  overflow: hidden;
  min-height: 48px;
  transition: all 0.2s ease;
}

.wa-input-group:focus-within {
  background: var(--cloudy-surface-focus);
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18), 0 8px 24px rgba(14, 165, 233, 0.12);
}

.wa-input-group[data-invalid="true"] {
  border-color: rgba(239, 68, 68, 0.75) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16) !important;
}

.wa-prefix {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  background: rgba(14, 165, 233, 0.09);
  border-right: 1px solid rgba(174, 212, 255, 0.12);
  color: #e0f2fe;
  font-size: 13.5px;
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
}

.wa-flag {
  width: 20px;
  height: 14px;
  border-radius: 2px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
  object-fit: cover;
}

.wa-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--cloudy-text) !important;
  padding: 13px 12px !important;
  font-size: 15px !important;
  min-width: 0;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.wa-operator-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 10px;
  align-self: center;
  transition: all 0.2s ease;
}

.wa-operator-telma {
  background: rgba(234, 179, 8, 0.16);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.wa-operator-orange {
  background: rgba(249, 115, 22, 0.16);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.wa-operator-airtel {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* --- Password Strength Meter --- */
.pwd-meter-container {
  margin-top: 8px;
}

.pwd-meter-track {
  display: flex;
  gap: 5px;
  height: 4px;
  border-radius: 99px;
  overflow: hidden;
}

.pwd-meter-segment {
  flex: 1;
  height: 100%;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 99px;
  transition: background-color 0.25s ease;
}

.pwd-meter-segment.weak { background: #ef4444; }
.pwd-meter-segment.medium { background: #f59e0b; }
.pwd-meter-segment.strong { background: #10b981; }

.pwd-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--cloudy-muted);
}

/* --- Alerts & Feedback --- */
.auth-message-box {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.auth-message-box.error {
  background: rgba(239, 68, 68, 0.14) !important;
  color: #fca5a5 !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
}

.auth-message-box.success {
  background: rgba(34, 197, 94, 0.14) !important;
  color: #86efac !important;
  border: 1px solid rgba(34, 197, 94, 0.35) !important;
}

.auth-message-box.info {
  background: rgba(14, 165, 233, 0.14) !important;
  color: #7dd3fc !important;
  border: 1px solid rgba(14, 165, 233, 0.35) !important;
}

/* --- Modal WhatsApp Completion Post-Google --- */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.auth-modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.auth-modal-card {
  background: linear-gradient(155deg, rgba(14, 23, 44, 0.96), rgba(6, 12, 24, 0.96));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 22px;
  max-width: 440px;
  width: 100%;
  padding: 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 35px rgba(14, 165, 233, 0.16);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-modal-backdrop.open .auth-modal-card {
  transform: scale(1);
}

/* --- Zoom reduit de 10% (zoom: 0.9) sur mobile uniquement --- */
@media (max-width: 768px) {
  body.cloudy-auth-page {
    zoom: 0.9 !important;
  }
}

/* --- Responsive Mobile Optimization --- */
@media (max-width: 480px) {
  .auth-card,
  .glass-card {
    padding: 1.25rem !important;
    border-radius: 20px !important;
  }
  .auth-tabs-nav {
    margin-bottom: 16px;
    padding: 3px;
  }
  .auth-tab-link {
    padding: 8px 10px;
    font-size: 12.5px;
    min-height: 38px;
  }
  .ios-input,
  .auth-input,
  .btn-primary,
  .btn-google {
    min-height: 46px !important;
    font-size: 14px !important;
  }
  .wa-prefix {
    padding: 0 10px;
    font-size: 12.5px;
  }
  .wa-input {
    font-size: 14px !important;
    padding: 11px 10px !important;
  }
  .auth-blob {
    filter: blur(65px);
    opacity: 0.22;
  }
}
