/* Windows Taskbar - Metallic Reflective 3D Style */
:root {
    --taskbar-bg-color: #8b0000; /* Dark Red */
}

.windows-taskbar {
    position: fixed;
    bottom: 0px;
    left: 0px;
    right: 0px;
    height: 38px;
    width: 100vw;
    /* Completely opaque gradient to eliminate any transparency "gaps" */
    background: linear-gradient(           /* Top white solid edge */
        var(--taskbar-bg-color) 4%, 
        var(--taskbar-bg-color) 47%,            /* Solid white center shimmering strip */
        var(--taskbar-bg-color) 53%,
        var(--taskbar-bg-color) 92%,
        #1a0000 100%            /* Dark opaque bottom */
    );
    box-shadow: 
        inset 0 1px 1px #ff0000,
        inset 0 -2px 5px rgba(0, 0, 0, 0.4),
        0 -3px 20px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0; 
    z-index: 10009;
    box-sizing: border-box;
}

.taskbar-left {
    display: flex;
    align-items: center;
    padding-left: 3px; /* Exactly 3px from left edge */
}

.taskbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-right: 25px; /* Stay well within screen */
}

/* Move controls up when Windows mode is active to prevent overlap */
.taskbar-mode .immersive-controls {
    bottom: 95px !important;
}

.taskbar-mode .restore-ui-btn {
    bottom: 45px !important;
}

.start-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 6px;
    padding: 0;
}

.start-btn img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.start-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.2);
}

.start-btn:active {
    transform: scale(0.95);
}

.taskbar-time {
    color: white;
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.taskbar-color-picker {
    position: relative;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.taskbar-color-picker input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* Start Menu - Glassmorphism */
.windows-start-menu {
    position: fixed;
    bottom: 46px; /* Optimized for shorter taskbar */
    left: 8px;
    width: 450px;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    z-index: 10010;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: startMenuIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
}

@keyframes startMenuIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.start-menu-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name {
    font-weight: 700;
    font-size: 18px;
}

.admin-badge {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: black;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.start-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 24px;
    max-height: 400px;
    overflow-y: auto;
}

.start-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.start-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.start-icon {
    font-size: 32px;
}

.start-label {
    font-size: 12px;
    text-align: center;
    font-weight: 500;
}

.start-menu-footer {
    padding: 15px 24px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: flex-end;
}

.start-footer-btn {
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.start-footer-btn.logout:hover {
    background: rgba(255, 77, 77, 0.2);
    color: #ff4d4d;
}

/* Ensure dock is visible even when immersive-active if selected */
.immersive-active .dock-container.force-show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    bottom: 20px !important;
    z-index: 10009;
}

/* --- Mobile Responsive Adjustments --- */
@media screen and (max-width: 768px) {
    /* Reposition Dock to 6px from bottom */
    .immersive-active .dock-container.force-show {
        bottom: 6px !important;
    }

    /* Only show immersive controls when immersive mode is active */
    .immersive-active .immersive-controls {
        display: flex !important;
        position: fixed !important;
        top: 50% !important;
        bottom: auto !important;
        transform: translateY(-50%) !important;
        right: 15px !important;
        flex-direction: column !important;
        gap: 12px !important;
        z-index: 10005 !important;
    }
    
    /* Ensure it is hidden when not active (override previously greedy rule) */
    .immersive-controls {
        display: none !important;
    }
    .immersive-active .immersive-controls {
        display: flex !important;
    }

    /* Restore button is now nested, style it to match the control stack */
    .immersive-controls .restore-ui-btn {
        position: static !important;
        width: 38px !important;
        height: 38px !important;
        border-radius: 50% !important;
        font-size: 18px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(255, 77, 77, 0.4) !important; /* Slightly distinct red */
        border: 1px solid rgba(255, 77, 77, 0.6) !important;
        margin-top: 5px !important; /* Just a small gap in the stack */
    }

    /* Adapt Windows Start Menu for mobile */
    .windows-start-menu {
        width: 95% !important;
        max-width: 380px !important;
        left: 2.5% !important;
        bottom: 48px !important; /* Above the taskbar */
        border-radius: 12px !important;
        z-index: 100010 !important;
    }

    .start-menu-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        padding: 10px !important;
    }

    /* Adjust Taskbar for mobile */
    .windows-taskbar {
        height: 38px !important;
        padding: 0 10px !important;
    }

    /* Adjust Apps Modal for mobile: guarantee symmetry with transform centering */
    .immersive-apps-modal {
        min-width: 0 !important;
        width: 95vw !important; 
        height: 86vh !important; 
        left: 50% !important; 
        transform: translateX(-50%) !important;
        top: 20px !important; 
        bottom: auto !important;
        z-index: 100020 !important;
        /* Glassmorphism background */
        background: rgba(20, 20, 20, 0.4) !important;
        backdrop-filter: blur(50px) !important;
        -webkit-backdrop-filter: blur(50px) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 24px !important; 
        padding: 0 !important;
        box-sizing: border-box !important;
        display: none !important; /* Hide until toggled */
    }

    .immersive-apps-modal.is-visible {
        display: flex !important;
        animation: slideUpMobile 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
    }

    @keyframes slideUpMobile {
        from { opacity: 0; transform: translateX(-50%) translateY(50px); }
        to { opacity: 1; transform: translateX(-50%) translateY(0); }
    }

    .apps-modal-resizer {
        display: none !important; /* Force hide everywhere on mobile */
    }

    /* Force 4 apps per row on mobile library, ensure no side scrolling */
    .immersive-apps-grid {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .immersive-apps-grid .icons-container {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0 !important; 
        padding: 10px 0 !important; /* Remove lateral padding that might cause asymmetry */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Reduce scale of large immersive widgets on mobile by ~20% */
    .immersive-widget.large-size {
        transform: scale(1.3) !important; /* Down from 1.6 */
    }

    /* Hide any counters (click counts, etc) in the Apps Library */
    .immersive-apps-grid .click-count,
    .immersive-apps-grid .news-feed-counter {
        display: none !important;
    }

    /* Ensure icons match homepage app list size and radius */
    .immersive-apps-grid .icon-item {
        margin: 0 !important;
        padding: 5px 0 !important; /* Narrower lateral padding for 4-across */
        width: auto !important;
        height: auto !important;
    }

    .immersive-apps-grid .ios-icon {
        width: 70px !important; /* Matches homepage mobile size */
        height: 70px !important;
        margin: 0 auto !important;
        border-radius: 18px !important; /* Matches standard squircle */
    }

    .immersive-apps-grid .icon-label {
        font-size: 11px !important;
        margin-top: 6px !important;
        max-width: 75px !important;
        text-align: center !important;
    }

    .immersive-apps-modal.is-visible {
        display: flex !important;
    }
}
