/* ========================================
   IMPORTS
======================================== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap');

/* ========================================
   1. RESET Y CONFIGURACIÓN GLOBAL
======================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========================================
   2. BODY — FONDO CON IMAGEN
======================================== */
body {
    font-family: 'Outfit', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    -webkit-text-size-adjust: 100%;
    position: relative;
    overflow-x: hidden;
    background-color: #1a0005;
}

/* Capa 1: Imagen de fondo */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('https://images.unsplash.com/photo-1607623814075-e51df1bdc82f?w=1920&q=80&auto=format');
    background-size: cover;
    background-position: center 40%;
    z-index: 0;
}

/* Capa 2: Overlay oscuro con tinte rojo */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(10, 0, 0, 0.78) 0%,
        rgba(120, 10, 20, 0.62) 50%,
        rgba(10, 0, 0, 0.72) 100%
    );
    z-index: 0;
}

/* Todo el contenido encima del fondo */
body > * {
    position: relative;
    z-index: 1;
}

/* ========================================
   3. CONTENEDOR PRINCIPAL — TARJETA
======================================== */
.login-page-grid {
    background: #ffffff;
    border-radius: 24px;
    width: 95%;

    /* ── Estado inicial: columna única (formulario) ── */
    max-width: 480px;
    display: grid;
    grid-template-columns: 1fr;

    /* Overflow hidden permite la animación de deslizamiento */
    overflow: hidden;

    /* Sombra dramática sobre el fondo oscuro */
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.08),
        0 8px 24px rgba(0,0,0,0.35),
        0 30px 60px rgba(0,0,0,0.45);

    /* ── TRANSICIÓN: expandir el card ── */
    transition:
        max-width 0.65s cubic-bezier(0.34, 1.30, 0.64, 1),
        grid-template-columns 0.1s ease;
}

/* ── Estado expandido: dos columnas ── */
.login-page-grid.show-sucursales {
    max-width: 940px;
    grid-template-columns: 1fr 1fr;
}

/* ========================================
   4. COLUMNA IZQUIERDA — FORMULARIO
======================================== */
.form-column {
    padding: clamp(28px, 5vw, 52px);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ========================================
   5. HEADER Y LOGO
======================================== */
.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.logo-container {
    text-align: center;
    margin-bottom: 14px;
}

.bull-icon {
    width: clamp(56px, 8vw, 72px);
    height: clamp(56px, 8vw, 72px);
    margin: 0 auto 14px;
    background: linear-gradient(145deg, #dc3545, #a71d2a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
}

.bull-icon img {
    width: 55%;
    height: 55%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.login-header h1 {
    color: #c82333;
    font-size: clamp(1.3rem, 4vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    line-height: 1.1;
}

.login-header p {
    color: #868e96;
    font-size: clamp(0.82rem, 2vw, 0.95rem);
    font-weight: 400;
}

/* ========================================
   6. INDICADOR DE PROGRESO (2 pasos)
======================================== */
.step-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid #e9ecef;
    color: #adb5bd;
    background: #fff;
    transition: all 0.35s ease;
}

.step-dot.active {
    border-color: #dc3545;
    color: #fff;
    background: #dc3545;
    box-shadow: 0 3px 10px rgba(220, 53, 69, 0.3);
}

.step-dot.done {
    border-color: #28a745;
    color: #fff;
    background: #28a745;
}

.step-line {
    flex: 1;
    height: 2px;
    background: #e9ecef;
    border-radius: 2px;
    max-width: 60px;
    position: relative;
    overflow: hidden;
}

.step-line::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: #dc3545;
    border-radius: 2px;
    transition: width 0.6s ease 0.2s;
}

.login-page-grid.show-sucursales .step-line::after {
    width: 100%;
}

/* ========================================
   7. FORMULARIO E INPUTS
======================================== */
.form-group {
    margin-bottom: 16px;
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: 7px;
    color: #dc3545;
    font-weight: 600;
    font-size: clamp(0.82rem, 2vw, 0.9rem);
    letter-spacing: 0.01em;
}

.input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 13px 15px 13px 44px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: clamp(0.9rem, 2vw, 1rem);
    font-family: inherit;
    background: #f8f9fa;
    color: #495057;
    transition: all 0.25s ease;
    outline: none;
    -webkit-appearance: none;
}

.form-input:focus {
    border-color: #dc3545;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.10);
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    transition: color 0.25s ease;
    line-height: 1;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #adb5bd;
    cursor: pointer;
    padding: 5px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: color 0.2s;
}

.toggle-password:hover { color: #dc3545; }

/* ========================================
   8. BOTÓN PRINCIPAL
======================================== */
.login-button {
    width: 100%;
    padding: clamp(13px, 3vw, 15px);
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: clamp(0.95rem, 2.5vw, 1.05rem);
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
    box-shadow: 0 6px 18px rgba(220, 53, 69, 0.25);
    min-height: 48px;
    position: relative;
    overflow: hidden;
}

.login-button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s;
}

.login-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(220, 53, 69, 0.38);
}

