/* Estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
}

/* --- 1. Bloqueo estricto del Body --- */
body {
    display: flex;
    flex-direction: column;
    height: 100vh !important;
    /* Estricto a la ventana */
    overflow: hidden !important;
    /* Cero scroll global */
    margin: 0;
}

#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
}

/* Header removido (Parche Arquitecto) */

/* --- 2. Contenedores con 'min-height: 0' (La regla mágica) --- */
.profile-main-container {
    flex: 1;
    display: flex;
    width: 100%;
    overflow: hidden;
    min-height: 0;
    /* OBLIGA a flexbox a no crecer más allá de la pantalla */
}

.profile-container {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    /* OBLIGA a flexbox a no crecer más allá de la pantalla */
}

/* --- 1. Contenedor del Menú (Convertido a Flexbox) --- */
.profile-sidebar {
    width: 280px;
    flex-shrink: 0;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0;
    padding: 30px 20px;
    height: 100%;
    box-sizing: border-box;
    transition: transform 0.3s ease-in-out;
    /* MAGIA: Quitamos el scroll global de la barra y la hacemos Flex */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

/* --- 2. Cabecera del Menú (Foto y Nombre Fijos) --- */
.sidebar-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: none;
    flex-shrink: 0;
    /* Evita que la foto se encoja cuando hay muchos links */
}

.profile-pic {
    position: relative;
    width: 110px;
    height: 110px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
    border: none;
    /* Adiós al borde azul sólido */
    box-shadow: 0 0 0 4px #ffffff, 0 0 0 8px #eff6ff, 0 10px 20px -5px rgba(37, 99, 235, 0.2);
    /* Efecto Anillo Premium */
    transition: transform 0.3s ease;
}

.profile-pic:hover {
    transform: scale(1.05);
}

.profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-change-pic {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(15, 23, 42, 0.6);
    /* Gris oscuro cristalino */
    backdrop-filter: blur(4px);
    color: white;
    border: none;
    padding: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-change-pic:hover {
    background-color: #1a5dc8;
}

.sidebar-header h3 {
    margin: 10px 0 0;
    color: #0f172a;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

/* --- 3. Zona de Enlaces (Ahora con Scroll independiente) --- */
.sidebar-nav {
    flex: 1;
    /* Toma todo el espacio sobrante debajo de la foto */
    overflow-y: auto;
    /* Activa el scroll SOLO para los links */
    padding-right: 5px;
    /* Espacio para que el scroll no pise los botones */
    padding-bottom: 20px;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav li {
    margin-bottom: 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    color: #475569;
    text-decoration: none;
    border-radius: 14px;
    /* Forma de píldora */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0 10px;
    /* Espacio de los bordes laterales */
}

.sidebar-nav a:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    transform: translateX(6px);
    /* Efecto de deslizarse sutilmente a la derecha */
}

.sidebar-nav a img {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    filter: grayscale(100%) opacity(0.7);
    transition: all 0.3s ease;
}

.sidebar-nav a:hover img,
.sidebar-nav li.active a img {
    filter: grayscale(0%) opacity(1);
}

.sidebar-nav li.active a {
    background-color: #eff6ff;
    /* Fondo azul extra suave */
    color: #2563eb;
    /* Texto azul vibrante */
    font-weight: 600;
    box-shadow: 0 4px 10px -2px rgba(37, 99, 235, 0.1);
}

/* ======================================================== */
/* --- 1. CONTENEDORES MAESTROS Y SCROLL RESTAURADO --- */
/* ======================================================== */
.profile-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden !important;
    /* Bloquea solo la página más externa */
    box-sizing: border-box;
    background-color: #f4f7fa;
    background-image: radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.07) 0px, transparent 50%), radial-gradient(at 100% 100%, rgba(147, 51, 234, 0.05) 0px, transparent 50%), radial-gradient(at 100% 0%, rgba(2, 132, 199, 0.06) 0px, transparent 50%);
    background-attachment: fixed;
    height: 100%;
}

#dynamicContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 40px 40px 40px !important;
    /* MAGIA: Devuelve el scroll a TODAS las vistas (Pagos, Contactos, etc.) */
    overflow-y: auto !important;
    min-height: 0;
}

/* ======================================================== */
/* --- 1. BREADCRUMBS CON GLASSMORPHISM --- */
/* ======================================================== */
.breadcrumbs {
    position: sticky !important;
    top: 0 !important;
    z-index: 101 !important;
    /* Por encima del título */
    flex-shrink: 0;
    margin: 0 !important;
    /* MAGIA: Copiamos el fondo cristal exacto del título */
    background: rgba(244, 247, 250, 0.95) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    /* Ajustamos el padding para que se fusione con el h2 */
    padding: 25px 40px 5px 40px !important;
    padding-top: calc(25px + env(safe-area-inset-top, 0px)) !important;
    font-size: 0.75rem !important;
    color: #64748b !important;
    display: flex !important;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    border: none !important;
    box-shadow: none !important;
}

