/* ============================================================
   MODALES INDEX
   ============================================================ */

.index-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 180ms ease,
        visibility 180ms ease;
}

/* ============================================================
   MODAL ACTIVA
   ============================================================ */

.index-modal.modal-activa {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ============================================================
   FONDO
   ============================================================ */

.index-modal__backdrop {
    position: absolute;
    inset: 0;

    background: rgba(2, 6, 23, 0.78);

    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* ============================================================
   CAJA
   ============================================================ */

.index-modal__dialog {
    position: relative;
    z-index: 2;

    width: min(100%, 430px);

    background: #ffffff;

    border-radius: 20px;

    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.3),
        0 8px 25px rgba(0, 0, 0, 0.15);

    overflow: hidden;

    transform: translateY(18px) scale(0.96);

    opacity: 0;

    transition:
        transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 180ms ease;
}

.index-modal.modal-activa .index-modal__dialog {
    transform: translateY(0) scale(1);

    opacity: 1;
}

/* ============================================================
   MODALES DE ERROR
   ============================================================ */

.index-modal__dialog--error,
.index-modal__dialog--warning {
    padding: 30px 28px 26px;

    text-align: center;
}

/* ============================================================
   ICONO PRINCIPAL
   ============================================================ */

.index-modal__icon {
    width: 76px;
    height: 76px;

    margin: 0 auto 18px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
}

.index-modal__icon svg {
    width: 38px;
    height: 38px;
}

.index-modal__icon--danger {
    color: #dc2626;
    background: #fee2e2;

    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.06);
}

.index-modal__icon--warning {
    color: #d97706;
    background: #fef3c7;

    box-shadow: 0 0 0 8px rgba(217, 119, 6, 0.06);
}

/* ============================================================
   TITULO
   ============================================================ */

.index-modal__title {
    margin: 0;

    color: #0f172a;

    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 21px;
    font-weight: 700;

    line-height: 1.25;
}

/* ============================================================
   MENSAJE
   ============================================================ */

.index-modal__message {
    margin: 10px 0 24px;

    color: #64748b;

    font-family: Inter, system-ui, sans-serif;

    font-size: 14px;
    line-height: 1.6;
}

/* ============================================================
   BOTONES
   ============================================================ */

.index-modal__button {
    width: 100%;
    min-height: 46px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    border: 0;
    border-radius: 11px;

    padding: 11px 18px;

    font-family: Inter, system-ui, sans-serif;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    transition:
        transform 120ms ease,
        box-shadow 160ms ease,
        filter 160ms ease;
}

.index-modal__button:hover {
    filter: brightness(1.04);
}

.index-modal__button:active {
    transform: scale(0.98);
}

.index-modal__button svg {
    width: 18px;
    height: 18px;
}

.index-modal__button--danger {
    color: #ffffff;
    background: #dc2626;

    box-shadow: 0 5px 14px rgba(220, 38, 38, 0.25);
}

.index-modal__button--warning {
    color: #ffffff;
    background: #d97706;

    box-shadow: 0 5px 14px rgba(217, 119, 6, 0.25);
}

.index-modal__button--primary {
    color: #ffffff;
    background: #10b981;

    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.28);
}

.index-modal__button--primary:hover {
    background: #059669;
}

/* ============================================================
   MODAL 2FA
   ============================================================ */

.index-modal__dialog--2fa {
    width: min(100%, 480px);
}

/* ============================================================
   HEADER 2FA
   ============================================================ */

.index-modal__header {
    position: relative;

    display: flex;
    align-items: center;

    gap: 13px;

    padding: 20px 22px;

    background: linear-gradient(135deg, #0f172a 0%, #102b45 100%);

    color: #ffffff;
}

.index-modal__header-icon {
    width: 45px;
    height: 45px;

    flex: 0 0 45px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 12px;

    background: rgba(16, 185, 129, 0.16);

    color: #34d399;
}

.index-modal__header-icon svg {
    width: 24px;
    height: 24px;
}

.index-modal__header-text {
    min-width: 0;
}

.index-modal__eyebrow {
    display: block;

    margin-bottom: 2px;

    color: #6ee7b7;

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.09em;
}

.index-modal__header .index-modal__title {
    color: #ffffff;

    font-size: 19px;
}

/* ============================================================
   BOTÓN CERRAR
   ============================================================ */

.index-modal__close {
    position: absolute;

    top: 14px;
    right: 14px;

    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 8px;

    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.08);

    cursor: pointer;

    transition:
        background 150ms ease,
        color 150ms ease,
        transform 120ms ease;
}