.login-button:hover:not(:disabled)::after {
    background: rgba(255,255,255,0.07);
}

.login-button:active:not(:disabled) {
    transform: translateY(0);
}

.login-button:disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.forgot-password-link {
    color: #868e96;
    text-decoration: none;
    font-size: clamp(0.78rem, 2vw, 0.87rem);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 12px;
    transition: color 0.2s;
    font-weight: 500;
}

.forgot-password-link:hover {
    color: #dc3545;
    text-decoration: underline;
}

.error-msg {
    color: #dc3545;
    font-weight: 600;
    text-align: center;
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(220, 53, 69, 0.08);
    border-radius: 8px;
    font-size: clamp(0.78rem, 2vw, 0.87rem);
}

/* ========================================
   9. COLUMNA DERECHA — SUCURSALES
      Empieza colapsada, se despliega
======================================== */
.sucursal-column {
    background: #f8f9fa;
    border-left: 1.5px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;

    /* ── Estado inicial: invisible y sin ancho ── */
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0;
    transform: translateX(20px);

    transition:
        max-width   0.65s cubic-bezier(0.34, 1.30, 0.64, 1),
        opacity     0.45s ease 0.15s,
        transform   0.50s ease 0.10s,
        padding     0.50s ease;
}

/* ── Cuando el grid tiene la clase activa ── */
.login-page-grid.show-sucursales .sucursal-column {
    max-width: 600px;
    opacity: 1;
    transform: translateX(0);
    padding: clamp(24px, 4vw, 44px) clamp(20px, 3.5vw, 36px);
}

