/* Selection Styles */
.desktop-icon.selected, .folder-item.selected {
    background-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

body {
    /* Обои в высоком разрешении для ПК */
    background: url('https://images.unsplash.com/photo-1477346611705-65d1883cee1e?q=80&w=2070&auto=format&fit=crop') no-repeat center center fixed;
    background-size: cover;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
}

/* Glassmorphism */
.glass-dock {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-menu {
    background: rgba(245, 245, 247, 0.9);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Window Styles */
.os-window {
    position: absolute;
    background: #F5F5F7;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: visible; /* Changed to visible for resize handles */
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.1);
    /* Minimize animation update */
    transition: all 0.3s linear;
    transform-origin: center bottom;
    pointer-events: auto;
    min-width: 300px;
    min-height: 200px;
}

.os-window.window-minimized {
    opacity: 0;
    transform: scale(0.1) translateY(400px);
    pointer-events: none !important;
    filter: blur(10px);
}

.os-window.window-dark {
    background-color: #1c1c1e;
    color: #ffffff;
}
.os-window.window-dark .window-header {
    background-color: #2C2C2E;
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
}
.os-window.window-dark .window-title {
    color: #ffffff;
}

/* Container for content clipping to preserve rounded corners */
.window-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    width: 100%;
    height: 100%;
}

/* Remove border-radius when maximized */
.os-window[data-maximized="true"] .window-content-wrapper {
    border-radius: 0;
}

/* Remove transition during drag/resize for responsiveness */
.os-window.no-transition {
    transition: none !important;
}

.os-window.dragging, .desktop-icon.dragging {
    transition: none !important;
    z-index: 9999 !important;
}

/* Resizers */
.resizer { position: absolute; z-index: 100; }
.resizer-r { right: -5px; top: 0; bottom: 0; width: 10px; cursor: e-resize; }
.resizer-b { bottom: -5px; left: 0; right: 0; height: 10px; cursor: s-resize; }
.resizer-l { left: -5px; top: 0; bottom: 0; width: 10px; cursor: w-resize; }
.resizer-t { top: -5px; left: 0; right: 0; height: 10px; cursor: n-resize; }
.resizer-br { right: -5px; bottom: -5px; width: 15px; height: 15px; cursor: se-resize; }
.resizer-bl { left: -5px; bottom: -5px; width: 15px; height: 15px; cursor: sw-resize; }
.resizer-tr { right: -5px; top: -5px; width: 15px; height: 15px; cursor: ne-resize; }
.resizer-tl { left: -5px; top: -5px; width: 15px; height: 15px; cursor: nw-resize; }

/* Snap Preview */
#snap-preview {
    position: absolute;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    z-index: 9000;
    pointer-events: none;
    display: none;
    transition: all 0.1s ease-out;
}

/* Snap Assist */
#snap-assist-overlay {
    position: absolute;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 8000;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 20px;
    box-sizing: border-box;
    /* Grid layout handled in JS or below */
    overflow-y: auto;
}

#snap-assist-overlay.show {
    opacity: 1;
}

.snap-assist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    width: 100%;
    height: 100%;
    align-content: center;
    justify-items: center;
}

.snap-assist-item {
    width: 100%;
    aspect-ratio: 4/3;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    border: 1px solid rgba(255,255,255,0.5);
}

.snap-assist-item:hover {
    transform: scale(1.05);
    background: white;
}

.snap-assist-icon {
    font-size: 48px;
    color: #333;
    margin-bottom: 10px;
}

.snap-assist-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-align: center;
    padding: 0 10px;
}


