/* ═══════════════════════════════════════════════════════════════════
   WhasaaS — Auth CSS
   Login / Two-Factor pages — WhatsApp-inspired dark premium design
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── CSS Variables ──────────────────────────────────────────────── */
:root {
  --wa-green:        #00A884;
  --wa-green-dark:   #008C70;
  --wa-green-light:  #25D366;
  --wa-green-glow:   rgba(0, 168, 132, 0.25);

  --bg-deep:         #0B141A;
  --bg-panel:        #111B21;
  --bg-card:         #1C2B33;
  --bg-input:        #2A3942;
  --bg-hover:        #2A3942;

  --text-primary:    #E9EDEF;
  --text-secondary:  #8696A0;
  --text-muted:      #667781;

  --border-subtle:   rgba(134, 150, 160, 0.15);
  --border-focus:    rgba(0, 168, 132, 0.6);

  --red:             #FF6B6B;
  --yellow:          #FFB830;
  --blue:            #4FC3F7;

  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       20px;
  --radius-xl:       28px;

  --shadow-card:     0 24px 80px rgba(0, 0, 0, 0.5);
  --shadow-glow:     0 0 40px rgba(0, 168, 132, 0.15);

  --transition:      all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ─── Animated Background ────────────────────────────────────────── */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.auth-bg::before {
  content: '';
  position: absolute;
  width: 900px;
  height: 900px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 168, 132, 0.08) 0%, transparent 70%);
  top: -300px;
  right: -200px;
  animation: pulse-glow 8s ease-in-out infinite alternate;
}

.auth-bg::after {
  content: '';
  position: absolute;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 211, 102, 0.05) 0%, transparent 70%);
  bottom: -200px;
  left: -150px;
  animation: pulse-glow 10s ease-in-out infinite alternate-reverse;
}

/* Patrón de burbujas de chat decorativo */
.auth-bg-pattern {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(0, 168, 132, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(37, 211, 102, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 60% 80%, rgba(0, 168, 132, 0.03) 0%, transparent 45%);
}

@keyframes pulse-glow {
  from { transform: scale(1) translate(0, 0); opacity: 0.6; }
  to   { transform: scale(1.15) translate(20px, -20px); opacity: 1; }
}

/* ─── Auth Layout ────────────────────────────────────────────────── */
.auth-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 1.5rem;
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(32px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ─── Card ───────────────────────────────────────────────────────── */
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  backdrop-filter: blur(20px);
}

/* ─── Logo & Header ──────────────────────────────────────────────── */
.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.auth-logo-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-green) 0%, var(--wa-green-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px rgba(0, 168, 132, 0.4);
  position: relative;
}

.auth-logo-icon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(0, 168, 132, 0.3);
  animation: ring-pulse 2s ease-in-out infinite;
}

@keyframes ring-pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50%       { transform: scale(1.08); opacity: 1; }
}

.auth-logo-icon svg {
  width: 38px;
  height: 38px;
  fill: white;
}

.auth-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.auth-logo p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  text-align: center;
}

/* ─── Flash Messages ─────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

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

.flash--error   { background: rgba(255, 107, 107, 0.12); border: 1px solid rgba(255, 107, 107, 0.3); color: #FF6B6B; }
.flash--success { background: rgba(0, 168, 132, 0.12);   border: 1px solid rgba(0, 168, 132, 0.3);   color: var(--wa-green-light); }
.flash--warning { background: rgba(255, 184, 48, 0.12);  border: 1px solid rgba(255, 184, 48, 0.3);  color: var(--yellow); }

.flash__icon  { font-size: 1rem; flex-shrink: 0; }
.flash__msg   { flex: 1; }
.flash__close { background: none; border: none; color: inherit; cursor: pointer; opacity: 0.7; font-size: 1.1rem; padding: 0; }
.flash__close:hover { opacity: 1; }

/* ─── Form ───────────────────────────────────────────────────────── */
.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.375rem; }

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input-wrap svg {
  position: absolute;
  left: 0.875rem;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition);
  flex-shrink: 0;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus {
  border-color: var(--wa-green);
  background: #243540;
  box-shadow: 0 0 0 3px var(--wa-green-glow);
}

.form-input:focus + svg,
.form-input-wrap:focus-within svg {
  color: var(--wa-green);
}

/* Orden correcto para el icono a la izquierda */
.form-input-wrap .form-input { order: 1; }
.form-input-wrap > svg       { order: 0; }

/* Toggle contraseña */
.btn-toggle-pass {
  position: absolute;
  right: 0.875rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: var(--transition);
}
.btn-toggle-pass:hover { color: var(--text-secondary); }
.btn-toggle-pass svg   { width: 18px; height: 18px; }

/* ─── Código 2FA ─────────────────────────────────────────────────── */
.otp-input-group {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.5rem 0 1rem;
}

.otp-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  caret-color: var(--wa-green);
}

.otp-digit:focus {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px var(--wa-green-glow);
  background: #243540;
}

/* Hidden input real para 2FA (los dígitos son solo UI) */
.otp-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* ─── Submit Button ──────────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--wa-green) 0%, var(--wa-green-light) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 0.5rem;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.25px;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.1) 100%);
  opacity: 0;
  transition: var(--transition);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0, 168, 132, 0.4); }
.btn-primary:hover::before { opacity: 1; }
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Spinner */
.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary.loading .btn-label  { display: none; }
.btn-primary.loading .btn-spinner { display: block; }

/* ─── Google OAuth Button ────────────────────────────────────────── */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  height: 48px;
  background-color: white;
  border: none;
  border-radius: var(--radius-md);
  color: #1E293B;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
  margin-bottom: 0.5rem;
}

.btn-google:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  background-color: #F8FAFC;
}

.btn-google:active {
  transform: translateY(0);
}

.btn-google svg {
  width: 20px;
  height: 20px;
}

/* ─── Divider ────────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ─── Footer Links ───────────────────────────────────────────────── */
.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.auth-footer a {
  color: var(--wa-green);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}
.auth-footer a:hover { color: var(--wa-green-light); text-decoration: underline; }

/* ─── 2FA Info Box ───────────────────────────────────────────────── */
.tfa-info {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(0, 168, 132, 0.08);
  border: 1px solid rgba(0, 168, 132, 0.2);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  margin-bottom: 1.25rem;
}

.tfa-info svg   { width: 20px; height: 20px; color: var(--wa-green); flex-shrink: 0; margin-top: 1px; }
.tfa-info p     { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5; }
.tfa-info small { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 0.25rem; }

/* ─── Version tag ────────────────────────────────────────────────── */
.auth-version {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  body { align-items: flex-start; }

  .auth-wrapper {
    padding: 0;
    max-width: 100%;
    min-height: 100vh;
  }

  .auth-card {
    border-radius: 0;
    min-height: 100vh;
    padding: 2rem 1.5rem;
    border: none;
    box-shadow: none;
  }

  .auth-logo { margin-top: 2rem; margin-bottom: 2rem; }
  .auth-logo h1 { font-size: 1.5rem; }

  .otp-digit { width: 42px; height: 50px; font-size: 1.25rem; }
}

@media (max-width: 360px) {
  .otp-digit { width: 36px; height: 46px; font-size: 1.1rem; }
}
