/* ==========================================================================
   RESET & VARIABLES GLOBALES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.CRM-body {
    font-family: 'Poppins', sans-serif;
    background-color: #fcfaff;
    overflow-x: hidden;
    color: #39333f;
}

.CRM-d-none { display: none !important; }

/* ==========================================================================
   ESTILOS DE LA PANTALLA DE ACCESO (LOGIN)
   ========================================================================== */
.CRM-login-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url('assets/Aguascalientes.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 10000;
}

.CRM-login-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(24, 56, 117, 0.6) 0%, rgba(24, 56, 117, 1) 100%);
    z-index: 1;
}

.CRM-login-card {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 20px 40px #071644;
}

.CRM-login-logo {
    height: 50px;
    margin-bottom: 1.5rem;
    object-fit: contain;
}

.CRM-login-title {
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.CRM-login-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

.CRM-login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.CRM-input-group {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    padding: 0.5rem 0;
}

.CRM-input-inline-icon {
    width: 20px;
    height: 20px;
    opacity: 0.5;
    margin-right: 0.75rem;
    object-fit: contain;
}

.CRM-input-field {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.95rem;
}

.CRM-input-field::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.CRM-toggle-password-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Opacidad del ojo inicializada al 50% según requerimiento */
.CRM-eye-icon {
    width: 20px;
    height: 20px;
    opacity: 0.5;
    transition: opacity 200ms ease;
}

.CRM-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    text-align: left;
    margin-top: 0.25rem;
}

.CRM-checkbox {
    accent-color: #ff3333;
    width: 16px;
    height: 16px;
}

.CRM-checkbox-text {
    color: #ffffff;
    font-size: 0.85rem;
}

.CRM-btn-submit {
    margin-top: 1rem;
    background-color: #ff3333;
    color: #ffffff;
    border: none;
    padding: 0.9rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 15px #071644;
    transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1), 
                padding 300ms cubic-bezier(0.2, 0.8, 0.2, 1), 
                box-shadow 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.CRM-btn-submit:hover {
    box-shadow: none;
    transform: translateY(7px);
    padding-left: calc(2rem + 7px);
    padding-right: calc(2rem + 7px);
}

/* ==========================================================================
   ESTILOS GENERALES DEL PANEL DE CONTROL
   ========================================================================== */
.CRM-panel-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Barra Superior Fija */
.CRM-topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 70px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    z-index: 1000;
}

.CRM-brand-img {
    height: 40px;
    object-fit: contain;
}

.CRM-topbar-user-zone {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.CRM-user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.CRM-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.CRM-user-info {
    display: flex;
    flex-direction: column;
}

/* Protección anti-desborde para correos largos */
.CRM-user-email {
    font-size: 0.85rem;
    font-weight: 500;
    color: #39333f;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.CRM-user-role {
    font-size: 0.75rem;
    color: #867d91;
}

.CRM-btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: #867d91;
    transition: color 250ms ease;
}

.CRM-btn-logout:hover {
    color: #ff3333;
}

.CRM-logout-inline-icon {
    width: 20px;
    height: 20px;
}

/* Layout Principal */
.CRM-main-layout {
    display: flex;
    margin-top: 70px;
    flex: 1;
    height: calc(100vh - 70px);
    position: relative;
}

/* Menú Lateral - Alto completo absoluto */
.CRM-sidebar {
    width: 260px;
    background-color: #ffffff;
    border-right: 1px solid #f0ebf5;
    display: flex;
    flex-direction: column;
    transition: width 350ms cubic-bezier(0.4, 0, 0.2, 1), background-color 350ms ease;
    height: 100%;
    flex-shrink: 0;
}

.CRM-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid #fbf9fc;
}

.CRM-sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #39333f;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 250ms ease;
}

.CRM-sidebar-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #867d91;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}

.CRM-arrow-icon {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-top: 2px solid #867d91;
    border-left: 2px solid #867d91;
    transform: rotate(-45deg);
    transition: transform 350ms ease;
}

.CRM-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.CRM-sidebar-nav::-webkit-scrollbar { width: 4px; }
.CRM-sidebar-nav::-webkit-scrollbar-thumb { background: #e2daeb; border-radius: 10px; }

.CRM-nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: #867d91;
    text-align: left;
    gap: 1rem;
    transition: background-color 250ms ease, color 250ms ease;
}