.window-header {
    height: 38px;
    background: #EBEBEB;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: default;
    flex-shrink: 0;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
}
.close-btn { background: #FF5F57; border: 1px solid #E0443E; }
.min-btn { background: #FEBC2E; border: 1px solid #D89E24; }
.max-btn { background: #28C840; border: 1px solid #1AAB29; }

.control-btn:hover::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    color: rgba(0,0,0,0.5);
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}
.close-btn:hover::after { content: '\f00d'; }
.min-btn:hover::after { content: '\f068'; }
.max-btn:hover::after { content: '\f067'; }

/* Desktop Icon Styles */
.desktop-icon {
    position: absolute;
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 12px;
    transition: background-color 0.2s, transform 0.2s;
}

.desktop-icon:hover {
    background-color: rgba(255,255,255,0.15);
}

.desktop-icon:active {
    filter: brightness(0.9);
}

/* Dock Indicators */
.dock-dot {
    position: absolute;
    bottom: -6px;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}
.dock-item.active .dock-dot {
    opacity: 1;
}

.dock-item {
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.glass-dock.drag-over {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #C1C1C1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #A8A8A8;
}

/* Install Screen */
#install-screen {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 20000;
    display: flex;
    flex-col: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    padding: 20px;
}

/* --- Notification System --- */
#toast-container {
    position: fixed;
    top: 40px; /* Below top bar (28px) + padding */
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 350px;
    pointer-events: none;
}

.harmony-toast {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    border-radius: 20px;
    padding: 16px;
    color: #1a1a1a;
    transform-origin: top right;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.harmony-toast.show {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.harmony-toast.hide {
    opacity: 0;
    transform: scale(0.9) translateX(100px);
    margin-top: -100px; /* Collapse space */
}

.harmony-toast .progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    width: 100%;
    transform-origin: left;
    transform: scaleX(1);
    transition: transform linear;
    opacity: 0.7;
}

/* Toast Inputs */
.toast-reply-input {
    background: rgba(0,0,0,0.04);
    border: none;
    border-radius: 12px;
    padding: 10px 12px;
    width: 100%;
    outline: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.toast-reply-input:focus {
    background: rgba(0,0,0,0.08);
}

.harmony-toast:active {
    transform: scale(0.98);
}

/* --- iOS Unlock Animations --- */
@keyframes iosFlyIn {
    0% {
        transform: scale(3) translateY(20px);
        opacity: 0;
        filter: blur(10px);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
        filter: blur(0);
    }
}

@keyframes dockFlyIn {
    0% {
        transform: translateY(100px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.app-icon-animate {
    animation: iosFlyIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0; /* Initially hidden */
}

.dock-animate {
    animation: dockFlyIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.1s;
    opacity: 0; /* Initially hidden */
}

/* --- iOS Drag & Folder Animations --- */

/* Folder Hint (Glass Backdrop) */
.folder-hint {
    position: absolute;
    width: 60px; /* Slightly larger than standard icon (56px) */
    height: 60px;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.4s cubic-bezier(0.3, 1.5, 0.5, 1);
    pointer-events: none;
    z-index: -1;
    top: 5px; /* Adjust based on icon positioning inside wrapper */
}

/* Parent container state when hint is active */
.desktop-icon.can-drop .folder-hint {
    opacity: 1;
    transform: scale(1.1);
}

.desktop-icon.can-drop > .icon-container-wrapper {
    transform: scale(0.85);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Global Squeeze Effect */
.is-dragging-mode .desktop-icon:not(.dragging):not(.selected) {
    transform: scale(0.92);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    opacity: 0.8;
}

/* Folder Grid Layout */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    padding: 3px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.mini-icon {
    border-radius: 2px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.mini-content {
    transform: scale(0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;
    color: white;
}

/* Pop Animation */
@keyframes popIn {
    from { opacity: 0; transform: scale(0.2); }
    to { opacity: 1; transform: scale(1); }
}

.animate-pop {
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* --- Mobile Adaptation (Max Width 768px) --- */
@media (max-width: 768px) {
    /* Hide Desktop Top Bar */
    .h-7.bg-black\/20.backdrop-blur-md {
        display: none !important;
    }

    /* Adjust Desktop Container */
    #desktop {
        height: 100vh;
        overflow: hidden;
    }

    /* Desktop Icons Layer - Grid Layout */
    #desktop-icons-layer {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important; /* Force 4 columns like iOS */
        grid-auto-rows: min-content !important;
        gap: 15px !important;
        padding: 40px 20px 100px 20px !important; /* Bottom padding for Dock */
        overflow-y: auto !important;
        align-content: start !important;
        position: absolute !important;
        inset: 0 !important;
    }

    /* Desktop Icon Reset */
    .desktop-icon {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        width: 100% !important; /* Fill grid cell */
        height: auto !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }

    .desktop-icon .icon-container-wrapper {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: auto !important;
        border-radius: 14px !important; /* More rounded like iOS */
    }

    /* Force square aspect ratio for folders and widgets, but allow custom logos to flex */
    .desktop-icon.type-folder .icon-container-wrapper,
    .desktop-icon.type-widget .icon-container-wrapper,
    .desktop-icon.type-icon .icon-container-wrapper {
        aspect-ratio: 1 / 1 !important;
    }

    .desktop-icon.has-custom-logo .icon-container-wrapper {
        aspect-ratio: auto !important;
    }

    .desktop-icon.has-custom-logo .icon-container-wrapper img {
        object-fit: contain !important;
        height: auto !important;
        position: static !important;
    }

    .desktop-icon span {
        font-size: 11px !important;
        margin-top: 4px !important;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Dock Adjustments */
    #dock-wrapper {
        bottom: 15px !important;
        width: 90% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    #dock-container {
        padding: 10px !important;
        border-radius: 20px !important;
        justify-content: space-around !important;
        width: 100% !important;
        background: rgba(255, 255, 255, 0.25) !important; /* Slightly more visible */
    }

    .dock-item {
        width: 48px !important;
        height: 48px !important;
        margin: 0 !important;
    }

    /* Windows - Full Screen Force */
    .os-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        transform: none !important;
        box-shadow: none !important;
    }

    .window-content-wrapper {
        border-radius: 0 !important;
    }

    .window-header {
        height: 44px !important; /* Taller for touch */
        padding: 0 10px !important;
    }

    /* Hide unnecessary window controls, keep Close */
    .control-btn.min-btn,
    .control-btn.max-btn {
        display: none !important;
    }

    .control-btn.close-btn {
        width: 20px !important;
        height: 20px !important;
    }

    /* User Widget (Top Right) - Hide completely */
    #user-widget-wrapper {
        display: none !important;
    }

    /* Lock Screen */
    #lock-clock {
        font-size: 4rem !important;
    }
}
