/* ========================================
   KIPO - Estilos Responsive
   Mobile First Design
   ======================================== */

/* ========================================
   SIDEBAR RESPONSIVE
   ======================================== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 60;
    background-color: var(--color-primary);
    color: var(--color-bg-white);
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle:hover {
    background-color: #1a2e47;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-speed) ease-in-out;
    margin-left: 16rem;
}

/* ========================================
   TABLET (768px y menores)
   ======================================== */
@media (max-width: 768px) {

    /* Mostrar botón toggle del sidebar */
    .sidebar-toggle {
        display: block;
    }

    /* Sidebar oculto por defecto en móvil */
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-speed) ease-in-out;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Contenido ocupa todo el ancho */
    .content-area {
        margin-left: 0 !important;
    }

    /* Tablas responsivas */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
    }

    /* Dashboard grid a 1 columna */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Dashboard cards más compactas */
    .dashboard-card {
        padding: 1.25rem;
    }

    .dashboard-card-content {
        flex-direction: row;
        gap: 1rem;
    }

    .dashboard-card-value {
        font-size: 1.75rem;
    }

    .dashboard-card-label {
        font-size: 0.875rem;
    }

    .dashboard-card-icon {
        font-size: 2rem;
    }

    /* Grid layouts a 1 columna */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    /* Header responsive */
    .main-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
        padding-left: 4rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Modales más pequeños */
    .modal-content {
        max-width: 95vw;
        margin: 0.5rem;
    }

    /* Botones en columna */
    .btn-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Tarjetas más compactas */
    .card {
        padding: 1rem;
    }

    .dashboard-card-value {
        font-size: 1.5rem;
    }

    .dashboard-card-icon {
        font-size: 2rem;
    }

    /* Info sections */
    .info-section-content {
        grid-template-columns: 1fr;
    }

    /* Formularios */
    .form-group {
        margin-bottom: 1rem;
    }

    /* Tipografía más pequeña */
    h1 {
        font-size: 1.875rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.125rem;
    }

    /* Sidebar user info más compacto */
    .sidebar-user-name {
        font-size: 1rem;
    }

    .sidebar-user-role {
        font-size: 0.875rem;
    }

    /* Padding reducido */
    .p-6 {
        padding: 1.5rem;
    }

    .p-5 {
        padding: 1.25rem;
    }
}

/* ========================================
   MOBILE PEQUEÑO (480px y menores)
   ======================================== */