/* ========================================
   10. TÍTULOS DE SECCIÓN (SUCURSALES)
======================================== */
.column-title {
    color: #dc3545;
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.column-subtitle {
    color: #868e96;
    font-size: clamp(0.78rem, 1.8vw, 0.9rem);
    margin-bottom: 18px;
}

/* ========================================
   11. LISTA DE SUCURSALES
======================================== */
.search-group { margin-bottom: 12px; }

.sucursal-list-container {
    max-height: 340px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #dc3545 #f1f1f1;
}

.sucursal-list-container::-webkit-scrollbar { width: 5px; }
.sucursal-list-container::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.sucursal-list-container::-webkit-scrollbar-thumb { background: #dc3545; border-radius: 4px; }

/* Animación stagger para las cards de sucursal */
.sucursal-card {
    display: flex;
    align-items: center;
    padding: clamp(11px, 2vw, 14px);
    background: #fff;
    border: 2px solid #f1f3f5;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.22s ease;
    width: 100%;
    font-family: inherit;
    -webkit-appearance: none;
    min-height: 58px;

    /* Animación de entrada */
    animation: cardSlideIn 0.4s ease both;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Delay escalonado para cada card */
.sucursal-card:nth-child(1) { animation-delay: 0.20s; }
.sucursal-card:nth-child(2) { animation-delay: 0.28s; }
.sucursal-card:nth-child(3) { animation-delay: 0.36s; }
.sucursal-card:nth-child(4) { animation-delay: 0.44s; }
.sucursal-card:nth-child(5) { animation-delay: 0.52s; }

.sucursal-card:hover:not(.is-selected) {
    border-color: #dc3545;
    background: #fff8f8;
    transform: translateX(5px);
    box-shadow: -3px 0 0 #dc3545;
}

.sucursal-card.is-selected {
    background: linear-gradient(135deg, #dc3545, #c82333);
    border-color: #dc3545;
    color: #fff;
    box-shadow: 0 6px 18px rgba(220, 53, 69, 0.28);
}

.sucursal-icon {
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    margin-right: clamp(10px, 2vw, 14px);
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(38px, 7vw, 44px);
    height: clamp(38px, 7vw, 44px);
    background: #f8f9fa;
    border-radius: 10px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.sucursal-card.is-selected .sucursal-icon {
    background: rgba(255,255,255,0.2);
}

.sucursal-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.sucursal-name {
    font-size: clamp(0.88rem, 2vw, 0.97rem);
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sucursal-location {
    font-size: clamp(0.72rem, 1.8vw, 0.82rem);
    color: #868e96;
}

.sucursal-card.is-selected .sucursal-location {
    color: rgba(255,255,255,0.8);
}

.selection-indicator {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    margin-left: 8px;
    display: none;
    flex-shrink: 0;
}

.sucursal-card.is-selected .selection-indicator {
    display: block;
}

.list-status {
    text-align: center;
    color: #adb5bd;
    padding: 20px;
    font-style: italic;
    font-size: 0.88rem;
}

/* ========================================
   12. ANIMACIÓN SHAKE
======================================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.shake { animation: shake 0.5s ease-in-out; }

/* ========================================
   13. RESPONSIVE — MÓVIL (< 768px)
======================================== */
@media (max-width: 767px) {

    .login-page-grid {
        max-width: 440px;
        /* En móvil: columna única siempre */
        grid-template-columns: 1fr !important;
    }

    /* En móvil el panel de sucursales se despliega ABAJO */
    .login-page-grid.show-sucursales {
        max-width: 440px;
    }

    .sucursal-column {
        /* Reset: en móvil usa max-height en lugar de max-width */
        max-width: unset !important;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        padding: 0 clamp(20px, 5vw, 30px);
        transform: translateY(-10px);
        border-left: none;
        border-top: 1.5px solid #f0f0f0;

        transition:
            max-height 0.65s cubic-bezier(0.34, 1.10, 0.64, 1),
            opacity    0.40s ease 0.15s,
            transform  0.45s ease 0.10s,
            padding    0.45s ease;
    }

    .login-page-grid.show-sucursales .sucursal-column {
        max-height: 520px;
        opacity: 1;
        transform: translateY(0);
        padding: 24px clamp(20px, 5vw, 30px) 28px;
    }
}

/* ========================================
   14. RESPONSIVE — TABLET (768px - 1023px)
======================================== */
@media (min-width: 768px) and (max-width: 1023px) {
    .login-page-grid.show-sucursales {
        max-width: 780px;
    }
}

/* ========================================
   15. UTILIDADES
======================================== */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.sucursal-info small { display: none !important; }

/* ========================================
   16. MODALES
======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal[style*="display: flex"] { opacity: 1; }

.modal-content {
    background: #fff;
    padding: clamp(24px, 4vw, 32px);
    border-radius: 20px;
    width: 90%;
    max-width: 440px;
    text-align: center;
    position: relative;
    box-shadow: 0 30px 60px rgba(0,0,0,0.35);
    transform: scale(0.92) translateY(10px);
    transition: transform 0.35s cubic-bezier(0.34, 1.30, 0.64, 1);
    color: #333;
}

.modal[style*="display: flex"] .modal-content {
    transform: scale(1) translateY(0);
}

.modal-icon {
    font-size: clamp(2.4rem, 6vw, 2.8rem);
    margin-bottom: 12px;
    display: block;
}

.modal-title {
    color: #dc3545;
    font-size: clamp(1.2rem, 3vw, 1.45rem);
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-message {
    color: #666;
    margin-bottom: 22px;
    line-height: 1.55;
    font-size: clamp(0.88rem, 2vw, 0.97rem);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-button {
    padding: clamp(10px, 2vw, 12px) clamp(18px, 3vw, 24px);
    border-radius: 10px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: clamp(0.83rem, 2vw, 0.93rem);
    min-height: 44px;
    flex: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #fff;
    box-shadow: 0 4px 12px rgba(220,53,69,0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220,53,69,0.35);
}

.btn-secondary {
    background: #f1f3f5;
    color: #495057;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.success-modal .modal-title { color: #28a745; }
.success-modal .btn-primary { background: linear-gradient(135deg, #28a745, #218838); }

@media (max-width: 479px) {
    .modal-content { width: 95%; padding: 20px; }
    .modal-buttons { flex-direction: column; gap: 8px; }
    .modal-button { width: 100%; }
}

/* ========================================
   17. NOTIFICACIONES
======================================== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

/* ========================================
   18. RECUPERACIÓN DE CONTRASEÑA
======================================== */
.recovery-modal-content {
    max-width: 440px;
    width: 95%;
    background: #fff;
    padding: 32px 28px;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.35);
}

.recovery-step {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeSlideIn 0.3s ease-out;
}

.recovery-step.active { display: flex; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.canales-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 18px 0;
}

.canal-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.canal-card:hover {
    border-color: #dc3545;
    background: #fff8f8;
    transform: translateX(5px);
}

.canal-icon { font-size: 22px; }
.canal-tipo { font-weight: 700; color: #333; display: block; font-size: 0.95rem; }
.canal-destino { font-size: 12px; color: #6c757d; font-family: monospace; }

/* OTP */
.otp-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 22px 0;
    align-items: center;
}

.otp-separator {
    font-size: 1.4rem;
    color: #adb5bd;
    margin: 0 2px;
}

.otp-input {
    width: 44px;
    height: 54px;
    font-size: 22px;
    font-weight: 800;
    font-family: inherit;
    text-align: center;
    border: 2px solid #ced4da;
    border-radius: 12px;
    background: #f8f9fa;
    transition: all 0.2s;
    color: #333;
}

.otp-input:focus {
    border-color: #dc3545;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(220,53,69,0.12);
    outline: none;
}

/* Fortaleza de contraseña */
.pass-strength {
    width: 100%;
    height: 5px;
    background: #e9ecef;
    border-radius: 10px;
    margin: 12px 0;
    overflow: hidden;
    position: relative;
}

.strength-fill { height: 100%; width: 0%; transition: width 0.3s ease, background-color 0.3s; }
.strength-weak   { width: 33%;  background: #dc3545; }
.strength-medium { width: 66%;  background: #ffc107; }
.strength-strong { width: 100%; background: #28a745; }

.resend-timer { font-size: 0.85rem; color: #868e96; margin: 10px 0 4px; }
.resend-btn {
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    border-radius: 8px;
    padding: 6px 16px;
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s;
}
.resend-btn:hover { background: #dc3545; color: #fff; }

#forgotPasswordModal[style*="display: flex"] { opacity: 1 !important; }
#forgotPasswordModal[style*="display: flex"] .recovery-modal-content {
    transform: scale(1) translateY(0) !important;
}

/* ========================================
   19. BOTÓN SECUNDARIO
======================================== */
.secondary-button {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 13px 20px;
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    text-align: center;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.97rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.22);
}

.secondary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220, 53, 69, 0.32);
}

@media (max-width: 479px) {
    .otp-input { width: 36px; height: 46px; font-size: 18px; }
    .recovery-modal-content { padding: 24px 18px; }
}