/**
 * Modal de autenticación - Buscador Agrícola
 * Extraído de inline para cacheo y mejor rendimiento
 */
:root {
    --auth-primary: var(--ba-primary);
    --auth-primary-hover: var(--ba-primary-hover);
    --auth-bg: var(--ba-bg-white);
    --auth-text-dark: var(--ba-text-primary);
    --auth-text-muted: var(--ba-text-muted);
    --auth-border: var(--ba-border);
    --auth-radius: 16px;
    --auth-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

#auth-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
}

#auth-modal-overlay.is-visible {
    display: flex !important;
    opacity: 1 !important;
}

.auth-modal-card {
    background: var(--auth-bg);
    width: 95%;
    max-width: 520px;
    max-height: 90vh !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    position: relative;
    padding: 0;
    display: flex;
    flex-direction: column;
}

#close-auth-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--ba-text-muted);
    color: var(--ba-text-on-dark);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    z-index: 10;
}

#close-auth-modal:hover {
    background: var(--ba-text-secondary);
    color: var(--ba-text-on-dark);
}

.auth-section {
    display: none !important;
    padding: 40px 32px 40px;
    height: auto;
    min-height: 0;
}

.auth-section.active {
    display: block !important;
}

/* Espacio al final del formulario de registro al hacer scroll */
#register-section.active {
    padding-bottom: 48px;
}

.auth-modal-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--auth-primary);
    margin-bottom: 25px;
    text-align: left;
    border-bottom: 2px solid var(--ba-bg-section);
    padding-bottom: 15px;
}

.auth-modal-title--block {
    display: block !important;
}

.auth-role-hint {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--ba-text-muted);
}

.auth-form-msg {
    margin-top: 10px;
}

.auth-form-msg a {
    color: inherit;
    text-decoration: underline;
}

.auth-login-fallback {
    margin-top: 12px;
    font-size: 0.8125rem;
    color: var(--ba-text-muted);
}

.auth-login-fallback a {
    color: var(--ba-link);
}

#update-profile-form {
    display: flex !important;
    flex-direction: column;
    gap: 20px;
}

.auth-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--auth-text-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-field input,
.auth-field select {
    padding: 12px 16px;
    border: 1.5px solid var(--auth-border);
    border-radius: 10px;
    font-size: 15px;
    color: var(--ba-text-primary);
    transition: all 0.2s ease;
    background: var(--ba-bg-section);
}

.auth-field input:focus {
    background: var(--ba-bg-white);
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 4px rgba(15, 107, 63, 0.1);
    outline: none;
}

.auth-field input:disabled {
    background: var(--ba-bg-section);
    cursor: not-allowed;
    color: var(--ba-text-muted);
}

.auth-form-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1.5px solid var(--ba-bg-section);
}

.btn-save {
    background: var(--auth-primary) !important;
    color: white !important;
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-save:hover {
    background: var(--auth-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 107, 63, 0.2);
}

.btn-cancel {
    background: var(--ba-bg-white);
    color: var(--auth-text-muted);
    padding: 12px 20px;
    border: 1.5px solid var(--auth-border);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

#profile-msg,
#password-msg {
    font-size: 14px;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.auth-field__pass-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-field__pass-wrap input {
    padding-right: 44px;
    flex: 1;
}

.auth-field__pass-wrap .toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--auth-text-muted);
    font-size: 20px;
    width: 24px;
    height: 24px;
}

.auth-field__pass-wrap .toggle-pass:hover {
    color: var(--auth-primary);
}

#password-section .auth-modal-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--auth-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--auth-border);
}

#change-password-form.auth-form--password {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.password-form-row {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 32px;
    align-items: start;
}

.password-form-fields {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

#password-section .auth-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ba-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#password-section .auth-field__pass-wrap input {
    width: 100%;
    min-height: 44px;
    padding: 12px 44px 12px 14px;
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    font-size: 15px;
    color: var(--ba-text-primary);
    background: var(--ba-bg-section);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#password-section .auth-field__pass-wrap input::placeholder {
    color: var(--ba-text-muted);
}

#password-section .auth-field__pass-wrap input:focus {
    background: var(--ba-bg-white);
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px rgba(15, 107, 63, 0.12);
    outline: none;
}

.password-requirements {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: var(--ba-text-muted);
    min-width: 200px;
}

.password-requirements li {
    padding: 8px 0 8px 26px;
    position: relative;
    line-height: 1.4;
}

.password-requirements li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--ba-border);
    border-radius: 50%;
    background: var(--ba-bg-white);
}

.password-requirements li.valid::before {
    background: var(--auth-primary);
    border-color: var(--auth-primary);
}

.password-requirements li.valid::after {
    content: "✓";
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--ba-text-on-dark);
    font-weight: bold;
}

#password-section .auth-form-buttons {
    margin-top: 8px;
    padding-top: 20px;
    border-top: 1px solid var(--auth-border);
    justify-content: flex-end;
    gap: 12px;
}

#password-section .btn-cancel {
    background: var(--ba-bg-white);
    color: var(--ba-text-secondary);
    border: 1.5px solid var(--ba-border);
    border-radius: 10px;
    padding: 12px 22px;
    font-weight: 600;
}

#password-section .btn-cancel:hover {
    background: var(--ba-bg-section);
    border-color: var(--ba-text-muted);
}

#password-section .btn-save {
    background: var(--auth-primary);
    color: var(--ba-text-on-dark);
    border: none;
    border-radius: 10px;
    padding: 12px 26px;
    font-weight: 700;
}

@media (max-width: 640px) {
    .auth-form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .password-form-row {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .auth-modal-card {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .auth-section {
        padding: 30px 20px;
    }
    .auth-form-buttons {
        flex-direction: column;
    }
    .btn-save,
    .btn-cancel {
        width: 100%;
    }
}
