/* ===================================
   RESPONSIVE DESIGN - M&R ABOGADOS
   =================================== */

/* ========================================
   SIDEBAR RESPONSIVE
   ======================================== */

/* Desktop (por defecto) */
.sidebar {
    width: 280px;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transition: all 0.3s ease;
    z-index: 1000;
    background: #2c3e50;
}

.main-content {
    margin-left: 280px;
    transition: all 0.3s ease;
}

/* Botón hamburguesa (oculto en desktop) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1100;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
    transition: all 0.3s ease;
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

/* Overlay para cerrar sidebar en móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    cursor: pointer;
}

/* ========================================
   TABLETS Y PANTALLAS MEDIANAS (768px - 1024px)
   ======================================== */
@media (max-width: 1024px) {
    .container-fluid {
        padding: 15px;
    }
    
    .card {
        margin-bottom: 15px;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .btn-group {
        flex-wrap: wrap;
    }
    
    /* Sidebar más estrecho */
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
}

/* ========================================
   TABLETS PEQUEÑAS Y MÓVILES (max 768px)
   ======================================== */
@media (max-width: 768px) {
    /* Mostrar botón hamburguesa */
    .sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 50px;
        height: 50px;
    }
    
    /* Sidebar oculto por defecto en móvil */
    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    
    /* Sidebar visible cuando tiene clase 'active' */
    .sidebar.active {
        left: 0 !important;
    }
    
    /* Overlay visible cuando sidebar está activo */
    .sidebar.active ~ .sidebar-overlay,
    .sidebar-overlay.show {
        display: block !important;
    }
    
    /* Estilos del sidebar en móvil */
    .sidebar-header {
        padding: 20px;
        background: rgba(0, 0, 0, 0.2);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .sidebar-header h2 {
        color: white;
        font-size: 18px;
        margin: 0;
    }
    
    .sidebar-nav {
        padding: 10px 0;
    }
    
    .sidebar-nav .nav-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 15px 20px;
        color: rgba(255, 255, 255, 0.8);
        text-decoration: none;
        transition: all 0.3s ease;
        border-left: 3px solid transparent;
    }
    
    .sidebar-nav .nav-link:hover {
        background: rgba(255, 255, 255, 0.1);
        color: white;
        border-left-color: #3498db;
    }
    
    .sidebar-nav .nav-link.active {
        background: rgba(52, 152, 219, 0.2);
        color: white;
        border-left-color: #3498db;
    }
    
    .sidebar-nav .nav-link i {
        font-size: 18px;
        width: 20px;
        text-align: center;
    }
    
    /* Main content ocupa todo el ancho */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
        padding: 70px 15px 20px 15px;
    }
    
    /* Ajustes generales */
    .navbar-brand img {
        height: 35px !important;
    }
    
    .row {
        margin: 0;
    }
    
    .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-12 {
        width: 100%;
        padding: 10px;
    }
    
    /* Dashboard stats en columna */
    .dashboard-stats,
    .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .stats-card, .stat-card {
        width: 100% !important;
        margin-bottom: 0;
    }
    
    /* Títulos más pequeños */
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.2rem;
    }
    
    /* Tablas scrolleables */
    table {
        min-width: 600px;
        font-size: 14px;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }
    
    /* Botones de acción en tablas más pequeños */
    td .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Timeline seguimientos */
    .timeline-item {
        padding-left: 1rem;
    }
    
    .timeline-card {
        padding: 1rem;
    }
    
    /* Agenda tareas */
    .agenda-tarea {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .agenda-tarea-content {
        width: 100%;
    }
}

/* ========================================
   MÓVILES PEQUEÑOS (max 576px)
   ======================================== */
