/* ========================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ======================================== */

/* Estilos base para todos los dispositivos */
* {
    box-sizing: border-box;
}

/* Prevenir zoom en inputs en iOS */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
textarea,
select {
    font-size: 16px !important;
}

/* Contenedor principal responsivo */
.container,
.container-fluid,
main {
    width: 100%;
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
    margin: 0 auto;
}

/* ========================================
   BOTONES DE ACCIÓN CUADRADOS
   ======================================== */
/* Botones de acciones en tablas - más cuadrados */
.btn-group .btn-sm {
    padding: 6px 8px !important; /* Reducir padding vertical */
    width: 32px !important; /* Ancho fijo más pequeño */
    height: 30px !important; /* Alto fijo para hacer cuadrados más pequeños */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    border-radius: 4px !important;
}

/* Iconos dentro de botones de acción */
.btn-group .btn-sm i {
    font-size: 12px !important;
    margin: 0 !important;
}

/* Espaciado entre botones en btn-group */
.btn-group .btn-sm:not(:last-child) {
    margin-right: 2px;
}

/* Colores específicos para botones de acción */
.btn-group .btn-warning {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
}

.btn-group .btn-danger {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
}

.btn-group .btn-secondary {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

/* ========================================
   TABLETS (768px y menores)
   ======================================== */
@media (max-width: 768px) {
    
    /* Sidebar responsivo */
    .sidebar {
        position: fixed !important;
        left: -250px;
        top: 0;
        width: 250px;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
        background: #2c3e50;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Overlay para sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Botón hamburguesa */
    .menu-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 10000;
        background: #2c3e50;
        color: white;
        border: none;
        padding: 10px;
        border-radius: 5px;
        font-size: 18px;
        cursor: pointer;
    }
    
    /* Contenido principal */
    .main-content {
        margin-left: 0 !important;
        padding-top: 60px;
        width: 100%;
    }
    
    /* Tablas responsivas con diseño tipo cards */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Convertir tablas en cards en móviles */
    .mobile-card-table {
        display: block;
        width: 100%;
    }
    
    .mobile-card-table thead {
        display: none;
    }
    
    .mobile-card-table tbody {
        display: block;
        width: 100%;
    }
    
    .mobile-card-table tr {
        display: block;
        margin-bottom: 15px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: 15px;
        border: 1px solid #e0e0e0;
    }
    
    .mobile-card-table td {
        display: block;
        text-align: left !important;
        border: none !important;
        padding: 8px 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .mobile-card-table td:last-child {
        border-bottom: none;
    }
    
    .mobile-card-table td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #333;
        display: inline-block;
        width: 120px;
        min-width: 120px;
    }
    
    /* Tablas normales para cuando no se puede usar cards */
    table:not(.mobile-card-table) {
        min-width: 600px;
        font-size: 14px;
    }
    
    table:not(.mobile-card-table) th, 
    table:not(.mobile-card-table) td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* Cards en dashboard */
    .row .col-md-3,
    .row .col-lg-3,
    .row .col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 15px;
    }
    
    .card {
        margin-bottom: 15px;
    }
    
    /* Formularios */
    .form-group {
        margin-bottom: 15px;
    }
    
    .input100 {
        padding: 0 15px;
        height: 45px;
        font-size: 16px;
    }
    
    /* Botones */
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        margin-bottom: 10px;
        width: 100%;
        display: block;
    }
    
    /* Excluir botones de acción del estilo de bloque */
    .btn-group .btn {
        width: auto !important;
        display: inline-flex !important;
        margin-bottom: 0 !important;
    }
    
    /* Botones específicos que no deben ser de ancho completo */
    .btn-create-user,
    .btn-submit-form,
    .btn-filter {
        width: auto !important;
        display: inline-flex !important;
        margin-bottom: 10px !important;
        padding: 8px 16px !important;
        font-size: 14px !important;
    }
    
    /* Mantener btn-group horizontal en móviles */
    .btn-group {
        display: flex;
        flex-direction: row;
        gap: 2px;
        justify-content: center;
    }
    
    /* Logo */
    .logo-container {
        top: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
    }
    
    /* Navegación */
    .nav-tabs {
        flex-direction: column;
    }
    
    .nav-tabs .nav-link {
        margin-bottom: 5px;
        text-align: center;
    }
}

/* ========================================
   MÓVILES (480px y menores)
   ======================================== */