.index-modal__close:hover {
    color: #ffffff;
    background: rgba(239, 68, 68, 0.85);
}

.index-modal__close:active {
    transform: scale(0.92);
}

.index-modal__close svg {
    width: 15px;
    height: 15px;
}

/* ============================================================
   BODY 2FA
   ============================================================ */

.index-modal__body {
    padding: 24px 24px 22px;
}

/* ============================================================
   MENSAJE DE SEGURIDAD
   ============================================================ */

.index-modal__security-message {
    display: flex;
    align-items: flex-start;

    gap: 12px;

    margin-bottom: 22px;
    padding: 13px;

    border: 1px solid #d1fae5;
    border-radius: 12px;

    background: #ecfdf5;
}

.index-modal__security-icon {
    width: 35px;
    height: 35px;

    flex: 0 0 35px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    color: #059669;
    background: #d1fae5;
}

.index-modal__security-icon svg {
    width: 18px;
    height: 18px;
}

.index-modal__security-message strong {
    display: block;

    margin-bottom: 3px;

    color: #065f46;

    font-size: 13px;
    font-weight: 700;
}

.index-modal__security-message p {
    margin: 0;

    color: #047857;

    font-size: 12px;
    line-height: 1.5;
}

/* ============================================================
   FORMULARIO
   ============================================================ */

.index-modal__form {
    display: flex;
    flex-direction: column;

    gap: 18px;
}

.index-modal__field {
    width: 100%;
}

.index-modal__label {
    display: block;

    margin-bottom: 8px;

    color: #334155;

    font-size: 13px;
    font-weight: 700;
}

/* ============================================================
   INPUT
   ============================================================ */

.index-modal__input-wrapper {
    position: relative;

    display: flex;
    align-items: center;
}

.index-modal__input-icon {
    position: absolute;

    left: 14px;

    width: 18px;
    height: 18px;

    color: #64748b;

    pointer-events: none;
}

.index-modal__input {
    width: 100%;
    height: 52px;

    padding: 0 48px 0 43px;

    border: 1.5px solid #cbd5e1;
    border-radius: 11px;

    outline: none;

    background: #f8fafc;

    color: #0f172a;

    font-family: "IBM Plex Mono", "Courier New", monospace;

    font-size: 21px;
    font-weight: 700;

    letter-spacing: 0.25em;

    text-align: center;

    transition:
        border-color 150ms ease,
        box-shadow 150ms ease,
        background 150ms ease;
}

.index-modal__input::placeholder {
    color: #94a3b8;

    letter-spacing: 0.15em;
}

