/* ========================================
   SISTEMA JURÍDICO - ESTILOS PERSONALIZADOS
   ======================================== */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* ========================================
   SIDEBAR - VERSIÓN OPTIMIZADA
   ======================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    
}

/* HEADER DEL SIDEBAR */
.sidebar-header {
    flex-shrink: 0;
    padding: 15px 10px; /* Reducido de 1.5rem */
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h4 {
    margin: 0;
    font-size: 1.1rem; /* Reducido */
    font-weight: 600;
    margin-bottom: 2px;
}

.sidebar-header small {
    font-size: 0.75rem; /* Reducido */
}

/* MENÚ DEL SIDEBAR */
.sidebar-menu {
    padding: 10px 0; /* Reducido */
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Títulos de sección del menú */
.menu-section-title {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.7rem; /* Reducido de 0.75rem */
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 8px 15px 4px 15px; /* Reducido padding vertical */
    margin-top: 8px; /* Reducido de 15px */
    margin-bottom: 2px; /* Reducido de 5px */
}

/* Elementos del menú */
.sidebar-menu .menu-item {
    padding: 8px 15px; /* Reducido de 12px a 8px */
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.85rem; /* Reducido de 0.95rem */
    margin: 1px 8px; /* Reducido margen */
    border-radius: 6px;
}

.sidebar-menu .menu-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: white;
    transform: translateX(3px);
}

.sidebar-menu .menu-item.active {
    background: rgba(255,255,255,0.15);
    color: white;
    border-left-color: #ffc107;
    font-weight: 500;
}

.sidebar-menu .menu-item i {
    width: 20px; /* Reducido de 25px */
    min-width: 20px;
    margin-right: 10px;
    font-size: 1rem; /* Reducido de 1.1rem */
    text-align: center;
}

.sidebar-menu .menu-item span {
    font-size: 0.85rem; /* Reducido */
    line-height: 1.2; /* Reducido interlineado */
}

/* FOOTER DEL SIDEBAR - CORREGIDO (sin position fixed) */
.sidebar .sidebar-footer {
    padding: 12px 15px !important; /* Reducido */
    flex-shrink: 0;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.3) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .sidebar-footer small {
    font-size: 0.75rem; /* Reducido */
    display: block;
    margin-bottom: 8px; /* Reducido */
}

.sidebar .sidebar-footer .btn {
    font-size: 0.85rem; /* Reducido */
    padding: 6px 12px; /* Reducido */
    width: 100%;
}

/* SCROLLBAR DEL SIDEBAR */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Espacio extra al final del menú para evitar superposición */
.sidebar-menu::after {
    content: '';
    display: block;
    height: 100px;
}

/* AJUSTES RESPONSIVOS PARA SIDEBAR */
@media (max-height: 700px) {
    /* En pantallas pequeñas, reducir aún más el espaciado */
    .sidebar-menu .menu-item {
        padding: 6px 15px;
        font-size: 0.8rem;
    }
    
    .menu-section-title {
        padding: 6px 15px 3px 15px;
        font-size: 0.65rem;
    }
    
    .sidebar-header {
    flex-shrink: 0;
        padding: 10px;
    }
    
    .sidebar .sidebar-footer {
        padding: 10px 12px !important;
    flex-shrink: 0;
    }
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s;
}

.topbar {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
}

.content-area {
    padding: 2rem;
}

/* ========================================
   CARDS
   ======================================== */
.stat-card {
    border-radius: 10px;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.stat-card .card-body {
    padding: 1.5rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.stat-icon.bg-primary-soft {
    background: rgba(13, 110, 253, 0.1);
    color: var(--primary-color);
}

.stat-icon.bg-success-soft {
    background: rgba(25, 135, 84, 0.1);
    color: var(--success-color);
}

.stat-icon.bg-warning-soft {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

.stat-icon.bg-danger-soft {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.stat-icon.bg-info-soft {
    background: rgba(13, 202, 240, 0.1);
    color: var(--info-color);
}

/* ========================================
   TABLES
   ======================================== */
.table-card {
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.table-responsive {
    border-radius: 10px;
}

.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    color: #495057;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    padding: 0.5em 0.8em;
    font-weight: 500;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    border-radius: 6px;
    padding: 0.5rem 1.2rem;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* ========================================
   FORMS
   ======================================== */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 0.6rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* ========================================
   MODALES
   ======================================== */
.modal-content {
    border-radius: 10px;
    border: none;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0b5ed7 100%);
    color: white;
    border-radius: 10px 10px 0 0;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }
    
    .sidebar.active {
        margin-left: 0;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-area {
        padding: 1rem;
    }
    
    .topbar {
        padding: 1rem;
    }
}

/* ========================================
   UTILIDADES
   ======================================== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

.shadow-sm-hover:hover {
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.15) !important;
}

.hover-shadow {
    transition: box-shadow 0.3s ease;
}

.hover-shadow:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.15) !important;
}

/* ========================================
   LOGO
   ======================================== */
.logo-login {
    max-width: 35px; /* Reducido de 50px */
    height: 35px; /* Reducido */
    margin-right: 8px;
}

/* ========================================
   GRADIENTES DE FONDO
   ======================================== */
.bg-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}



/* ============================================================
   ESTILOS PARA IMPRESIÓN DE FICHAS TÉCNICAS
   Agregar al final del <style> en ver_ficha.php
   ============================================================ */

/* Estilos para modo de impresión */
@media print {
    /* Ocultar elementos no necesarios */
    .sidebar,
    .top-bar,
    .topbar,
    .btn,
    button,
    .no-print,
    nav,
    .breadcrumb,
    .btn-group,
    .alert {
        display: none !important;
    }
    
    /* Ajustar el contenido principal */
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .container-fluid {
        padding: 10mm !important;
    }
    
    /* Configuración de página */
    @page {
        size: letter;
        margin: 15mm;
    }
    
    body {
        font-size: 11pt !important;
        color: #000 !important;
        background: white !important;
    }
    
    /* Encabezados */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        color: #000 !important;
    }
    
    /* Tablas */
    table {
        page-break-inside: avoid;
        border-collapse: collapse !important;
    }
    
    table, th, td {
        border: 1px solid #000 !important;
    }
    
    th {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Cards y secciones */
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        margin-bottom: 10mm;
    }
    
    .section-title {
        background-color: #e0e0e0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        page-break-after: avoid;
        border: 1px solid #000 !important;
    }
    
    /* Info sections */
    .info-section {
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
    }
    
    .info-value {
        border: 1px solid #ddd !important;
    }
    
    /* Badges */
    .badge {
        border: 1px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Evitar saltos de página */
    .info-section,
    .card-body,
    tr {
        page-break-inside: avoid;
    }
    
    /* Logo y encabezado */
    .print-header {
        text-align: center;
        margin-bottom: 5mm;
        padding-bottom: 5mm;
        border-bottom: 2px solid #000;
    }
    
    .print-header img {
        max-width: 150px;
        height: auto;
    }
    
    /* Pie de página */
    .print-footer {
        position: fixed;
        bottom: 0;
        width: 100%;
        text-align: center;
        font-size: 9pt;
        border-top: 1px solid #000;
        padding-top: 2mm;
    }
}

/* Estilos adicionales para pantalla cuando print=1 */
.print-mode .sidebar,
.print-mode .top-bar,
.print-mode .topbar,
.print-mode nav,
.print-mode .breadcrumb {
    display: none !important;
}

.print-mode .main-content {
    margin-left: 0 !important;
    padding: 20px !important;
    width: 100% !important;
    max-width: 100% !important;
}

.print-mode .btn-group {
    display: none !important;
}

/* Botón de imprimir en modo print */
.print-btn-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

@media print {
    .print-btn-container {
        display: none !important;
    }
}

/* ============================================================
   SCRIPT PARA MODO DE IMPRESIÓN
   Agregar al final del <script> en ver_ficha.php
   ============================================================ */

/*
// Detectar modo de impresión
const urlParams = new URLSearchParams(window.location.search);
const printMode = urlParams.get('print');

if (printMode === '1') {
    // Agregar clase al body
    document.body.classList.add('print-mode');
    
    // Agregar botón de imprimir
    const printBtn = document.createElement('div');
    printBtn.className = 'print-btn-container no-print';
    printBtn.innerHTML = `
        <button class="btn btn-primary btn-lg" onclick="window.print()">
            <i class="fas fa-print me-2"></i>Imprimir Ficha
        </button>
        <button class="btn btn-secondary btn-lg ms-2" onclick="window.close()">
            <i class="fas fa-times me-2"></i>Cerrar
        </button>
    `;
    document.body.appendChild(printBtn);
    
    // Auto-imprimir después de cargar
    window.addEventListener('load', function() {
        setTimeout(function() {
            window.print();
        }, 800);
    });
}
*//* ============================================================================
   PARCHE DE CORRECCIÓN PARA SIDEBAR
   Añade este código AL FINAL de tu archivo style.css
   Soluciona el problema del botón "Cerrar Sesión" que se monta sobre el menú
   ============================================================================ */

/* CORRECCIÓN PRINCIPAL: Usar Flexbox en el Sidebar */
.sidebar {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding-bottom: 0 !important;
}

/* Header del sidebar: No se encoge */
.sidebar-header {
    flex-shrink: 0 !important;
}

/* Menú del sidebar: Ocupa espacio disponible y tiene scroll interno */
.sidebar-menu {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-bottom: 10px !important;
}

/* Eliminar el espacio extra que causa problemas */
.sidebar-menu::after {
    display: none !important;
    content: none !important;
    height: 0 !important;
}

/* Scrollbar personalizado para el menú */
.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Footer del sidebar: Siempre visible al final */
.sidebar-footer {
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 10 !important;
    padding: 12px 15px !important;
}

/* Asegurar que el botón de logout sea visible */
.logout-btn {
    width: 100% !important;
    background-color: #dc3545 !important;
    border: none !important;
    color: white !important;
    padding: 8px 15px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s !important;
}

.logout-btn:hover {
    background-color: #bb2d3b !important;
    transform: translateY(-2px) !important;
}

/* ============================================================================
   FIN DEL PARCHE DE CORRECCIÓN
   ============================================================================ */