@media (max-width: 480px) {
    
    /* Contenedores más compactos */
    .container,
    .container-fluid,
    main {
        padding-left: 5px;
        padding-right: 5px;
    }
    
    /* Formulario de login */
    .wrap-login100 {
        padding: 30px 20px;
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .login100-form-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 20px;
    }
    
    /* Botones de acción cuadrados para móviles pequeños */
    .btn-group .btn-sm {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        padding: 4px 0 !important;
        margin: 0 1px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 10px !important;
    }
    
    /* Mantener btn-group horizontal en móviles pequeños */
    .btn-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 1px !important;
        justify-content: center !important;
    }
    
    .login100-form-logo img {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        background: transparent;
    }
    
    /* Ajustes específicos para inputs en login móvil */
    .wrap-input100 {
        margin-bottom: 25px;
        position: relative;
    }
    
    .input100 {
        padding: 0 50px 0 45px !important;
        height: 45px;
        font-size: 15px;
    }
    
    .input-icon {
        left: 15px;
        font-size: 16px;
        z-index: 2;
    }
    
    .toggle-password-icon {
        right: 15px !important;
        font-size: 16px;
        z-index: 2;
    }
    
    /* Ajustes para checkbox y botón */
    .contact100-form-checkbox {
        margin: 20px 0;
        font-size: 14px;
    }
    
    .container-login100-form-btn {
        margin-top: 25px;
    }
    
    .login100-form-btn {
        height: 45px;
        font-size: 16px;
    }
    
    /* Contenedor principal del login */
    .container-login100 {
        padding: 20px 15px;
        min-height: 100vh;
    }
    
    .limiter {
        width: 100%;
        padding: 0;
    }
    
    /* Tablas ultra compactas */
    table {
        font-size: 12px;
        min-width: 500px;
    }
    
    th, td {
        padding: 6px 4px;
    }
    
    /* Cards apiladas */
    .card-body {
        padding: 15px;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
    
    /* Estadísticas en dashboard */
    .dashboard-stats {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
        text-align: center;
    }
    
    .stat-number {
        font-size: 1.8rem;
        font-weight: bold;
    }
    
    .stat-label {
        font-size: 0.9rem;
        color: #666;
    }
    
    /* Botones más grandes para touch */
    .btn {
        min-height: 48px;
        font-size: 16px;
    }
    
    /* Botones específicos más pequeños en móviles pequeños */
    .btn-create-user,
    .btn-submit-form,
    .btn-filter {
        min-height: 36px !important;
        font-size: 14px !important;
        padding: 6px 12px !important;
        width: auto !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 5px !important;
    }
    
    /* Menu hamburguesa más grande */
    .menu-toggle {
        padding: 12px;
        font-size: 20px;
    }
    
    /* Sidebar más ancho en móviles pequeños */
    .sidebar {
        width: 280px;
        left: -280px;
    }
    
    /* Textos más legibles */
    body {
        font-size: 16px;
        line-height: 1.5;
    }
    
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.6rem; }
    h3 { font-size: 1.4rem; }
    h4 { font-size: 1.2rem; }
    h5 { font-size: 1.1rem; }
    h6 { font-size: 1rem; }
    
    /* Modal responsivo */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-body {
        padding: 15px;
    }
    
    /* Alertas */
    .alert {
        padding: 10px;
        font-size: 14px;
        margin: 10px 0;
    }
    
    /* Paginación */
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .page-link {
        padding: 8px 12px;
        margin: 2px;
    }
}

/* ========================================
   MÓVILES MUY PEQUEÑOS (320px y menores)
   ======================================== */
@media (max-width: 320px) {
    
    .wrap-login100 {
        padding: 20px 15px;
        margin: 5px;
    }
    
    .login100-form-logo {
        width: 60px;
        height: 60px;
        margin-bottom: 15px;
        background: none;
        border-radius: 0;
    }
    
    .login100-form-logo img {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        background: transparent;
    }
    
    .input100 {
        padding: 0 45px 0 40px !important;
        height: 40px;
        font-size: 14px;
    }
    
    .input-icon {
        left: 12px;
        font-size: 14px;
    }
    
    .toggle-password-icon {
        right: 12px !important;
        font-size: 14px;
    }
    
    .login100-form-title {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .contact100-form-checkbox {
        margin: 15px 0;
        font-size: 13px;
    }
    
    .login100-form-btn {
        height: 40px;
        font-size: 14px;
    }
    
    .container-login100 {
        padding: 15px 10px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    table {
        font-size: 11px;
    }
    
    th, td {
        padding: 4px 2px;
    }
    
    .card-body {
        padding: 10px;
    }
    
    .logo-container {
        width: 40px;
        height: 40px;
        top: 10px;
        right: 10px;
    }
}

/* ========================================
   UTILIDADES RESPONSIVAS
   ======================================== */

/* Ocultar en móviles */
@media (max-width: 768px) {
    .d-mobile-none {
        display: none !important;
    }
    
    .d-mobile-block {
        display: block !important;
    }
    
    .d-mobile-flex {
        display: flex !important;
    }
}

/* Mostrar solo en móviles */
@media (min-width: 769px) {
    .d-desktop-none {
        display: none !important;
    }
    
    .menu-toggle {
        display: none !important;
    }
    
    /* Estilos para desktop - contenido principal */
    .main-content {
        margin-left: 270px !important;
        padding: 20px;
        width: calc(100% - 270px);
        transition: margin-left 0.3s ease;
    }
    
    /* Contenedor fluido para desktop */
    .container-fluid {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ========================================
   SCROLL Y OVERFLOW
   ======================================== */

/* Evitar scroll horizontal */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Scroll suave */
html {
    scroll-behavior: smooth;
}

/* Scrollbar personalizada para webkit */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .sidebar,
    .menu-toggle,
    .btn,
    .logo-container {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.3;
    }
    
    table {
        border-collapse: collapse;
        width: 100%;
    }
    
    th, td {
        border: 1px solid #000;
        padding: 5px;
    }
}