@media (max-width: 576px) {
    /* Header más compacto */
    .navbar {
        flex-direction: column;
        padding: 10px;
    }
    
    .navbar-brand img {
        height: 30px !important;
    }
    
    /* Botones ocupan todo el ancho */
    .btn {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .btn-group .btn {
        width: auto;
        flex: 1;
    }
    
    /* Modales más pequeños */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 10px;
    }
    
    /* Formularios más compactos */
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    label {
        font-size: 0.9rem;
    }
    
    input, select, textarea {
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    /* Tablas más pequeñas */
    table {
        font-size: 0.85rem;
        min-width: 500px;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    /* Cards más compactos */
    .card-body {
        padding: 10px;
    }
    
    /* Sidebar más estrecho en móviles pequeños */
    .sidebar {
        width: 260px;
        left: -260px;
    }
    
    .sidebar-toggle {
        top: 10px;
        left: 10px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    /* Gráficos responsive */
    canvas {
        max-height: 250px !important;
    }
    
    /* Timeline más compacto */
    .timeline-card {
        padding: 0.75rem;
    }
    
    .timeline-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .timeline-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    /* Indicador "Solo Lectura" más pequeño */
    #indicador-lectura {
        top: 10px !important;
        right: 10px !important;
        font-size: 0.75rem !important;
        padding: 0.35rem 0.75rem !important;
    }
}

/* ========================================
   LANDSCAPE MODE (dispositivos horizontales)
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }
    
    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ========================================
   DESKTOP - Ocultar elementos móviles
   ======================================== */
@media (min-width: 769px) {
    .sidebar-toggle {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .hide-desktop {
        display: none !important;
    }
    
    .mobile-only {
        display: none !important;
    }
}

/* ========================================
   UTILIDADES RESPONSIVE
   ======================================== */

/* Ocultar en móvil */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
}

/* ========================================
   FASE 1 — DASHBOARD RESPONSIVE
   Agregar al final de responsive.css
   ======================================== */

/* --- Stats grid: 2x2 en móvil --- */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.68rem;
    }

    /* Dashboard cards en columna */
    .dashboard-content {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Estados panel en 1 columna */
    .estados-panel {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .estado-item {
        padding: 1rem;
    }

    /* Gráfico de tipos */
    #chartTipos {
        max-height: 200px !important;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }
}

/* --- Agenda Hoy en Dashboard --- */
@media (max-width: 768px) {
    .agenda-resumen {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }

    .resumen-card {
        padding: 0.75rem;
    }

    .resumen-valor {
        font-size: 1.2rem;
    }

    .agenda-hoy-item {
        padding: 10px 12px;
        gap: 8px;
    }

    .agenda-hoy-titulo {
        font-size: 13px;
    }

    .agenda-hoy-meta {
        gap: 5px;
    }

    /* Header section en móvil: título arriba, botón abajo */
    .header-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .header-section h1 {
        font-size: 1.4rem;
    }

    .header-section .btn {
        width: 100%;
        justify-content: center;
    }
}

/* --- Top bar + hamburguesa: evitar choque --- */
@media (max-width: 768px) {
    .top-bar {
        padding: 8px 12px 8px 72px; /* deja espacio al botón hamburguesa (50px + 15px offset + margen) */
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .user-menu-btn {
        font-size: 13px;
        padding: 6px 10px;
    }

    /* Ocultar nombre de usuario en móvil muy pequeño, dejar solo el ícono */
    @media (max-width: 400px) {
        #userMenuNombre {
            display: none;
        }
    }
}

/* --- Agenda tabs en móvil --- */
@media (max-width: 768px) {
    .agenda-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 0;
    }

    .agenda-tab-btn {
        white-space: nowrap;
        padding: 0.75rem 0.9rem;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .agenda-user-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .agenda-user-selector input {
        min-width: unset;
        width: 100%;
    }

    .agenda-content {
        padding: 1rem;
    }
}

/* ========================================
   FASE 2 — AGENDA / PENDIENTES RESPONSIVE
   Agregar al final de responsive.css
   ======================================== */

@media (max-width: 768px) {

    /* Contenedor principal de cada tarea */
    .agenda-tarea {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 10px 12px;
    }

    /* Fila superior: checkbox + hora + tipo + badge atrasada */
    .agenda-tarea-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    /* Primera fila dentro del contenido */
    .agenda-tarea-content {
        flex-wrap: nowrap;
    }

    /* Hora destacada */
    .agenda-tarea-hora {
        font-size: 13px;
        min-width: unset;
    }

    /* Título ocupa todo el ancho */
    .agenda-tarea-titulo {
        max-width: 100%;
        white-space: normal;
        font-size: 13px;
        width: 100%;
        flex-shrink: unset;
    }

    /* Descripción ocupa todo el ancho */
    .agenda-tarea-desc {
        width: 100%;
        white-space: normal;
        font-size: 12px;
    }

    /* Usuario en su propia línea */
    .agenda-tarea-usuario {
        font-size: 11px;
    }

    /* Botones de acción al final, alineados a la derecha */
    .agenda-tarea-actions {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 4px;
    }

    /* Expediente como chip pequeño */
    .agenda-tarea-expediente {
        font-size: 11px;
        padding: 2px 6px;
    }

    /* Checkbox más fácil de tocar */
    .agenda-checkbox input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    /* Fila meta: hora + tipo + badge en una línea */
    .agenda-tarea-content {
        display: grid;
        grid-template-areas:
            "hora tipo badge"
            "titulo titulo titulo"
            "desc desc expediente"
            "usuario usuario acciones";
        grid-template-columns: auto auto 1fr;
        align-items: center;
        gap: 4px 8px;
    }

    .agenda-tarea-hora       { grid-area: hora; }
    .agenda-tarea-tipo       { grid-area: tipo; }
    .agenda-badge-atrasada   { grid-area: badge; justify-self: end; }
    .agenda-tarea-titulo     { grid-area: titulo; max-width: 100%; white-space: normal; }
    .agenda-tarea-desc       { grid-area: desc; white-space: normal; }
    .agenda-tarea-expediente { grid-area: expediente; justify-self: end; }
    .agenda-tarea-usuario    { grid-area: usuario; }
    .agenda-tarea-actions    { grid-area: acciones; justify-self: end; margin-left: 0; }

    /* Resumen cards agenda: ya cubierto en Fase 1 */

    /* Filtros de agenda */
    .timeline-filters {
        flex-wrap: wrap;
        gap: 4px;
    }

    .filter-btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .agenda-tarea {
        padding: 8px 10px;
    }

    .agenda-tarea-content {
        grid-template-areas:
            "hora tipo"
            "titulo titulo"
            "desc desc"
            "usuario acciones";
        grid-template-columns: auto 1fr;
    }

    /* Ocultar badge atrasada en pantallas muy pequeñas si hay poco espacio */
    .agenda-badge-atrasada {
        grid-area: tipo;
        justify-self: end;
    }

    .agenda-tarea-expediente {
        display: none; /* Se puede ver en el detalle */
    }
}

/* ========================================
   FASE 3 — EXPEDIENTES / CLIENTES RESPONSIVE
   Agregar al final de responsive.css
   ======================================== */

@media (max-width: 768px) {

    /* --- Filtros apilados --- */
    .filters-panel {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 0.75rem;
        align-items: center;
    }

    .filters-panel select {
        width: 100%;
        min-width: unset;
        margin: 0;
    }

    /* Botón limpiar filtros ocupa toda la fila */
    .filters-panel .btn {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: center;
    }

    /* --- Barra de búsqueda --- */
    .search-bar {
        padding: 0.625rem 0.75rem;
    }

    .search-bar input {
        font-size: 16px; /* evita zoom iOS */
    }

    /* --- Tabla expedientes: scroll horizontal cómodo --- */
    #view-expedientes .table-container,
    #view-clientes .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Indicador visual de scroll */
        background:
            linear-gradient(to right, white 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
            linear-gradient(to right, rgba(0,0,0,0.08), rgba(0,0,0,0)),
            linear-gradient(to left, rgba(0,0,0,0.08), rgba(0,0,0,0));
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-position: 0 0, 100% 0, 0 0, 100% 0;
        background-attachment: local, local, scroll, scroll;
    }

    /* Reducir columnas menos importantes en expedientes */
    #tablaExpedientes th:nth-child(6), /* Usuario */
    #tablaExpedientes td:nth-child(6),
    #tablaExpedientes th:nth-child(7), /* Oficina */
    #tablaExpedientes td:nth-child(7) {
        display: none;
    }

    #view-expedientes .data-table {
        min-width: 750px; /* reducido desde 1200px */
    }

    /* Ajustar padding de celdas */
    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Botones de acción en tabla más compactos */
    .data-table .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
        margin: 1px;
    }

    /* --- Detalle expediente: campos en 1 columna --- */
    .exp-fila {
        grid-template-columns: 1fr;
    }

    .exp-filas {
        gap: 4px;
    }

    /* Estado cambio: campos en 1 columna */
    .estado-cambio-campos {
        grid-template-columns: 1fr;
    }

    /* Editar expediente: campos en 1 columna */
    .edit-fila {
        grid-template-columns: 1fr;
    }

    .edit-campo-wide {
        grid-column: span 1;
    }

    /* Info panel en 1 columna */
    .info-panel {
        grid-template-columns: 1fr;
    }

    /* Info grid en 1 columna */
    .info-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Tabs de detalle expediente: scroll horizontal */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }

    /* Equipo chips en móvil */
    .equipo-chips {
        gap: 4px;
    }

    .equipo-chip {
        font-size: 0.78rem;
        padding: 3px 8px;
    }

    /* Anotación form en 1 columna */
    .anotacion-fila {
        grid-template-columns: 1fr;
    }

    .anotacion-campo-wide {
        grid-column: span 1;
    }

    .anotacion-checks-fila {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .anotacion-adjunto {
        margin-left: 0;
        width: 100%;
    }

    .anotacion-adjunto input[type="file"] {
        max-width: 100%;
    }

    /* Acciones de anotación */
    .anotacion-acciones {
        flex-direction: row;
        width: 100%;
    }

    .btn-guardar-anotacion,
    .btn-cancelar-anotacion {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {

    /* Ocultar más columnas en pantallas muy pequeñas */
    #tablaExpedientes th:nth-child(5), /* Abogado */
    #tablaExpedientes td:nth-child(5),
    #tablaClientes th:nth-child(4),
    #tablaClientes td:nth-child(4) {
        display: none;
    }

    #view-expedientes .data-table {
        min-width: 520px;
    }

    /* Modal a pantalla completa en móvil pequeño */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 12px 12px 0 0;
        position: fixed;
        bottom: 0;
        max-height: 92vh;
    }

    .modal {
        align-items: flex-end;
    }
}