.index-modal__input:focus {
    border-color: #10b981;

    background: #ffffff;

    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

/* ============================================================
   TOGGLE PASSWORD
   ============================================================ */

.index-modal__toggle-password {
    position: absolute;

    right: 7px;

    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 8px;

    color: #64748b;
    background: transparent;

    cursor: pointer;

    transition:
        color 150ms ease,
        background 150ms ease;
}

.index-modal__toggle-password:hover {
    color: #059669;
    background: #ecfdf5;
}

.index-modal__toggle-password svg {
    width: 18px;
    height: 18px;
}

/* ============================================================
   VALIDACIÓN
   ============================================================ */

.index-modal__invalid {
    display: none;

    align-items: center;
    gap: 6px;

    margin-top: 7px;

    color: #dc2626;

    font-size: 11px;
}

.index-modal__invalid svg {
    width: 14px;
    height: 14px;
}

.index-modal__field.invalid .index-modal__input {
    border-color: #ef4444;

    background: #fffafa;

    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.index-modal__field.invalid .index-modal__invalid {
    display: flex;
}

/* ============================================================
   FOOTER
   ============================================================ */

.index-modal__footer {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 6px;

    padding: 11px 18px;

    border-top: 1px solid #e2e8f0;

    background: #f8fafc;

    color: #64748b;

    font-size: 11px;
}

.index-modal__footer svg {
    width: 13px;
    height: 13px;

    color: #10b981;
}

/* ============================================================
   ESTADO CARGANDO
   ============================================================ */

.index-modal__button.loading {
    pointer-events: none;

    opacity: 0.75;
}

.index-modal__button.loading::after {
    content: "";

    width: 15px;
    height: 15px;

    margin-left: 4px;

    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;

    border-radius: 50%;

    animation: indexModalSpinner 650ms linear infinite;
}

@keyframes indexModalSpinner {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    .index-modal {
        padding: 14px;
    }

    .index-modal__dialog {
        width: 100%;

        border-radius: 17px;
    }

    .index-modal__dialog--error,
    .index-modal__dialog--warning {
        padding: 25px 20px 21px;
    }

    .index-modal__icon {
        width: 68px;
        height: 68px;

        margin-bottom: 15px;
    }

    .index-modal__icon svg {
        width: 33px;
        height: 33px;
    }

    .index-modal__title {
        font-size: 19px;
    }

    .index-modal__message {
        font-size: 13px;
    }

    .index-modal__header {
        padding: 18px 17px;
    }

    .index-modal__body {
        padding: 20px 17px;
    }

    .index-modal__footer {
        padding: 10px;
    }
}

@media (max-width: 380px) {
    .index-modal {
        padding: 10px;
    }

    .index-modal__header-icon {
        width: 40px;
        height: 40px;

        flex-basis: 40px;
    }

    .index-modal__header .index-modal__title {
        font-size: 17px;
    }

    .index-modal__security-message {
        padding: 10px;
    }

    .index-modal__input {
        height: 49px;

        font-size: 19px;
    }
}

/* ============================================================
   REDUCIR ANIMACIONES SI EL USUARIO LO PREFIERE
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .index-modal,
    .index-modal__dialog,
    .index-modal__button,
    .index-modal__close {
        transition: none;
    }
}

/* ============================================================
   CÓDIGO 2FA - 4 CASILLAS
   ============================================================ */

.index-modal__code-container {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 12px;

    width: 100%;

    margin: 4px 0 8px;
}

/* ============================================================
   CASILLA INDIVIDUAL
   ============================================================ */

.index-modal__code-input {
    width: 62px;
    height: 62px;

    padding: 0;

    border: 2px solid #cbd5e1;
    border-radius: 12px;

    outline: none;

    background: #f8fafc;

    color: #0f172a;

    font-family: "IBM Plex Mono", "Courier New", monospace;

    font-size: 27px;
    font-weight: 700;

    line-height: 1;

    text-align: center;

    caret-color: #10b981;

    transition:
        border-color 150ms ease,
        background 150ms ease,
        box-shadow 150ms ease,
        transform 120ms ease;
}

/* ============================================================
   HOVER
   ============================================================ */

.index-modal__code-input:hover {
    border-color: #94a3b8;

    background: #ffffff;
}

/* ============================================================
   FOCUS
   ============================================================ */

.index-modal__code-input:focus {
    border-color: #10b981;

    background: #ffffff;

    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.11);

    transform: translateY(-1px);
}

/* ============================================================
   CASILLA CON DATO
   ============================================================ */

.index-modal__code-input:not(:placeholder-shown) {
    background: #ecfdf5;
}

/* ============================================================
   ERROR
   ============================================================ */

.index-modal__field.invalid .index-modal__code-input {
    border-color: #ef4444;

    background: #fffafa;

    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

/* ============================================================
   ANIMACIÓN AL COMPLETAR
   ============================================================ */

.index-modal__code-input.code-complete {
    animation: codeComplete 160ms ease;
}

@keyframes codeComplete {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }

    100% {
        transform: scale(1);
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 480px) {
    .index-modal__code-container {
        gap: 9px;
    }

    .index-modal__code-input {
        width: 56px;
        height: 58px;

        font-size: 25px;
    }
}

@media (max-width: 380px) {
    .index-modal__code-container {
        gap: 7px;
    }

    .index-modal__code-input {
        width: 50px;
        height: 54px;

        border-radius: 10px;

        font-size: 23px;
    }
}
