/**
 * auth.css — Panel de autenticación slide-in
 * Pilates Integral Chile
 */

/* ─── Backdrop glassmorphism ──────────────────────────────── */
.auth-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(35, 32, 32, 0.55);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s var(--ease-out), visibility 0.5s;
}
.auth-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* ─── Panel principal ─────────────────────────────────────── */
.auth-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(480px, 100vw);
    height: 100dvh;
    z-index: 1101;
    background: var(--white);
    padding: 2.5rem 2.5rem 2rem;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.55s var(--ease-out);
    display: flex;
    flex-direction: column;
    gap: 0;
    box-shadow: -20px 0 80px -20px rgba(35,32,32,0.25);
}
.auth-panel.active { transform: translateX(0); }

/* Scrollbar sutil */
.auth-panel::-webkit-scrollbar { width: 4px; }
.auth-panel::-webkit-scrollbar-track { background: transparent; }
.auth-panel::-webkit-scrollbar-thumb { background: var(--nude); border-radius: 4px; }

/* ─── Cerrar ──────────────────────────────────────────────── */
.auth-panel__close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 38px; height: 38px;
    border: none;
    background: var(--nude-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--charcoal);
    transition: all 0.3s var(--ease-out);
}
.auth-panel__close svg { width: 18px; height: 18px; }
.auth-panel__close:hover {
    background: var(--rose);
    color: var(--white);
    transform: rotate(90deg);
}

/* ─── Header marca ────────────────────────────────────────── */
.auth-panel__header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--nude);
}
.auth-panel__logo {
    height: 38px; width: auto;
    filter: brightness(0) saturate(100%) invert(63%) sepia(18%)
            saturate(760%) hue-rotate(158deg) brightness(90%) contrast(88%);
}
.auth-panel__brand {
    display: flex; flex-direction: column; line-height: 1.1;
}
.auth-panel__brand-name {
    font-family: var(--font-display);
    font-size: 1.15rem; font-weight: 500;
    color: var(--ink);
}
.auth-panel__brand-sub {
    font-family: var(--font-sans);
    font-size: 0.6rem; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--rose-deep);
    margin-top: 2px;
}

/* ─── Títulos del estado ──────────────────────────────────── */
.auth-panel__title {
    font-family: var(--font-display);
    font-size: 1.9rem; font-weight: 400;
    color: var(--ink); margin-bottom: 0.4rem;
    line-height: 1.15;
}
.auth-panel__subtitle {
    font-family: var(--font-sans);
    font-size: 0.95rem; color: var(--charcoal);
    opacity: 0.65; margin-bottom: 1.8rem;
    line-height: 1.5;
}

/* ─── Alertas ─────────────────────────────────────────────── */
.auth-alert {
    display: none;
    padding: 0.9rem 1.2rem;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.2rem;
}
.auth-alert.error {
    display: block;
    background: #fef0f0;
    color: #c0392b;
    border-left: 3px solid #e74c3c;
}
.auth-alert.success {
    display: block;
    background: #f0f9f4;
    color: #1e7e50;
    border-left: 3px solid #2ecc71;
}

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

.auth-field { display: flex; flex-direction: column; gap: 0.45rem; }
.auth-field label {
    font-family: var(--font-sans);
    font-size: 0.88rem; font-weight: 500;
    color: var(--charcoal);
    display: flex; align-items: center; justify-content: space-between;
}
.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="tel"] {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--nude);
    border-radius: 6px;
    background: var(--nude-light);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--charcoal);
    transition: all 0.3s var(--ease-out);
    outline: none;
}
.auth-field input:focus {
    border-color: var(--rose);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(111,167,194,0.15);
}
.auth-field input.invalid {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

/* Fila de campos (nombre + apellido) */
.auth-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Input con ojo */
.auth-input-wrap {
    position: relative;
    display: flex; align-items: center;
}
.auth-input-wrap input { padding-right: 3rem; }
.auth-eye {
    position: absolute; right: 0.8rem;
    background: none; border: none;
    color: var(--charcoal); opacity: 0.5;
    cursor: pointer;
    display: flex; align-items: center;
    transition: opacity 0.2s ease;
    padding: 0;
}
.auth-eye svg { width: 18px; height: 18px; }
.auth-eye:hover { opacity: 1; }

/* "Olvidé contraseña" inline */
.auth-forgot {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--rose-deep);
    background: none; border: none;
    cursor: pointer; padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}