/* ======================================================== */
/* --- TÍTULO STICKY CAMUFLADO (Efecto Invisible) --- */
/* ======================================================== */
#dynamicContent>h2 {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    margin: 0 -40px 25px -40px !important;
    /* Se estira a los bordes */
    padding: 0 40px 15px 40px !important;
    /* Espacio para la línea */

    /* MAGIA VISUAL: Copiamos el fondo exacto de la página web */
    background-color: #f4f7fa !important;
    background-image: radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.07) 0px, transparent 50%), radial-gradient(at 100% 100%, rgba(147, 51, 234, 0.05) 0px, transparent 50%), radial-gradient(at 100% 0%, rgba(2, 132, 199, 0.06) 0px, transparent 50%) !important;
    background-attachment: fixed !important;
    /* Esto hace que el fondo empate a la perfección */

    /* Sin desenfoques ni cristales */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;

    /* Solo la línea elegante abajo */
    border-bottom: 2px solid rgba(203, 213, 225, 0.6) !important;

    color: #0f172a !important;
    font-size: 1.8rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.5px !important;
    flex-shrink: 0;
}

/* ======================================================== */
/* --- 3. RESTAURAR EL DISEÑO CENTRADO DEL FORMULARIO --- */
/* ======================================================== */
.profile-form {
    max-width: 900px !important;
    /* DEVUELVE EL ANCHO ELEGANTE */
    margin: 0 auto !important;
    /* LO CENTRA EN LA PANTALLA */
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 30px;
    overflow: visible !important;
    /* Quita la regla vieja que lo rompía */
}

/* Scrollbars finas re-aplicadas al contenedor correcto */
#dynamicContent::-webkit-scrollbar {
    width: 6px;
}

#dynamicContent::-webkit-scrollbar-track {
    background: transparent;
}

#dynamicContent::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.4);
    border-radius: 10px;
}

#dynamicContent::-webkit-scrollbar-thumb:hover {
    background-color: rgba(148, 163, 184, 0.8);
}

/* --- 3. Tarjetas Flotantes (Magia de 2 Columnas) --- */
.form-section {
    padding: 35px 40px;
    border-radius: 24px;
    background-color: #ffffff;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: transform 0.3s ease, box-shadow 0.3s ease;

    /* Auto-Grid Flexbox */
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    margin-bottom: 0;
}

.form-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 50px -10px rgba(0, 0, 0, 0.08);
}

.form-section h3,
.form-section legend {
    width: 100%;
    /* Fuerza al título a ocupar toda la fila superior */
    font-size: 1.25rem;
    color: #0f172a;
    font-weight: 800;
    margin: 0 0 5px 0;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 15px;
}

/* --- 4. Inputs Soft UI Premium --- */
.input-group {
    flex: 1 1 calc(50% - 25px);
    /* Ocupa mitad de pantalla menos el espacio (gap) */
    min-width: 260px;
    /* Si es móvil o pantalla pequeña, baja a la siguiente línea */
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Casos donde el elemento debe ocupar toda la fila sí o sí */
.input-group.full-width,
.form-section .info-text,
.password-wrapper {
    flex: 1 1 100%;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
    font-weight: 700;
    color: #475569;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 16px 20px;
    background-color: #f8fafc;
    border: 2px solid transparent;
    border-radius: 14px;
    font-size: 1rem;
    color: #1e293b;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    font-family: inherit;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    background-color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    outline: none;
}

.info-text {
    margin-top: 5px;
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
    font-style: normal;
}

/* --- 5. Botón de Envío Elevado --- */
.btn-submit {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 20px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4);
    width: 100%;
}

.btn-submit:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px -5px rgba(37, 99, 235, 0.5);
}

.message {
    margin-top: 20px;
    padding: 10px;
    border-radius: 5px;
    display: none;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    display: block;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    display: block;
}

/* Footer */
footer {
    text-align: center;
    padding: 15px 0;
    background-color: rgba(255, 255, 255, 0.8);
    color: #333333;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    backdrop-filter: blur(5px);
    z-index: 20;
    /* Asegura que se mantenga por encima del contenido */
    position: relative;
    /* Lo ancla al fondo del flexbox */
}