.CRM-nav-inline-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    transition: filter 250ms ease;
}

.CRM-nav-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 250ms ease;
}

.CRM-nav-item:hover { background-color: #fff8ff; }
.CRM-nav-item.CRM-active { background-color: #ff3333; color: #ffffff; }
.CRM-nav-item.CRM-active .CRM-nav-inline-icon { filter: brightness(0) invert(1); }

/* Escritorio: Estado Colapsado Regular */
.CRM-sidebar.CRM-collapsed { width: 70px; }
.CRM-sidebar.CRM-collapsed .CRM-sidebar-title,
.CRM-sidebar.CRM-collapsed .CRM-nav-text {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
}
.CRM-sidebar.CRM-collapsed .CRM-arrow-icon { transform: rotate(135deg); }

/* Área de Contenido */
.CRM-content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background-color: #fcfaff;
    height: 100%;
}

.CRM-view-container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.CRM-component-header { margin-bottom: 0.5rem; }
.CRM-main-title { font-size: 1.5rem; font-weight: 600; color: #39333f; margin-bottom: 0.25rem; }
.CRM-main-subtitle { font-size: 0.9rem; color: #867d91; }

.CRM-card-container {
    background-color: #ffffff;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.01);
    border: 1px solid #f3eff7;
}
.CRM-card-title { font-size: 1.15rem; font-weight: 600; color: #39333f; margin-bottom: 0.5rem; }
.CRM-card-desc { font-size: 0.9rem; color: #867d91; }

/* Alertas */
.CRM-alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-radius: 15px;
    border: 1px solid transparent;
}
.CRM-alert-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.CRM-alert-desc { font-size: 0.875rem; }
.CRM-alert-close { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; color: inherit; opacity: 0.7; }

.CRM-alert-success { background-color: #dcffde; border-color: #85c988; color: #345134; }
.CRM-alert-warning { background-color: #fff7c5; border-color: #c6b585; color: #5e543c; }
.CRM-alert-danger { background-color: #f7e3ff; border-color: #c485c6; color: #543456; }
.CRM-alert-info { background-color: #dff8fc; border-color: #85b2c6; color: #283d44; }

/* ==========================================================================
   OPTIMIZACIÓN CRÍTICA PARA CELULARES (REQUERIMIENTO EXACTO)
   ========================================================================== */
@media (max-width: 768px) {
    /* Barra Superior en móviles: Truncado controlado del correo */
    .CRM-user-email {
        max-width: 110px;
        font-size: 0.75rem;
    }
    .CRM-user-role {
        font-size: 0.65rem;
    }
    .CRM-topbar-user-zone {
        gap: 0.75rem;
    }

    /* Comportamiento del Sidebar en Celulares */
    .CRM-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 999;
        background-color: #ffffff;
        box-shadow: 5px 0 20px rgba(0,0,0,0.05);
    }

    /* ESTADO COLAPSADO EN MÓVIL: Totalmente transparente, sin iconos y fondo invisible detrás del botón */
    .CRM-sidebar.CRM-collapsed {
        width: 60px;
        background-color: transparent;
        border-right-color: transparent;
        box-shadow: none;
    }

    /* Ocultar elementos informativos al colapsar */
    .CRM-sidebar.CRM-collapsed .CRM-sidebar-title,
    .CRM-sidebar.CRM-collapsed .CRM-nav-text,
    .CRM-sidebar.CRM-collapsed .CRM-nav-inline-icon {
        display: none !important;
    }

    /* El contenedor del botón flotante mantiene su estética limpia */
    .CRM-sidebar.CRM-collapsed .CRM-sidebar-header {
        border-bottom-color: transparent;
        justify-content: center;
        padding: 1rem 0;
    }

    /* Estilo del botón de flecha flotante en celulares cuando está colapsado */
    .CRM-sidebar.CRM-collapsed .CRM-sidebar-toggle-btn {
        background-color: #ffffff;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        border: 1px solid #f0ebf5;
    }

    /* Asegurar que el scroll no ocupe espacio cuando no se ve */
    .CRM-sidebar.CRM-collapsed .CRM-sidebar-nav {
        display: none !important;
    }

    /* Ajuste de márgenes del contenedor de contenido */
    .CRM-content-wrapper {
        padding: 1rem;
    }
}