/* ==========================================================================
   1. NAVEGACIÓN GENERAL & SIDEBAR RESPONSIVO
   ========================================================================== */

.sidebar {
    width: 260px;
    background: var(--nav-bg);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    backdrop-filter: blur(16px) saturate(120%);
    border-right: 1px solid var(--glass-border);
    height: 100vh;
    max-height: 100vh;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar estética para sidebar */
.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

/* Contenido principal fluye con la página en móviles */
@media (max-width: 768px) {
    .main-content {
        height: auto;
        overflow-y: visible;
    }
    
    .main-content::-webkit-scrollbar {
        width: 4px;
    }
    
    .main-content::-webkit-scrollbar-thumb {
        background: var(--glass-border);
        border-radius: 4px;
    }
    
    /* Asegurar que los modales sean scrolleables */
    .modal-body {
        max-height: 75vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-dialog {
        max-width: 95%;
        margin: 10px auto;
    }
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
}

.sidebar-logo {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: inline-block;
    background-image: url('../../logo-blanco.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    background-color: transparent;
}

[data-theme="light"] .sidebar-logo {
    background-image: url('../../logo-negro.png');
}

.sidebar .nav-header {
    color: #4CA688 !important;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-shadow: none;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    opacity: 0.85;
    flex-shrink: 0;
}

.sidebar .nav-link {
    color: #F8FAFC !important;
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.95rem;
    margin-bottom: 0.35rem;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.94rem;
    text-shadow: none;
    border-left: 3px solid transparent;
    white-space: nowrap;
    width: 100%;
    max-width: 100%;
}

.sidebar .nav-link i {
    font-size: 1.15rem;
    color: #6B8E8E;
    transition: transform 0.25s ease, color 0.25s ease;
    flex-shrink: 0;
}

.sidebar .nav-link:hover {
    color: #F8FAFC !important;
    background: linear-gradient(90deg, rgba(45, 138, 110, 0.10) 0%, rgba(45, 138, 110, 0.02) 100%);
    border-left: 3px solid #2D8A6E;
    transform: translateX(4px);
    box-shadow: none;
}

.sidebar .nav-link:hover i {
    color: #F8FAFC;
    transform: scale(1.08);
}

.sidebar .nav-link.active {
    background: linear-gradient(135deg, #2D8A6E 0%, #1E6B56 100%);
    color: #F8FAFC !important;
    font-weight: 600;
    border-left: 3px solid #4CA688;
    box-shadow: 0 4px 12px rgba(45, 138, 110, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.sidebar .nav-link.active i {
    color: #F8FAFC;
}


/* --- ESTRUCTURA BASE DE MÓDULOS (ESTANDARIZACIÓN) --- */
.tab-pane {
    display: flex;
    flex-direction: column;
    gap: var(--infra-spacing-md);
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Cabecera de módulo compacta: los datos empiezan justo después, sin margen grande */
.tab-pane > .d-flex.justify-content-between.align-items-center {
    margin-bottom: 0.5rem !important;
}

.tab-pane > .d-flex.justify-content-between.align-items-center h3 {
    margin-bottom: 0.15rem;
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--infra-spacing-md);
    padding-bottom: var(--infra-spacing-md);
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: var(--infra-spacing-md);
    flex-wrap: wrap;
}

.module-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.sidebar .nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar .nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar .nav::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.main-content {
    margin-left: 260px;
    padding: 0 2rem 2rem;
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    min-height: 100vh;
    transition: margin-left 0.3s ease, width 0.3s ease;
    box-sizing: border-box;
    overflow-x: hidden;
}

.main-content > .tab-content {
    width: 100%;
    max-width: 1480px;
    margin-inline: auto;
    box-sizing: border-box;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

.mobile-topbar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    z-index: 1030;
}

/* Ajustes para tablet y móvil (< 992px) */
@media (max-width: 991.98px) {
    .sidebar {
        left: -280px;
        box-shadow: none;
        width: 280px;
        max-width: 85vw;
    }
    .sidebar.show {
        left: 0;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        padding: 1rem;
        padding-top: 0;
    }
    .main-content > .tab-content {
        max-width: 100%;
        padding: 0;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
        z-index: 1049;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

@media print {
    body * {
        visibility: hidden;
    }
    #printable-quote-doc, #printable-quote-doc * {
        visibility: visible;
    }
    #printable-quote-doc {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        border: none !important;
    }
    #printable-quote-doc .btn-close,
    #printable-quote-doc button {
        display: none !important;
    }
    #printable-quote-doc .text-light,
    #printable-quote-doc .text-secondary,
    #printable-quote-doc .text-muted,
    #printable-quote-doc h4,
    #printable-quote-doc h5,
    #printable-quote-doc h6 {
        color: #000 !important;
    }
    #printable-quote-doc table,
    #printable-quote-doc th,
    #printable-quote-doc td {
        border-color: #ccc !important;
        color: #000 !important;
    }
    #printable-quote-doc .badge {
        border: 1px solid #333 !important;
        color: #000 !important;
        background: transparent !important;
    }
}