/* Responsive Design */
@media (max-width: 992px) {

    .profile-container {
        flex-direction: column;
        /* Cambia a una sola columna */
        height: auto;
    }

    .profile-sidebar {
        position: fixed;
        /* Fija el menú para que se deslice sobre el contenido */
        top: 0;
        /* Lo alineas con la parte superior del header que tienes en perfil_solicitudes.html */
        left: 0;
        height: 100vh;
        /* Ocupa toda la altura */
        width: 280px;
        /* Ancho fijo para el menú deslizable */
        z-index: 1000;
        /* Asegura que esté por encima de todo */
        transform: translateX(-100%);
        /* Lo oculta fuera de la pantalla a la izquierda */
        transition: transform 0.3s ease-in-out;
        /* Animación suave */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        border-right: none;
        /* Ya no es necesario el borde */
    }

    .profile-sidebar.show {
        transform: translateX(0);
        /* Lo muestra cuando tiene la clase 'show' */
    }

    .profile-content {
        /* Aseguramos que el contenido ocupe todo el ancho */
        padding: 20px;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .brand-text {
        font-size: 20px;
    }

    .logo {
        height: 35px;
    }
}

@media (max-width: 576px) {
    .form-section {
        padding: 15px;
    }

    .profile-pic {
        width: 100px;
        height: 100px;
    }

    .profile-content {
        padding: 15px;
    }

    .input-group input,
    .input-group select {
        padding: 10px 12px;
    }

    .btn-submit {
        padding: 12px 20px;
        font-size: 16px;
    }

    .header {
        padding: 0 10px;
        height: 60px;
    }

    .brand-text {
        font-size: 18px;
    }

    .logo {
        height: 30px;
    }

    .user-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* Estilos para el menú desplegable del usuario */
.user-menu-container {
    position: relative;
    display: inline-block;
}

.user-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #2575fc;
    color: white;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.user-btn:hover {
    background-color: #1a5dc8;
    transform: scale(1.05);
}

.dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 50px;
    background-color: white;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    border-radius: 8px;
    overflow: hidden;
}

.dropdown.show {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-option {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.dropdown-option:hover {
    background-color: #f5f5f5;
}

.dropdown-option .btn-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background-color: white;
    min-width: 150px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-radius: 0 8px 8px 8px;
    z-index: 1001;
}

.dropdown-option:hover .submenu {
    display: block;
}

.submenu-option {
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.submenu-option:hover {
    background-color: #f5f5f5;
    color: #2575fc;
}

/* --- VALIDACIÓN DE INPUTS (PERFIL) --- */

.input-error {
    border-color: #dc3545 !important;
    background-color: #fff8f8;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1) !important;
}

.input-success {
    border-color: #28a745 !important;
    background-color: #f8fff9;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1) !important;
}

.validation-msg {
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
    font-weight: 500;
}

.validation-msg.error {
    color: #dc3545;
}

.validation-msg.success {
    color: #28a745;
}

/* Overlay para la barra lateral en móvil */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    /* Por debajo del sidebar (1000) pero encima del contenido */
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* --- Scrollbars Ultra Premium (Estilo macOS) --- */
.sidebar-nav::-webkit-scrollbar,
#dynamicContent::-webkit-scrollbar,
.profile-content::-webkit-scrollbar,
.requests-list::-webkit-scrollbar,
.role-scroll-area::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 4px;
    /* Ultra delgado */
    height: 4px;
    /* Ultra delgado para scroll horizontal */
}

.sidebar-nav::-webkit-scrollbar-track,
#dynamicContent::-webkit-scrollbar-track,
.profile-content::-webkit-scrollbar-track,
.requests-list::-webkit-scrollbar-track,
.role-scroll-area::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
    background: transparent;
    /* Pista invisible */
}

.sidebar-nav::-webkit-scrollbar-thumb,
#dynamicContent::-webkit-scrollbar-thumb,
.profile-content::-webkit-scrollbar-thumb,
.requests-list::-webkit-scrollbar-thumb,
.role-scroll-area::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.4);
    /* Gris azulado semi-transparente */
    border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover,
#dynamicContent::-webkit-scrollbar-thumb:hover,
.profile-content::-webkit-scrollbar-thumb:hover,
.requests-list::-webkit-scrollbar-thumb:hover,
.role-scroll-area::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(148, 163, 184, 0.8);
    /* Se oscurece un poco al pasar el mouse */
}

@media (max-width: 768px) {
    .profile-header {
        padding: 10px 20px !important;
        padding-top: calc(10px + env(safe-area-inset-top, 0px)) !important;
        height: auto !important;
        min-height: 65px !important;
    }

    #dynamicContent {
        padding: 0 20px 20px 20px !important;
    }

    .breadcrumbs {
        padding: 15px 20px 5px 20px !important;
    }

    #dynamicContent>h2 {
        margin: 0 -20px 20px -20px !important;
        padding: 0 20px 15px 20px !important;
        font-size: 1.5rem !important;
    }

    .form-section {
        padding: 20px !important;
        gap: 15px;
    }

    .input-group {
        flex: 1 1 100% !important;
        min-width: 100%;
    }

    #dynamicContent .profile-pic,
    .form-section .profile-pic {
        flex-shrink: 0 !important;
        margin: 15px auto 40px auto !important;
    }

    #dynamicContent .input-group:has(.profile-pic) {
        height: auto !important;
        width: 100% !important;
        align-items: center;
    }
}

@media (max-width: 992px) {
    .mobile-profile-menu-btn {
        display: block !important;
    }

    .sidebar-overlay {
        z-index: 10000 !important;
    }

    .profile-sidebar {
        z-index: 10001 !important;
        height: 100dvh !important;
        bottom: 0;
    }

    .sidebar-nav {
        padding-bottom: 50px !important;
    }
}