/* ========================================
   FASE 5 — REPORTES Y DETALLES FINALES
   Agregar al final de responsive.css
   ======================================== */

@media (max-width: 768px) {

    /* --- Reportes: tabs en scroll horizontal --- */
    .reporte-tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding: 4px;
    }

    .reporte-tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.78rem;
        padding: 6px 12px;
    }

    /* --- Reportes: grid en 1 columna --- */
    .reporte-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .reporte-card-full {
        grid-column: 1;
    }

    .reporte-card {
        padding: 12px;
    }

    /* --- Filtros de reportes apilados --- */
    .reporte-filtros {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }

    .reporte-filtro-campo {
        width: 100%;
    }

    .reporte-filtro-campo input,
    .reporte-filtro-campo select {
        width: 100%;
    }

    .btn-filtrar-reporte,
    .btn-descargar-reporte {
        width: 100%;
        justify-content: center;
        height: 38px;
    }

    /* --- Buscador 360 --- */
    .buscador360-container {
        padding: 10px 0;
    }

    .buscador360-input {
        font-size: 15px;
        padding: 12px 12px 12px 44px;
    }

    .resultado360-item {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* --- Login responsive --- */
    .login-container {
        padding: 28px 20px;
        width: 95%;
    }

    .login-header i {
        font-size: 38px;
    }

    .login-header h1 {
        font-size: 20px;
    }

    /* reCAPTCHA centrado y sin desborde */
    .g-recaptcha {
        transform: scale(0.88);
        transform-origin: left center;
    }

    /* --- Configuración: tablas --- */
    #view-configuracion .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #view-configuracion .data-table {
        min-width: 600px;
    }

    /* Submenú configuración en móvil */
    .submenu {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        border-radius: 12px 12px 0 0;
        padding: 12px 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
        z-index: 2000;
    }

    .submenu-item {
        padding: 14px 24px;
        font-size: 0.95rem;
    }

    /* --- Timeline tabla en expediente --- */
    .timeline-table-wrapper {
        max-height: 280px;
    }

    .timeline-table {
        font-size: 0.72rem;
    }

    /* Ocultar columna usuario en timeline móvil */
    .timeline-table th:nth-child(5),
    .timeline-table td:nth-child(5) {
        display: none;
    }

    /* --- Indicador solo lectura --- */
    #indicador-lectura {
        top: 65px !important;
        right: 10px !important;
        font-size: 0.7rem !important;
        padding: 0.3rem 0.6rem !important;
    }

    /* --- Modales generales desde abajo en móvil --- */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 14px 14px 0 0;
        position: fixed;
        bottom: 0;
        max-height: 92vh;
        overflow-y: auto;
    }

    .modal {
        align-items: flex-end;
    }

    /* Excepción: modal visor de documentos */
    .modal-viewer .modal-content {
        max-height: 95vh;
    }

    /* --- Formularios en modales --- */
    .modal-content form {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {

    /* reCAPTCHA más pequeño en móviles muy pequeños */
    .g-recaptcha {
        transform: scale(0.78);
        transform-origin: left center;
    }

    /* Tabla reportes compacta */
    #tabla-carga-abogados th,
    #tabla-carga-abogados td,
    #tabla-oficinas-reporte th,
    #tabla-oficinas-reporte td {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
}

/* ========================================
   FIX GRÁFICOS REPORTES
   Agregar al final de responsive.css
   ======================================== */

@media (max-width: 768px) {

    /* Contenedor del canvas con altura fija */
    .reporte-card {
        position: relative;
    }

    /* Todos los canvas de reportes */
    #chartAbogados,
    #chartOficinas,
    #chartEstados {
        max-height: 220px !important;
        width: 100% !important;
        height: 220px !important;
    }

    /* Chart del dashboard */
    #chartTipos {
        max-height: 180px !important;
        width: 100% !important;
        height: 180px !important;
    }

    /* Wrapper para que Chart.js respete el tamaño */
    .reporte-card canvas {
        max-width: 100%;
        display: block;
        margin: 0 auto;
    }

    /* Tablas dentro de reportes con scroll */
    .reporte-card .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #tabla-carga-abogados,
    #tabla-oficinas-reporte,
    #tabla-nuevos-procesos {
        min-width: 500px;
    }

    /* Nuevos procesos: ocultar columnas menos críticas */
    #tabla-nuevos-procesos th:nth-child(7),
    #tabla-nuevos-procesos td:nth-child(7) {
        display: none;
    }
}

