/**
 * ============================================================================
 * CRM Sublimet - Header Comercial Corporativo (Fondo Full-Width, Contenido en Box)
 * Archivo: public/assets/css/crm/crm-header.css
 * ============================================================================
 */

/* ==========================================================================
   RESET DE LAYOUT: Flujo Vertical Limpio y Contenido en Box
   ========================================================================== */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    background-color: #f0f4f8;
}

.app-wrapper {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #f0f4f8 !important;
    position: relative !important;
}

.app-wrapper .app-content,
.app-content {
    display: block !important;
    flex: 1 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    padding-top: 10px !important;
    padding-bottom: 30px !important;
    margin: 0 !important;
    box-shadow: none !important;
    min-height: auto !important;
}

/* Contenedor en Box Centrado para el Cuerpo del Sitio */
.crm-main-boxed-container {
    max-width: 1400px !important;
    width: 100% !important;
    margin: 0 auto 30px auto !important;
    padding: 0 24px !important;
    box-sizing: border-box;
}

/* Reset de Footer en Comercial */
.app-wrapper footer,
div > footer,
footer {
    padding-left: 0 !important;
    position: static !important;
    margin-top: auto !important;
    width: 100% !important;
    background-color: #ffffff !important;
    border-top: 1px solid #d2e2f0 !important;
}

/* Reset de elementos de navegación para no colisionar con temas antiguos */
.app-content nav,
nav:not(.dark-sidebar):not(.horizontal-sidebar):not(.navbar) {
    position: static !important;
    width: auto !important;
    height: auto !important;
    background-color: transparent !important;
    z-index: auto !important;
}

/* ==========================================================================
   1. CONTENEDOR PRINCIPAL DEL HEADER (FONDO A ANCHO COMPLETO)
   ========================================================================== */
.crm-sat-header {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background: linear-gradient(90deg, #0c2955 0%, #184294 100%);
    border-radius: 0 !important;
    margin: 0 0 20px 0 !important;
    box-shadow: 0 3px 14px rgba(12, 41, 85, 0.25);
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #ffffff;
    position: sticky !important;
    top: 0 !important;
    z-index: 1030 !important;
}

/* Contenedor Centrado en Box para el contenido del Header (Mismo ancho que el body) */
.crm-sat-inner-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

/* ==========================================================================
   2. FILA 1: LOGO - BUSCADOR - ICONOS (FAVORITO, NOTIFICACIONES, PERFIL)
   ========================================================================== */
.crm-sat-header-top {
    height: 60px;
    width: 100% !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    box-sizing: border-box;
}

/* Logo & Badge */
.crm-sat-brand-box {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.crm-sat-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: #ffffff;
}

.crm-sat-brand img {
    max-height: 30px;
    width: auto;
    object-fit: contain;
}

.crm-sat-badge {
    background: rgba(0, 148, 210, 0.25);
    border: 1px solid rgba(111, 203, 243, 0.45);
    color: #6fcbf3;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Buscador Grande Central */
.crm-sat-search-wrap {
    flex: 1;
    max-width: 620px;
    margin: 0 auto;
}

.crm-sat-search-box {
    position: relative;
    width: 100%;
}

.crm-sat-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9cd5ee;
    font-size: 16px;
    pointer-events: none;
    z-index: 5;
}

.crm-sat-search-input {
    width: 100%;
    height: 38px;
    background: rgba(255, 255, 255, 0.13) !important;
    border: 1px solid rgba(255, 255, 255, 0.24) !important;
    border-radius: 8px !important;
    padding: 7px 16px 7px 42px !important;
    font-size: 13.5px !important;
    font-family: 'IBM Plex Sans', sans-serif !important;
    color: #ffffff !important;
    outline: none !important;
    transition: all 0.2s ease-in-out !important;
}

.crm-sat-search-input::placeholder {
    color: #b0cee0 !important;
    font-size: 13px !important;
}

.crm-sat-search-input:focus {
    background: rgba(255, 255, 255, 0.24) !important;
    border-color: #6fcbf3 !important;
    box-shadow: 0 0 0 3.5px rgba(0, 148, 210, 0.3) !important;
    color: #ffffff !important;
}

/* Acciones e Iconos Derecha */
.crm-sat-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.crm-sat-select {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #ffffff;
    height: 34px;
    padding: 2px 26px 2px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.crm-sat-select option {
    background: #0c2955;
    color: #ffffff;
}

.crm-sat-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    position: relative;
    transition: all 0.15s ease;
    cursor: pointer;
}

.crm-sat-icon-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.35);
}

