/* ===================================
   AUTH MODAL - Estilos del sistema de autenticación
   =================================== */

/* ===================================
   MODAL PRINCIPAL
   =================================== */

.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.auth-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.auth-modal__container {
    position: relative;
    background: var(--color-white, #ffffff);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.auth-modal.active .auth-modal__container {
    transform: translateY(0);
}

.auth-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--color-gray, #6b7280);
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 10;
}

.auth-modal__close:hover {
    background: var(--color-gray-lighter, #f3f4f6);
    color: var(--color-dark, #1f2937);
}

/* ===================================
   FORMULARIOS
   =================================== */

.auth-modal__form {
    padding: 2rem;
}

.auth-modal__form--hidden {
    display: none;
}

.auth-modal__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-modal__logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--color-primary, #1e3a8a), var(--color-primary-light, #3b82f6));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
}

.auth-modal__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-dark, #1f2937);
    margin-bottom: 0.5rem;
}

.auth-modal__subtitle {
    font-size: 0.9375rem;
    color: var(--color-gray, #6b7280);
}

/* ===================================
   CAMPOS DE FORMULARIO
   =================================== */

.auth-modal__field {
    margin-bottom: 1rem;
}

.auth-modal__field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-dark, #1f2937);
    margin-bottom: 0.375rem;
}

.auth-modal__field input[type="text"],
.auth-modal__field input[type="email"],
.auth-modal__field input[type="password"],
.auth-modal__field input[type="tel"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
}

