/* ===================================
   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;
    }
}