.crm-sat-badge-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border: 1.5px solid #0c2955;
    border-radius: 50%;
}

/* Botón Hamburguesa Móvil */
.crm-sat-mobile-toggle {
    width: 36px;
    height: 36px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    outline: none;
}

.crm-sat-mobile-toggle:hover,
.crm-sat-mobile-toggle:focus {
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.35);
}

/* Perfil de Usuario */
.crm-sat-profile-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 3px 11px 3px 4px;
    border-radius: 50px;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.crm-sat-profile-pill:hover {
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
}

.crm-sat-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0094d2;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
}

.crm-sat-user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   3. FILA 2: MENÚ HORIZONTAL (ESCRITORIO, CONTACTOS, PEDIDOS, CARTERA)
   ========================================================================== */
.crm-sat-header-menu {
    height: 42px;
    width: 100% !important;
    background: rgba(0, 0, 0, 0.18);
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    position: relative;
    z-index: 101;
    box-sizing: border-box;
    overflow: visible !important;
}

.crm-sat-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    width: 100%;
}

.crm-sat-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 100%;
    padding: 0 14px;
    color: #d2e4f0;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 2.5px solid transparent;
    transition: all 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.crm-sat-nav-link:hover {
    color: #6fcbf3;
}

.crm-sat-nav-link .fa-chevron-down {
    transition: transform 0.2s ease;
}

.crm-sat-nav-link.active,
.crm-sat-nav-dropdown.active > .crm-sat-nav-link {
    color: #ffffff;
    border-bottom-color: #0094d2;
    background: rgba(255, 255, 255, 0.06);
}

.crm-sat-nav-dropdown {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Menú Desplegable Base */
.crm-sat-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff;
    color: #0c2955;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(12, 41, 85, 0.18);
    border: 1px solid #d5e2ee;
    min-width: 220px;
    display: none;
    z-index: 1050;
    padding: 6px 0;
    animation: crmSatFadeIn 0.15s ease;
}

/* Soporte de Apertura por Hover en Desktop y Clase .show/.open en Touch/Click */
@media (min-width: 992px) {
    .crm-sat-nav-dropdown:hover > .crm-sat-menu-dropdown {
        display: block;
    }

    .crm-sat-submenu-wrap:hover > .crm-sat-submenu-panel {
        display: block;
    }
}

.crm-sat-nav-dropdown.show > .crm-sat-menu-dropdown,
.crm-sat-nav-dropdown.open > .crm-sat-menu-dropdown {
    display: block;
}

.crm-sat-nav-dropdown.show > .crm-sat-nav-link .fa-chevron-down,
.crm-sat-nav-dropdown.open > .crm-sat-nav-link .fa-chevron-down {
    transform: rotate(180deg);
}

.crm-sat-menu-item {
    padding: 8px 16px;
    font-size: 12.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 9px;
    color: #0c2955;
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
    white-space: nowrap;
    cursor: pointer;
}

.crm-sat-menu-item:hover {
    background: #e8f4fc;
    color: #184294;
}

.crm-sat-menu-item.active {
    background: #e1f5fe;
    color: #0094d2;
    font-weight: 600;
}

/* Submenús multinivel */
.crm-sat-submenu-wrap {
    position: relative;
}

.crm-sat-submenu-wrap > a .fa-chevron-right {
    transition: transform 0.2s ease;
}

.crm-sat-submenu-panel {
    position: absolute;
    top: 0;
    left: 100%;
    background: #ffffff;
    color: #0c2955;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(12, 41, 85, 0.18);
    border: 1px solid #d5e2ee;
    min-width: 190px;
    display: none;
    z-index: 1051;
    padding: 6px 0;
    animation: crmSatFadeIn 0.15s ease;
}

.crm-sat-submenu-wrap.show > .crm-sat-submenu-panel,
.crm-sat-submenu-wrap.open > .crm-sat-submenu-panel {
    display: block;
}