.auth-modal__field input:focus {
    outline: none;
    border-color: var(--color-primary-light, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.auth-modal__field input::placeholder {
    color: #9ca3af;
}

.auth-modal__hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-gray, #6b7280);
    margin-top: 0.25rem;
}

/* Password wrapper */
.auth-modal__password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-modal__password-wrapper input {
    padding-right: 3rem;
}

.auth-modal__toggle-password {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--color-gray, #6b7280);
    transition: color 0.2s;
}

.auth-modal__toggle-password:hover {
    color: var(--color-dark, #1f2937);
}

/* Phone wrapper */
.auth-modal__phone-wrapper {
    display: flex;
    align-items: center;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.auth-modal__phone-wrapper:focus-within {
    border-color: var(--color-primary-light, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.auth-modal__phone-prefix {
    padding: 0.75rem 0.75rem;
    background: #f3f4f6;
    color: var(--color-gray, #6b7280);
    font-weight: 500;
    border-right: 2px solid #e5e7eb;
}

.auth-modal__phone-wrapper input {
    border: none;
    border-radius: 0;
    flex: 1;
}

.auth-modal__phone-wrapper input:focus {
    box-shadow: none;
}

/* ===================================
   CHECKBOXES
   =================================== */

.auth-modal__checkboxes {
    margin: 1.25rem 0;
}

.auth-modal__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--color-dark, #1f2937);
}

.auth-modal__checkbox input[type="checkbox"] {
    display: none;
}

.auth-modal__checkmark {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-top: 1px;
}

.auth-modal__checkbox input:checked + .auth-modal__checkmark {
    background: var(--color-primary, #1e3a8a);
    border-color: var(--color-primary, #1e3a8a);
}

.auth-modal__checkbox input:checked + .auth-modal__checkmark::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.auth-modal__checkbox a {
    color: var(--color-primary-light, #3b82f6);
    text-decoration: underline;
}

.auth-modal__checkbox a:hover {
    color: var(--color-primary, #1e3a8a);
}

/* Data info */
.auth-modal__data-info {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f0f9ff;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #0369a1;
    line-height: 1.4;
    margin-bottom: 1rem;
}

.auth-modal__data-info svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ===================================
   MENSAJES DE ERROR Y ÉXITO
   =================================== */

.auth-modal__error {
    display: none;
    padding: 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.auth-modal__success {
    display: none;
    padding: 0.75rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    color: #16a34a;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ===================================
   BOTONES
   =================================== */

.auth-modal__submit {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--color-primary, #1e3a8a), var(--color-primary-light, #3b82f6));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.auth-modal__submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.auth-modal__submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.auth-modal__submit.loading span {
    opacity: 0;
}

.auth-modal__submit.loading .auth-modal__spinner {
    display: block;
}

.auth-modal__spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: absolute;
}

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

.auth-modal__forgot {
    text-align: right;
    margin-bottom: 1rem;
}

.auth-modal__forgot a {
    font-size: 0.875rem;
    color: var(--color-primary-light, #3b82f6);
}

.auth-modal__forgot a:hover {
    text-decoration: underline;
}

.auth-modal__divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
}

.auth-modal__divider::before,
.auth-modal__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.auth-modal__divider span {
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--color-gray, #6b7280);
}

.auth-modal__switch {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: white;
    color: var(--color-primary, #1e3a8a);
    border: 2px solid var(--color-primary, #1e3a8a);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-modal__switch:hover {
    background: var(--color-primary, #1e3a8a);
    color: white;
}

.auth-modal__back {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background: none;
    border: none;
    color: var(--color-gray, #6b7280);
    font-size: 0.9375rem;
    cursor: pointer;
    margin-top: 1rem;
    transition: color 0.2s;
}

.auth-modal__back:hover {
    color: var(--color-dark, #1f2937);
}

/* ===================================
   INDICADOR DE USUARIO
   =================================== */

.user-indicator {
    position: relative;
    margin-right: 1rem;
}

/* Estado: No logueado (Guest) - Botón único "Acceder" */
.user-indicator__guest {
    display: flex;
    align-items: center;
}

.user-indicator__access-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, var(--color-primary, #1e3a8a), var(--color-primary-light, #3b82f6));
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.user-indicator__access-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.user-indicator__access-btn svg {
    opacity: 0.9;
}

.user-indicator__access-arrow {
    margin-left: 0.125rem;
    transition: transform 0.2s;
}

.user-indicator__guest-menu.active + .user-indicator__access-btn .user-indicator__access-arrow,
.user-indicator__access-btn:focus + .user-indicator__guest-menu.active ~ .user-indicator__access-arrow {
    transform: rotate(180deg);
}

/* Dropdown menú para guest */
.user-indicator__guest-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
    overflow: hidden;
}

.user-indicator__guest-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Estado: Logueado */
.user-indicator__logged {
    display: flex;
    align-items: center;
}

.user-indicator__button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 2px solid #e5e7eb;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-indicator__button:hover {
    border-color: var(--color-primary-light, #3b82f6);
    background: rgba(59, 130, 246, 0.05);
}

.user-indicator.logged-in .user-indicator__button {
    border-color: var(--color-primary, #1e3a8a);
    background: rgba(30, 58, 138, 0.05);
}

.user-indicator__avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--color-primary, #1e3a8a), var(--color-primary-light, #3b82f6));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-indicator__name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-dark, #1f2937);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-indicator__arrow {
    color: var(--color-gray, #6b7280);
    transition: transform 0.2s;
}

.user-indicator__menu.active ~ .user-indicator__button .user-indicator__arrow {
    transform: rotate(180deg);
}

/* User Menu Dropdown */
.user-indicator__menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
    overflow: hidden;
}

.user-indicator__menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-indicator__menu-header {
    padding: 1rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.user-indicator__email {
    font-size: 0.8125rem;
    color: var(--color-gray, #6b7280);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-indicator__menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: none;
    border: none;
    font-size: 0.9375rem;
    color: var(--color-dark, #1f2937);
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.user-indicator__menu-item:hover {
    background: #f3f4f6;
}

.user-indicator__menu-item--logout {
    color: #dc2626;
    border-top: 1px solid #e5e7eb;
}

.user-indicator__menu-item--logout:hover {
    background: #fef2f2;
}

/* ===================================
   ELEMENTOS PROTEGIDOS
   =================================== */

[data-auth-required] {
    position: relative;
}

[data-auth-required].auth-locked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    cursor: pointer;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .auth-modal__container {
        max-width: 100%;
        margin: 0.5rem;
        max-height: 95vh;
    }

    .auth-modal__form {
        padding: 1.5rem;
    }

    .auth-modal__logo {
        width: 60px;
        height: 60px;
    }

    .auth-modal__title {
        font-size: 1.25rem;
    }

    .user-indicator {
        margin-right: 0.5rem;
    }

    /* Botón Acceder en móvil */
    .user-indicator__access-btn {
        padding: 0.375rem 0.875rem;
        font-size: 0.8125rem;
    }

    .user-indicator__name {
        display: none;
    }

    .user-indicator__button {
        padding: 0.375rem;
        border-radius: 50%;
    }

    .user-indicator__arrow {
        display: none;
    }

    .user-indicator__menu {
        right: -0.5rem;
        min-width: 200px;
    }
}

@media (max-width: 480px) {
    .auth-modal__checkbox {
        font-size: 0.75rem;
    }

    .auth-modal__checkmark {
        width: 18px;
        height: 18px;
    }
}
