/* ═══════════════════════════════════════════════════════════
   NKS OS — Mobile & Touch Responsive Styles
   ═══════════════════════════════════════════════════════════ */

/* Prevent iOS zoom on double tap and accidental pinch-zoom */
* { touch-action: manipulation; }

/* Mobilni prvky skryty na desktopu */
.fm-mobile-sidebar-toggle {
    display: none;
}

/* ─── Mobile breakpoint: < 768px ─────────────────────────── */
@media (max-width: 768px) {

    /* Desktop icons — larger touch targets */
    .desktop-icon {
        min-width: 80px;
        min-height: 80px;
        padding: 12px 8px;
        width: 80px;
        height: 80px;
    }
    .desktop-icon-image {
        font-size: 36px !important;
    }
    .desktop-icon-label {
        font-size: 11px;
    }

    /* Desktop icons container — account for 52px taskbar */
    .desktop-icons {
        bottom: 52px;
    }
    .windows-container {
        bottom: 52px;
    }

    /* Taskbar — taller for touch */
    .taskbar {
        height: 52px;
        padding: 0 8px;
        gap: 6px;
    }
    .start-button {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 40px;
    }
    /* Skryt textovy popis u user chip pro usporu mista */
    .taskbar-user-name {
        display: none;
    }
    .taskbar-user-chip {
        padding: 5px 8px;
    }
    .task-item {
        padding: 6px 10px;
        font-size: 12px;
        max-width: 120px;
        min-height: 36px;
    }
    .system-tray {
        gap: 4px;
        padding: 0 4px;
    }
    .tray-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    .clock {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 60px;
    }

    /* Start menu — full width na mobilu */
    .start-menu {
        width: 100vw !important;
        left: 0 !important;
        bottom: 52px !important;
        max-height: 75vh;
        border-radius: 12px 12px 0 0;
    }
    .start-menu-header {
        padding: 14px 16px;
    }
    .start-menu-search {
        padding: 10px 16px;
    }
    .start-menu-content {
        padding: 12px 16px;
    }
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }
    .app-item {
        padding: 12px 8px;
        min-height: 80px;
    }
    .app-icon {
        font-size: 28px;
        margin-bottom: 6px;
    }
    .app-name {
        font-size: 11px;
    }
    .recent-app-item {
        min-height: 48px;
    }
    .start-menu-footer {
        padding: 10px 16px;
    }
    .quick-setting-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .power-button {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Okna — fullscreen na mobilu */
    .window {
        width: 100vw !important;
        height: calc(100vh - 52px) !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        transform: none !important;
        min-width: unset !important;
        min-height: unset !important;
    }
    .window .window-titlebar {
        border-radius: 0;
        height: 48px;
    }
    .window-control {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    .window-control.close {
        font-size: 20px;
    }
    /* Skryt resize handles na mobilu */
    .window-resize-handle {
        display: none !important;
    }
    /* Snap overlay skryt na mobilu */
    #snap-overlay {
        display: none !important;
    }
    /* Maximalizovana okna — stejna vyska jako normalni na mobilu */
    .window.maximized {
        height: calc(100vh - 52px) !important;
    }
    /* Snap layouts picker — skryt na mobilu */
    .snap-layouts-picker {
        display: none !important;
    }

    /* Toast notifikace — roztazit na celou sirku */
    .nc-toasts {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    .nc-toast {
        border-radius: 8px;
    }
    /* Legacy notifikace */
    .notifications-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    .notification {
        min-width: unset;
        max-width: 100%;
    }

    /* Context menu — sirsi polozky pro dotyk */
    .context-menu-item {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    .context-menu {
        min-width: 220px;
    }

    /* Dialog — responzivni */
    .dialog-box {
        width: 92vw !important;
        max-width: 420px;
        min-width: unset;
        margin: 16px;
    }
    .dialog-buttons button {
        min-height: 44px;
        padding: 10px 20px;
    }

    /* File Manager sidebar — posuvny na mobilu */
    .fm-sidebar {
        position: absolute;
        left: -210px;
        z-index: 10;
        transition: left 0.2s ease;
        height: 100%;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
    }
    .fm-sidebar.mobile-open {
        left: 0;
    }
    /* Hamburger tlacitko pro otvirani sidebaru v FM */
    .fm-mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        cursor: pointer;
        font-size: 18px;
        border-radius: 6px;
        background: var(--input-bg, rgba(255,255,255,0.05));
        transition: background 0.15s;
        flex-shrink: 0;
    }
    .fm-mobile-sidebar-toggle:hover {
        background: var(--hover-overlay, rgba(255,255,255,0.08));
    }

    /* Systemove vyhledavani — plna sirka */
    .system-search-overlay .search-container {
        width: 95vw;
        max-width: none;
    }

    /* Network monitor tabs — posuvne */
    .net-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .net-tabs::-webkit-scrollbar {
        display: none;
    }

    /* Skryt virtual desktops switcher na mobilu */
    .virtual-desktops-switcher {
        display: none;
    }

    /* Alt+Tab — responzivni */
    .alt-tab-container {
        flex-wrap: wrap;
        gap: 10px;
        padding: 16px;
        max-width: 90vw;
        max-height: 70vh;
        overflow-y: auto;
    }
    .alt-tab-item {
        min-width: 80px;
        padding: 12px;
    }
    .alt-tab-icon {
        font-size: 32px;
    }

    /* Toolbar buttons — vetsi dotykove cile */
    .toolbar-button {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 40px;
    }

    /* Boot screen — mensi logo na mobilu */
    .boot-logo {
        font-size: 36px;
    }
    .boot-progress {
        width: 260px;
    }

    /* Login screen — responzivni */
    .login-container {
        width: 90vw;
        max-width: 360px;
    }
}

/* ─── Tablet breakpoint: 769px — 1024px ──────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    .desktop-icon {
        min-width: 70px;
        padding: 10px 6px;
    }
    .desktop-icon-image {
        font-size: 32px !important;
    }
    .window {
        min-width: 320px;
        min-height: 240px;
    }
    .taskbar {
        height: 48px;
    }
    .start-menu {
        bottom: 58px !important;
        width: 420px;
        max-height: 80vh;
    }
    .context-menu-item {
        padding: 10px 14px;
        min-height: 40px;
    }
    .window-control {
        width: 34px;
        height: 34px;
    }
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}

/* ─── Touch-specificka vylepseni (pointer: coarse = dotykovy displej) ─── */
@media (pointer: coarse) {
    /* Vetsi dotykove cile dle WCAG 2.5.5 (44x44 px) */
    button,
    .toolbar-button,
    .side-item,
    .file-item,
    .net-table td,
    .recent-app-item,
    .app-item {
        min-height: 44px;
    }

    /* Scrollbar — sirsi pro dotyk */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    /* Odstranit hover efekty na dotyku (zasekavaji se) */
    .file-item:hover {
        transform: none;
    }
    .desktop-icon:hover {
        background: transparent;
    }

    /* Zakazat vyber textu behem tazeni */
    .window-titlebar,
    .desktop-icon,
    .task-item,
    .tray-icon {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Vetsi window controls pro prst */
    .window-control {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* Vetsi start button */
    .start-button {
        min-height: 40px;
    }

    /* Tray ikony — vetsi plocha */
    .tray-icon {
        min-width: 40px;
        min-height: 40px;
    }

    /* Vetsi context menu polozky */
    .context-menu-item {
        min-height: 44px;
    }
}

/* ─── Landscape mobile ─────────────────────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
    .taskbar {
        height: 40px;
    }
    .start-menu {
        bottom: 40px !important;
        max-height: 85vh;
    }
    .window {
        height: calc(100vh - 40px) !important;
    }
    .window.maximized {
        height: calc(100vh - 40px) !important;
    }
    .desktop-icons {
        bottom: 40px;
    }
    .windows-container {
        bottom: 40px;
    }
    /* V landscape rezimu kompaktnejsi toolbar */
    .window .window-titlebar {
        height: 38px;
    }
}

/* ─── PWA standalone mode — safe area insets pro notch displeje ─── */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
    }
    .taskbar {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(52px + env(safe-area-inset-bottom));
    }
    .desktop-icons {
        bottom: calc(52px + env(safe-area-inset-bottom));
    }
    .windows-container {
        bottom: calc(52px + env(safe-area-inset-bottom));
    }
    .start-menu {
        bottom: calc(52px + env(safe-area-inset-bottom)) !important;
    }
}

/* ─── Vysoke rozliseni (retina) — zadne zmeny layoutu ──────── */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .desktop-icon-image,
    .app-icon,
    .tray-icon {
        image-rendering: auto;
    }
}