.crm-sat-submenu-wrap.show > a .fa-chevron-right,
.crm-sat-submenu-wrap.open > a .fa-chevron-right {
    transform: rotate(90deg);
}

/* Dropdown Cards Generales */
.crm-sat-dropdown-card {
    border: 1px solid #d5e2ee;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(12, 41, 85, 0.18);
    background: #ffffff;
    color: #0c2955;
    padding: 6px 0;
    min-width: 240px;
    z-index: 1050;
}

.crm-sat-dropdown-header {
    padding: 10px 16px;
    border-bottom: 1px solid #e5edf5;
    background: #f8fafc;
}

@keyframes crmSatFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   4. RESPONSIVIDAD PARA DISPOSITIVOS MÓVILES Y SMARTPHONES (< 992px)
   ========================================================================== */
@media (max-width: 991px) {
    .crm-sat-header-top {
        height: auto;
    }

    .crm-sat-inner-container {
        flex-wrap: wrap;
        padding: 10px 14px !important;
        gap: 10px;
    }

    .crm-sat-search-wrap {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin: 0;
    }

    /* Menú Desplegable Drawer para Móviles */
    .crm-sat-header-menu {
        display: none !important;
        height: auto !important;
        background: #082247 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        padding: 12px 0 16px 0 !important;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
        max-height: 80vh;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }

    .crm-sat-header-menu.mobile-open {
        display: block !important;
        animation: crmSatFadeIn 0.2s ease;
    }

    .crm-sat-header-menu .crm-sat-inner-container {
        padding: 0 14px !important;
        flex-direction: column;
        align-items: stretch;
    }

    .crm-sat-nav-wrapper {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
        width: 100% !important;
        height: auto !important;
    }

    .crm-sat-nav-dropdown {
        flex-direction: column !important;
        width: 100% !important;
        height: auto !important;
        align-items: stretch !important;
    }

    /* Enlaces Principales en Móvil (Full-width, Touch-friendly) */
    .crm-sat-nav-link {
        width: 100% !important;
        min-height: 44px !important;
        height: auto !important;
        padding: 10px 14px !important;
        border-radius: 6px !important;
        border-bottom: none !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        color: #ffffff !important;
        background: rgba(255, 255, 255, 0.06) !important;
        box-sizing: border-box;
    }

    .crm-sat-nav-link:hover,
    .crm-sat-nav-link:focus,
    .crm-sat-nav-dropdown.show > .crm-sat-nav-link,
    .crm-sat-nav-dropdown.open > .crm-sat-nav-link {
        background: rgba(0, 148, 210, 0.25) !important;
        color: #6fcbf3 !important;
    }

    /* Menú Dropdown en Modo Acordeón Móvil (Sin recorte, expande hacia abajo) */
    .crm-sat-menu-dropdown {
        position: static !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: 1px solid rgba(255, 255, 255, 0.09) !important;
        border-radius: 8px !important;
        background: rgba(0, 0, 0, 0.3) !important;
        margin: 4px 0 8px 0 !important;
        padding: 4px !important;
        box-sizing: border-box;
    }

    .crm-sat-menu-item {
        padding: 11px 14px !important;
        min-height: 42px !important;
        font-size: 13.5px !important;
        color: #e1edf7 !important;
        border-radius: 6px !important;
        margin: 2px 0 !important;
        white-space: normal !important;
        box-sizing: border-box;
    }

    .crm-sat-menu-item:hover,
    .crm-sat-menu-item:active {
        background: rgba(255, 255, 255, 0.12) !important;
        color: #ffffff !important;
    }

    .crm-sat-menu-item.active {
        background: rgba(0, 148, 210, 0.3) !important;
        color: #6fcbf3 !important;
        font-weight: 600;
    }

    /* Submenú Multinivel Anidado en Acordeón Móvil */
    .crm-sat-submenu-panel {
        position: static !important;
        width: 100% !important;
        min-width: 100% !important;
        box-shadow: none !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 6px !important;
        background: rgba(0, 0, 0, 0.4) !important;
        margin: 4px 0 6px 12px !important;
        padding: 4px !important;
        box-sizing: border-box;
    }

    .crm-main-boxed-container {
        padding: 0 14px !important;
    }
}