@media (max-width: 480px) {
    #chartAbogados,
    #chartOficinas,
    #chartEstados {
        max-height: 180px !important;
        height: 180px !important;
    }
}

/* ========================================
   FIX SUBMENÚ CONFIGURACIÓN EN MÓVIL
   Agregar al final de responsive.css
   ======================================== */

@media (max-width: 768px) {

    /* Submenú inline dentro del sidebar, no flotando */
    #submenu-configuracion {
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 100% !important;
        background: rgba(0, 0, 0, 0.2) !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        border-top: 1px solid rgba(255,255,255,0.05);
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    #submenu-configuracion .submenu-item {
        padding: 12px 20px 12px 48px; /* indentado para indicar jerarquía */
        font-size: 0.875rem;
        color: rgba(255,255,255,0.7);
        border-left: 3px solid transparent;
    }

    #submenu-configuracion .submenu-item:hover,
    #submenu-configuracion .submenu-item.active {
        background: rgba(255,255,255,0.08);
        color: white;
        border-left-color: #3b82f6;
    }

    #submenu-configuracion .submenu-item i {
        margin-right: 10px;
        font-size: 0.85rem;
        width: 16px;
    }

    /* Flecha del menú configuración rota cuando está abierto */
    .menu-item.has-submenu .submenu-arrow {
        transition: transform 0.3s ease;
    }

    .menu-item.has-submenu.open .submenu-arrow {
        transform: rotate(180deg);
    }
}

