/**
 * ========================================
 * IA4Os - Responsive Styles
 * Estilos Responsive del Sistema
 * ========================================
 */

/* Variables responsive */
:root {
    --mobile-breakpoint: 768px;
    --tablet-breakpoint: 992px;
    --desktop-breakpoint: 1200px;
    --large-desktop-breakpoint: 1400px;
}

/* Base responsive para el sistema */
.responsive-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Desktop Layout */
@media (min-width: 1200px) {
    .desktop-grid {
        grid-template-columns: repeat(12, 1fr);
        gap: 24px;
    }
    
    .window-container {
        min-width: 400px;
        min-height: 300px;
    }
    
    .dock {
        flex-direction: row;
        height: 80px;
        width: auto;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .top-menu-bar {
        height: 40px;
        padding: 0 24px;
    }
}

/* Tablet Layout */
@media (max-width: 1199px) and (min-width: 768px) {
    .tablet-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 20px;
    }
    
    .window-container {
        min-width: 320px;
        min-height: 250px;
    }
    
    .dock {
        flex-direction: row;
        height: 70px;
        width: auto;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .dock-app {
        width: 50px;
        height: 50px;
    }
    
    .top-menu-bar {
        height: 36px;
        padding: 0 20px;
    }
    
    /* Ajustes para ventanas en tablet */
    .window {
        max-width: 90vw;
        max-height: 85vh;
    }
}

/* Mobile Layout */
@media (max-width: 767px) {
    .mobile-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
    
    /* Layout móvil para desktop */
    #desktop {
        padding: 8px;
    }
    
    /* Dock móvil */
    .dock {
        flex-direction: row;
        height: 60px;
        width: calc(100% - 16px);
        bottom: 8px;
        left: 8px;
        right: 8px;
        transform: none;
        justify-content: center;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .dock::-webkit-scrollbar {
        display: none;
    }
    
    .dock-app {
        width: 45px;
        height: 45px;
        min-width: 45px;
        font-size: 20px;
    }
    
    .dock-app .dock-tooltip {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* Top menu bar móvil */
    .top-menu-bar {
        height: 32px;
        padding: 0 12px;
        font-size: 12px;
    }
    
    .menu-item {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    /* Ventanas en móvil */
    .window {
        position: fixed !important;
        top: 32px !important;
        left: 0 !important;
        width: 100% !important;
        height: calc(100vh - 100px) !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        max-width: none !important;
        max-height: none !important;
    }
    
    .window-header {
        height: 40px;
        padding: 0 12px;
    }
    
    .window-title {
        font-size: 14px;
    }
    
    .window-controls {
        gap: 8px;
    }
    
    .window-control {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .window-content {
        padding: 12px;
    }
    
    /* Ajustes específicos para aplicaciones en móvil */
    .terminal {
        font-size: 12px;
    }
    
    .terminal-input {
        font-size: 12px;
        padding: 8px;
    }
    
    .finder-app {
        flex-direction: column;
    }
    
    .finder-sidebar {
        width: 100%;
        height: 120px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .settings-app {
        flex-direction: column;
    }
    
    .settings-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding: 8px;
    }
    
    .settings-category {
        white-space: nowrap;
        min-width: 100px;
        text-align: center;
        margin-right: 8px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .responsive-container {
        padding: 0 8px;
    }
    
    .dock-app {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 18px;
    }
    
    .window-header {
        height: 36px;
        padding: 0 8px;
    }
    
    .window-title {
        font-size: 12px;
    }
    
    .window-control {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
    
    .window-content {
        padding: 8px;
    }
    
    .top-menu-bar {
        font-size: 10px;
        padding: 0 8px;
    }
}

/* Orientación landscape en móviles */
@media (max-width: 767px) and (orientation: landscape) {
    .window {
        height: calc(100vh - 70px) !important;
    }
    
    .dock {
        height: 50px;
    }
    
    .dock-app {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .top-menu-bar {
        height: 28px;
    }
}

/* Ajustes para pantallas táctiles */
@media (pointer: coarse) {
    .dock-app,
    .window-control,
    .menu-item,
    button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    .dock-app {
        touch-action: manipulation;
    }
    
    .window {
        touch-action: pan-y;
    }
    
    .window-header {
        touch-action: none;
    }
}

/* Ajustes para modo oscuro en dispositivos móviles */
@media (max-width: 767px) and (prefers-color-scheme: dark) {
    .window {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .dock {
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(20px);
    }
    
    .top-menu-bar {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* Ajustes para notificaciones responsive */
@media (max-width: 767px) {
    .notification {
        position: fixed;
        top: 40px;
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
    }
}

/* Grid responsivo para aplicaciones */
.app-grid {
    display: grid;
    gap: 16px;
    padding: 16px;
}

@media (min-width: 1200px) {
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 24px;
        padding: 24px;
    }
}

@media (max-width: 1199px) and (min-width: 768px) {
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 20px;
        padding: 20px;
    }
}

@media (max-width: 767px) {
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 16px;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
        padding: 12px;
    }
}

/* Utilidades responsive */
.hide-mobile {
    display: block;
}

.hide-tablet {
    display: block;
}

.hide-desktop {
    display: block;
}

.show-mobile {
    display: none;
}

.show-tablet {
    display: none;
}

.show-desktop {
    display: none;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
}

@media (max-width: 1199px) and (min-width: 768px) {
    .hide-tablet {
        display: none !important;
    }
    
    .show-tablet {
        display: block !important;
    }
}

@media (min-width: 1200px) {
    .hide-desktop {
        display: none !important;
    }
    
    .show-desktop {
        display: block !important;
    }
}

/* Espaciado responsive */
.p-responsive {
    padding: 8px;
}

.m-responsive {
    margin: 8px;
}

@media (min-width: 768px) {
    .p-responsive {
        padding: 16px;
    }
    
    .m-responsive {
        margin: 16px;
    }
}

@media (min-width: 1200px) {
    .p-responsive {
        padding: 24px;
    }
    
    .m-responsive {
        margin: 24px;
    }
}

/* Texto responsive */
.text-responsive {
    font-size: 12px;
}

@media (min-width: 768px) {
    .text-responsive {
        font-size: 14px;
    }
}

@media (min-width: 1200px) {
    .text-responsive {
        font-size: 16px;
    }
}

/* Scroll responsivo */
.scroll-container {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.scroll-container::-webkit-scrollbar {
    height: 6px;
}

.scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

@media (max-width: 767px) {
    .scroll-container::-webkit-scrollbar {
        height: 4px;
    }
}

/* Flexbox responsive */
.flex-responsive {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (min-width: 768px) {
    .flex-responsive {
        flex-direction: row;
        gap: 16px;
    }
}

/* Ajustes para package installer responsive */
@media (max-width: 767px) {
    .package-installer {
        height: 100vh;
    }
    
    .installer-header {
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .installer-filters {
        position: sticky;
        top: 60px;
        z-index: 99;
    }
    
    .installer-content {
        padding-bottom: 80px; /* Espacio para el dock */
    }
}

/* Mejoras de accesibilidad responsive */
@media (max-width: 767px) {
    button, 
    .clickable,
    a {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Animaciones responsive */
@media (prefers-reduced-motion: reduce) {
    .window,
    .dock-app,
    .notification,
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .dock,
    .top-menu-bar,
    .window-controls,
    .notification {
        display: none !important;
    }
    
    .window {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        border: 1px solid #000 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: white !important;
        color: black !important;
        page-break-inside: avoid;
    }
    
    .window-content {
        padding: 20px !important;
    }
}

/* Dark mode responsive adjustments */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #0A84FF;
        --background-color: #000000;
        --surface-color: #1C1C1E;
        --text-color: #FFFFFF;
        --border-color: #38383A;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .window,
    .dock,
    .top-menu-bar {
        border-width: 2px !important;
        border-style: solid !important;
    }
    
    button,
    .dock-app {
        border: 2px solid currentColor !important;
    }
}

/* Reduced transparency for better performance */
@media (max-width: 767px) {
    .window,
    .dock,
    .top-menu-bar,
    .notification {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}