/* ========================================
   FARMA - ESTILOS RESPONSIVOS
   Versión 1.0
   ======================================== */

/* ===== VARIABLES RESPONSIVAS ===== */
:root {
    --sidebar-width: 250px;
    --sidebar-width-collapsed: 0;
    --header-height: 60px;
    --container-padding: 20px;
}

/* ===== BREAKPOINTS ===== */
/* Móvil: < 576px */
/* Tablet: 576px - 768px */
/* Desktop pequeño: 768px - 992px */
/* Desktop: 992px - 1200px */
/* Desktop grande: > 1200px */

/* ===== CONTENEDOR PRINCIPAL ===== */
@media (max-width: 1200px) {
    .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .card-body {
        padding: 15px !important;
    }
}

/* ===== SIDEBAR RESPONSIVE ===== */
@media (max-width: 768px) {
    #sidebar {
        margin-left: -250px;
        position: fixed;
        z-index: 1000;
        width: 250px;
        height: 100%;
        transition: margin 0.3s ease-in-out;
    }
    
    #sidebar.active {
        margin-left: 0;
        box-shadow: 0 0 20px rgba(0,0,0,0.3);
    }
    
    #content {
        width: 100%;
        margin-left: 0;
        transition: margin 0.3s ease-in-out;
    }
    
    #content.active {
        margin-left: 250px;
    }
    
    /* Overlay para móvil */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Ajustes del header en móvil */
    .navbar {
        padding: 10px 15px !important;
    }
    
    .navbar .user-info {
        display: none !important; /* Ocultar en móvil, mostrar solo avatar */
    }
    
    .navbar .avatar {
        display: flex !important;
    }
}

/* ===== TABLAS RESPONSIVAS ===== */
@media (max-width: 992px) {
    .table-responsive {
        border: 0;
        margin-bottom: 15px;
    }
    
    .table-responsive table {
        width: 100%;
    }
    
    /* Cards en lugar de tablas para móvil */
    .table-responsive.mobile-cards thead {
        display: none;
    }
    
    .table-responsive.mobile-cards tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .table-responsive.mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        border: none;
        border-bottom: 1px solid #eee;
    }
    
    .table-responsive.mobile-cards tbody td:last-child {
        border-bottom: none;
    }
    
    .table-responsive.mobile-cards tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 10px;
        color: #666;
    }
}

/* ===== CARDS Y GRIDS ===== */
@media (max-width: 768px) {
    .card-deck {
        display: block;
    }
    
    .card-deck .card {
        margin-bottom: 15px;
    }
    
    /* Stats cards en fila */
    .row .col-md-3,
    .row .col-md-4,
    .row .col-md-6 {
        margin-bottom: 15px;
    }
    
    /* Dashboard stats */
    .card-stats {
        padding: 15px !important;
    }
    
    .card-stats .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .card-stats .stat-value {
        font-size: 1.5rem;
    }
}

/* ===== FORMULARIOS RESPONSIVOS ===== */
@media (max-width: 768px) {
    form .row {
        margin-right: -5px;
        margin-left: -5px;
    }
    
    form [class*="col-"] {
        padding-right: 5px;
        padding-left: 5px;
    }
    
    .form-control, .form-select {
        font-size: 16px !important; /* Evita zoom en iOS */
        padding: 10px 12px;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 10px;
        padding: 12px !important;
        font-size: 16px;
    }
    
    .btn-group {
        display: flex;
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
        margin: 0 2px;
    }
    
    /* Botones flotantes para móvil */
    .btn-floating {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        z-index: 100;
    }
    
    .btn-floating i {
        margin: 0;
        font-size: 24px;
    }
    
    .btn-floating span {
        display: none;
    }
}

/* ===== MODALES RESPONSIVOS ===== */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px;
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
    }
    
    .modal-footer .btn {
        margin: 5px 0;
    }
}

/* ===== DASHBOARD RESPONSIVO ===== */
@media (max-width: 768px) {
    .dashboard-widget {
        padding: 15px !important;
    }
    
    .widget-title {
        font-size: 0.9rem;
    }
    
    .widget-value {
        font-size: 1.5rem;
    }
    
    /* Charts responsivos */
    canvas {
        max-width: 100%;
        height: auto !important;
    }
}