/* ========================================
   FIX TABLAS CLIENTES / EXPEDIENTES
   Agregar al final de responsive.css
   ======================================== */

@media (max-width: 768px) {

    /* ---- CLIENTES: ocultar solo ID y Email ---- */
    #tablaClientes th:nth-child(1), /* ID */
    #tablaClientes td:nth-child(1),
    #tablaClientes th:nth-child(4), /* Email */
    #tablaClientes td:nth-child(4) {
        display: none;
    }

    /* Clientes: scroll horizontal con todas las columnas visibles */
    #view-clientes .data-table {
        min-width: 480px;
    }

    /* ---- EXPEDIENTES: ocultar solo Usuario y Oficina ---- */
    #tablaExpedientes th:nth-child(6), /* Usuario */
    #tablaExpedientes td:nth-child(6),
    #tablaExpedientes th:nth-child(7), /* Oficina */
    #tablaExpedientes td:nth-child(7) {
        display: none;
    }

    #view-expedientes .data-table {
        min-width: 700px !important;
    }

    /* Botones de acción más grandes y fáciles de tocar */
    #tablaClientes .btn-sm,
    #tablaExpedientes .btn-sm {
        padding: 0.35rem 0.6rem;
        font-size: 0.78rem;
        margin: 2px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Celda de acciones no se comprima */
    #tablaClientes td:last-child,
    #tablaExpedientes td:last-child {
        white-space: nowrap;
        width: 1%;
    }

    /* Nombre cliente con ellipsis si es muy largo */
    #tablaClientes td:nth-child(2) {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Nº expediente compacto */
    #tablaExpedientes td:nth-child(1) {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Cliente en expediente con ellipsis */
    #tablaExpedientes td:nth-child(2) {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    /* En pantallas muy pequeñas ocultar también Cédula en clientes */
    #tablaClientes th:nth-child(3),
    #tablaClientes td:nth-child(3) {
        display: none;
    }

    /* Queda: Nombre + Teléfono + Acciones */
    #view-clientes .data-table {
        min-width: 320px;
    }

    /* Expedientes: ocultar también Tipo y Fecha */
    #tablaExpedientes th:nth-child(3),
    #tablaExpedientes td:nth-child(3),
    #tablaExpedientes th:nth-child(8),
    #tablaExpedientes td:nth-child(8) {
        display: none;
    }

    #view-expedientes .data-table {
        min-width: 480px !important;
    }
}