.auth-forgot:hover { color: var(--rose); }

/* Recordarme */
.auth-remember {
    display: flex; align-items: center; gap: 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.88rem; color: var(--charcoal);
    opacity: 0.8; cursor: pointer;
    user-select: none;
}
.auth-remember input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--rose);
    cursor: pointer;
}

/* Selector tipo de usuario */
.auth-tipo {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem;
}
.auth-tipo__option {
    cursor: pointer;
    display: block;
}
.auth-tipo__option input[type="radio"] { display: none; }
.auth-tipo__option span {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.5rem; padding: 1rem 0.8rem;
    border: 1.5px solid var(--nude);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.82rem; font-weight: 500;
    color: var(--charcoal); opacity: 0.7;
    text-align: center; line-height: 1.3;
    transition: all 0.25s var(--ease-out);
    background: var(--nude-light);
}
.auth-tipo__option span svg {
    width: 24px; height: 24px;
    stroke: var(--rose);
}
.auth-tipo__option input:checked + span {
    border-color: var(--rose);
    background: rgba(111,167,194,0.08);
    color: var(--rose-deep); opacity: 1;
    box-shadow: 0 0 0 3px rgba(111,167,194,0.12);
}

/* Indicador de fortaleza de contraseña */
.auth-strength {
    height: 3px; border-radius: 2px;
    background: var(--nude);
    margin-top: 0.4rem; overflow: hidden;
}
.auth-strength__bar {
    height: 100%; width: 0%;
    border-radius: 2px;
    transition: width 0.4s var(--ease-out), background 0.4s ease;
}

/* ─── Botón submit ────────────────────────────────────────── */
.auth-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--ink);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 1rem; font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.8rem;
    transition: all 0.35s var(--ease-out);
    margin-top: 0.5rem;
    position: relative; overflow: hidden;
}
.auth-btn:hover {
    background: var(--rose);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -8px var(--glow);
}
.auth-btn__spinner {
    width: 20px; height: 20px;
    display: none;
    animation: authSpin 0.8s linear infinite;
}
.auth-btn.loading span { opacity: 0.6; }
.auth-btn.loading .auth-btn__spinner { display: block; }

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

/* ─── Switch entre estados ────────────────────────────────── */
.auth-switch {
    text-align: center;
    font-size: 0.9rem;
    color: var(--charcoal); opacity: 0.7;
    margin-top: 1.5rem;
}
.auth-switch button {
    color: var(--rose-deep);
    background: none; border: none;
    cursor: pointer; font-size: 0.9rem;
    font-weight: 600; text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}
.auth-switch button:hover { color: var(--rose); }

/* Botón volver */
.auth-back {
    display: flex; align-items: center; gap: 0.4rem;
    background: none; border: none;
    color: var(--rose-deep); font-family: var(--font-sans);
    font-size: 0.88rem; font-weight: 500;
    cursor: pointer; padding: 0;
    margin-bottom: 1.5rem;
    transition: gap 0.3s var(--ease-out), color 0.2s ease;
}
.auth-back svg { width: 16px; height: 16px; }
.auth-back:hover { gap: 0.7rem; color: var(--rose); }

/* ─── Transición entre estados ────────────────────────────── */
.auth-state { width: 100%; }
.auth-state--hidden {
    display: none;
    opacity: 0;
    transform: translateX(20px);
}
.auth-state.auth-state--entering {
    display: flex;
    flex-direction: column;
    animation: authSlideIn 0.4s var(--ease-out) forwards;
}
@keyframes authSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 520px) {
    .auth-panel { padding: 2rem 1.5rem; }
    .auth-field-row { grid-template-columns: 1fr; }
    .auth-tipo { grid-template-columns: 1fr 1fr; }
}