@media (max-width: 480px) {

    /* Contenedor con menos padding */
    .container {
        padding: 0 0.75rem;
    }

    /* Login card */
    .login-card {
        padding: 1.5rem;
    }

    .login-title {
        font-size: 1.5rem;
    }

    /* Tarjetas */
    .card {
        padding: 0.75rem;
    }

    /* Tablas aún más estrechas */
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    /* Botones más pequeños */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    /* Modal en pantalla completa */
    .modal-content {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-body {
        max-height: calc(100vh - 120px);
    }

    /* Dashboard cards más compactos */
    .dashboard-card {
        padding: 1rem;
    }

    .dashboard-card-value {
        font-size: 1.25rem;
    }

    .dashboard-card-label {
        font-size: 0.75rem;
    }

    .dashboard-card-icon {
        font-size: 1.5rem;
    }

    /* Header aún más compacto */
    .main-header {
        padding: 0.75rem;
        padding-left: 3.5rem;
    }

    .header-title {
        font-size: 1.25rem;
    }

    .header-user-email {
        font-size: 0.75rem;
    }

    /* Sidebar más angosto */
    .sidebar {
        width: 14rem;
    }

    /* Forms inputs más pequeños */
    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Badges más pequeños */
    .badge {
        padding: 0.1875rem 0.5rem;
        font-size: 0.6875rem;
    }

    /* Alertas más compactas */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    /* Info boxes */
    .info-box {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Accordion más compacto */
    .accordion-header {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .accordion-content {
        padding: 1rem;
    }

    /* Espaciado reducido */
    .mt-6 {
        margin-top: 2rem;
    }

    .mt-5 {
        margin-top: 1.5rem;
    }

    .mb-6 {
        margin-bottom: 2rem;
    }

    .mb-5 {
        margin-bottom: 1.5rem;
    }
}

/* ========================================
   LANDSCAPE MOBILE
   ======================================== */
@media (max-height: 600px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }

    .modal-content {
        max-height: 95vh;
    }

    .modal-body {
        max-height: calc(95vh - 100px);
    }
}

/* ========================================
   DESKTOP GRANDE (1200px y mayores)
   ======================================== */
@media (min-width: 1200px) {
    .container {
        max-width: 1200px;
    }

    .content-wrapper {
        max-width: 1400px;
    }

    /* Dashboard con más columnas */
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }

    /* Grids más anchos */
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Formularios en dos columnas */
    .form-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* ========================================
   EXTRA LARGE (1440px y mayores)
   ======================================== */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }

    .content-wrapper {
        max-width: 1600px;
    }

    /* Dashboard cards más grandes */
    .dashboard-card-value {
        font-size: 2.5rem;
    }

    .dashboard-card-icon {
        font-size: 3rem;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {

    .sidebar,
    .sidebar-toggle,
    .header-actions,
    .btn,
    .nav-link {
        display: none !important;
    }

    .content-area {
        margin-left: 0 !important;
    }

    .card,
    .table-container {
        box-shadow: none !important;
        border: 1px solid var(--color-border);
    }

    body {
        background-color: white !important;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Foco visible para navegación por teclado */
*:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

/* ========================================
   UTILIDADES RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }

    .show-desktop {
        display: block !important;
    }
}

/* ========================================
   MEJORAS ADICIONALES DE RESPONSIVIDAD
   ======================================== */

/* Imágenes responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Videos responsive */
video {
    max-width: 100%;
    height: auto;
}

/* Tablas responsive mejoradas */
@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table {
        width: 100%;
        border-collapse: collapse;
    }

    .table-responsive th,
    .table-responsive td {
        white-space: nowrap;
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

/* Formularios responsive */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }

    .form-group {
        width: 100%;
        margin-bottom: 1rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    select,
    textarea {
        width: 100%;
        box-sizing: border-box;
    }
}

/* Grids responsive */
@media (max-width: 768px) {
    .grid-responsive {
        grid-template-columns: 1fr !important;
    }

    .grid-2-responsive {
        grid-template-columns: 1fr !important;
    }

    .grid-3-responsive {
        grid-template-columns: 1fr !important;
    }
}

/* Cards responsive */
@media (max-width: 768px) {
    .card-responsive {
        margin-bottom: 1rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Botones responsive */
@media (max-width: 480px) {
    .btn-responsive {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-group-responsive {
        flex-direction: column;
    }

    .btn-group-responsive .btn {
        width: 100%;
    }
}

/* Modales responsive mejorados */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.5rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

/* Navegación responsive mejorada */
@media (max-width: 768px) {
    .navbar-nav {
        flex-direction: column;
    }

    .nav-item {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .nav-link {
        padding: 0.75rem 1rem;
        display: block;
    }
}

/* Utilidades de espaciado responsive */
@media (max-width: 768px) {
    .p-responsive {
        padding: 1rem !important;
    }

    .m-responsive {
        margin: 1rem !important;
    }

    .px-responsive {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .py-responsive {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* Texto responsive */
@media (max-width: 480px) {
    .text-responsive {
        font-size: 0.875rem;
        line-height: 1.5;
    }

    h1.text-responsive {
        font-size: 1.5rem;
    }

    h2.text-responsive {
        font-size: 1.25rem;
    }

    h3.text-responsive {
        font-size: 1.125rem;
    }
}

/* Contenedores responsive */
@media (max-width: 768px) {
    .container-fluid-responsive {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Flexbox responsive */
@media (max-width: 768px) {
    .flex-responsive {
        flex-direction: column;
    }

    .flex-wrap-responsive {
        flex-wrap: wrap;
    }
}

/* Overflow responsive */
@media (max-width: 768px) {
    .overflow-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}