/* ===== PERFILES RESPONSIVOS ===== */
@media (max-width: 768px) {
    .profile-header {
        padding: 20px !important;
        text-align: center;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
        margin: 0 auto 15px;
    }
    
    .profile-info {
        text-align: center;
    }
    
    .profile-stats {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .profile-stats .stat-item {
        flex: 1 1 calc(50% - 5px);
        min-width: auto;
    }
}

/* ===== REPORTES RESPONSIVOS ===== */
@media (max-width: 992px) {
    .report-filters {
        flex-direction: column;
    }
    
    .report-filters .col-md-3,
    .report-filters .col-md-4,
    .report-filters .col-md-6 {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .report-chart {
        height: 250px !important;
    }
}

/* ===== TIMELINE RESPONSIVO ===== */
@media (max-width: 768px) {
    .timeline {
        padding-left: 20px;
    }
    
    .timeline-item {
        margin-bottom: 20px;
    }
    
    .timeline-left {
        left: -20px;
    }
    
    .timeline-content {
        margin-left: 20px;
        padding: 10px;
    }
}

/* ===== SELECT2 RESPONSIVO ===== */
@media (max-width: 768px) {
    .select2-container {
        width: 100% !important;
    }
    
    .select2-selection {
        min-height: 45px !important;
    }
    
    .select2-selection__rendered {
        line-height: 45px !important;
    }
}

/* ===== NAVEGACIÓN RESPONSIVA ===== */
@media (max-width: 576px) {
    .navbar .breadcrumb {
        display: none;
    }
    
    .page-title {
        font-size: 1.2rem;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .content-header .btn-group {
        margin-top: 10px;
        width: 100%;
    }
}

/* ===== ALERTAS RESPONSIVAS ===== */
@media (max-width: 768px) {
    .alert {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .alert i {
        margin-right: 8px;
    }
}

/* ===== DROPDOWNS RESPONSIVOS ===== */
@media (max-width: 768px) {
    .dropdown-menu {
        width: 100%;
        position: static !important;
        float: none;
        box-shadow: none;
        border: 1px solid rgba(0,0,0,0.1);
    }
}

/* ===== TOUCH OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    /* Aumentar áreas táctiles */
    .btn,
    .nav-link,
    .dropdown-item,
    .list-group-item {
        min-height: 44px;
        padding: 12px 15px !important;
    }
    
    /* Mejorar scroll */
    .modal-body,
    .sidebar-menu-container {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Eliminar hovers en móvil */
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* ===== IMPRESIÓN ===== */
@media print {
    #sidebar,
    .navbar,
    .btn,
    .footer {
        display: none !important;
    }
    
    #content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    body {
        background: white;
        font-size: 12pt;
    }
}

/* Estilos para el menú en móvil */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    #sidebar.active {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }

    .sidebar-overlay.active {
        display: block;
    }

    #content {
        margin-left: 0 !important;
        width: 100%;
        transition: margin-left 0.3s ease;
    }

    #content.shifted {
        margin-left: 280px !important;
    }

    /* Ajustes para el header móvil */
    .mobile-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
        color: white;
        z-index: 1030;
        padding: 0 15px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    .mobile-header .menu-toggle {
        background: transparent;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    .mobile-header .menu-toggle:hover {
        background: rgba(255,255,255,0.1);
    }

    .mobile-header .logo {
        font-size: 18px;
        font-weight: bold;
    }

    .mobile-header .user-avatar {
        width: 36px;
        height: 36px;
        background: rgba(255,255,255,0.2);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        font-size: 16px;
    }

    /* Ocultar navbar de escritorio en móvil */
    .navbar {
        display: none !important;
    }

    /* Ajustar contenido principal */
    .container-fluid {
        margin-top: 70px !important;
        padding: 0 10px !important;
    }
}

/* Dispositivos muy pequeños */
@media (max-width: 480px) {
    .mobile-header .logo {
        font-size: 16px;
    }

    .mobile-header .menu-toggle {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    .mobile-header .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    #sidebar {
        width: 260px;
        left: -260px;
    }

    #sidebar.active {
        left: 0;
    }

    #content.shifted {
        margin-left: 260px !important;
    }
}