/* macOS Desktop Theme - Complete Styling */

/* === macOS Big Sur Wallpaper === */
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
}

.macos-desktop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
            #667eea 0%,
            #764ba2 20%,
            #f093fb 40%,
            #4facfe 60%,
            #00f2fe 80%,
            #43e97b 100%);
    overflow: hidden;
}

/* === macOS Menu Bar === */
.macos-menubar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 10000;
    font-size: 13px;
    color: white;
}

.macos-menubar-left,
.macos-menubar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.macos-menubar-item {
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.macos-menubar-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.macos-apple-logo {
    font-size: 16px;
    cursor: pointer;
}

/* === Desktop Icons === */
.desktop-icons {
    position: absolute;
    top: 40px;
    left: 20px;
    right: 340px;
    bottom: 100px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.desktop-icons::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.desktop-icon {
    position: absolute;
    width: 90px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.desktop-icon img {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    margin: 0 auto 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
    display: block;
}

.desktop-icon:hover img {
    transform: scale(1.15);
}

.desktop-icon span {
    display: block;
    font-size: 11px;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    padding: 3px 5px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    backdrop-filter: blur(10px);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0 auto;
    line-height: 1.2;
}

/* Responsive Desktop Icons for smaller screens */
@media (max-height: 900px) {
    .desktop-icon {
        width: 75px !important;
    }

    .desktop-icon img {
        width: 58px !important;
        height: 58px !important;
        border-radius: 10px !important;
    }

    .desktop-icon span {
        font-size: 10px !important;
        max-width: 75px !important;
    }
}

@media (max-height: 768px) {
    .desktop-icon {
        width: 65px !important;
    }

    .desktop-icon img {
        width: 50px !important;
        height: 50px !important;
        border-radius: 9px !important;
    }

    .desktop-icon span {
        font-size: 9px !important;
        max-width: 65px !important;
        padding: 2px 4px !important;
    }
}

@media (max-width: 1366px) {
    .desktop-icons {
        right: 280px !important;
    }

    .desktop-icon {
        width: 75px !important;
    }

    .desktop-icon img {
        width: 58px !important;
        height: 58px !important;
    }
}

/* === Widget Sidebar === */
.macos-widgets {
    position: fixed;
    top: 24px;
    right: 0;
    width: 320px;
    height: calc(100vh - 24px - 80px);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding: 16px;
    overflow-y: auto;
    z-index: 100;
}

/* Responsive Widget Sidebar */
@media (max-width: 1366px) {
    .macos-widgets {
        width: 260px;
        padding: 12px;
    }
}

@media (max-width: 1024px) {
    .macos-widgets {
        display: none;
    }

    .desktop-icons {
        right: 20px !important;
    }
}

.widget-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.widget-header {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin-bottom: 8px;
}

/* Widget Search */
.widget-search {
    margin-bottom: 16px;
}

.widget-search form {
    display: flex;
    gap: 8px;
}

.widget-search-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 14px;
}

.widget-search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.widget-search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.widget-search-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

.widget-search-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.widget-ad-space {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: white;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

.widget-ad-space p {
    margin: 8px 0;
}

/* === macOS Dock === */
.macos-dock {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 16px;
    padding: 8px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
}

.dock-icon {
    width: 56px;
    height: 56px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
}

.dock-icon:hover {
    transform: translateY(-12px) scale(1.2);
}

/* Responsive Dock for smaller screens */
@media (max-height: 900px) {
    .macos-dock {
        padding: 6px !important;
        gap: 6px !important;
        bottom: 6px !important;
    }

    .dock-icon {
        width: 48px !important;
        height: 48px !important;
    }

    .dock-icon:hover {
        transform: translateY(-10px) scale(1.15) !important;
    }
}

@media (max-height: 768px) {
    .macos-dock {
        padding: 5px !important;
        gap: 5px !important;
        bottom: 5px !important;
        border-radius: 12px !important;
    }

    .dock-icon {
        width: 42px !important;
        height: 42px !important;
    }

    .dock-icon:hover {
        transform: translateY(-8px) scale(1.1) !important;
    }

    .dock-icon-emoji {
        font-size: 24px !important;
    }
}

@media (max-width: 1366px) {
    .macos-dock {
        gap: 6px !important;
    }

    .dock-icon {
        width: 48px !important;
        height: 48px !important;
    }
}

.dock-icon img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dock-icon-emoji {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.dock-separator {
    width: 1px;
    height: 48px;
    background: rgba(255, 255, 255, 0.3);
    margin: 0 4px;
}

/* === macOS Window === */
.macos-window {
    position: fixed;
    width: 80%;
    max-width: 1200px;
    height: 80%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: none;
    z-index: 10001;
}

.macos-window.active {
    display: block;
    animation: windowOpen 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes windowOpen {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.window-titlebar {
    height: 40px;
    background: rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: move;
    user-select: none;
}

.window-controls {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 10000;
    /* Above menubar */
}

.window-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.window-btn.close {
    background: #ff5f57;
}

.window-btn.close:hover {
    background: #ff3b30;
}

.window-btn.minimize {
    background: #ffbd2e;
}

.window-btn.minimize:hover {
    background: #ff9500;
}

.window-btn.maximize {
    background: #28c840;
}

.window-btn.maximize:hover {
    background: #34c759;
}

.window-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.window-content {
    height: calc(100% - 40px);
    overflow: auto;
    background: white;
}

.window-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Window States */
.macos-window.maximized {
    width: 100vw !important;
    height: calc(100vh - 110px) !important;
    /* Space for menubar (28px) and dock (~82px) */
    max-width: none !important;
    /* Override 1200px limit */
    max-height: none !important;
    top: 28px !important;
    /* Flush with menubar bottom */
    left: 0 !important;
    transform: none !important;
    border-radius: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100 !important;
    /* Below menubar but above desktop */
}

.macos-window.minimized {
    animation: macosMinimize 0.35s cubic-bezier(0.32, 0, 0.67, 0) forwards;
}

/* macOS-style Scale Minimize Animation */
@keyframes macosMinimize {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

    100% {
        opacity: 0;
        transform: scale(0.01) translateY(80vh);
    }
}

/* === Game Grid in Window === */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
    padding: 20px;
}

.game-card {
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.game-card:hover {
    transform: translateY(-4px);
}

.game-card img {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    object-fit: cover;
}

.game-card-title {
    margin-top: 8px;
    font-size: 12px;
    text-align: center;
    color: #333;
    line-height: 1.3;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* === Responsive === */
@media (max-width: 768px) {
    .macos-widgets {
        display: none;
    }

    .desktop-icons {
        right: 20px;
    }

    .macos-window {
        width: 95%;
        height: 90%;
    }
}

/* Running App Indicator */
.dock-dot {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

.dock-separator-running {
    margin-left: 8px;
    margin-right: 8px;
}

/* Spotlight Search */
.spotlight-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
    z-index: 20000;
    display: none;
}

.spotlight-overlay.active {
    display: block;
}

.spotlight-search {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 90%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    padding: 16px;
    z-index: 20001;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    margin-top: -20px;
}

.spotlight-search.active {
    opacity: 1;
    pointer-events: all;
    margin-top: 0;
}

.spotlight-icon {
    font-size: 24px;
    color: #666;
    margin-right: 16px;
    width: 32px;
    text-align: center;
}

.spotlight-search input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 24px;
    color: #333;
    outline: none;
    font-weight: 300;
}

/* Apple Menu */
.apple-menu {
    position: fixed;
    top: 28px;
    left: 10px;
    width: 220px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 6px 0;
    z-index: 20002;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.apple-menu-item {
    padding: 4px 16px;
    font-size: 14px;
    color: #333;
    cursor: default;
}

.apple-menu-item:hover {
    background: #007aff;
    color: white;
}

.apple-menu-separator {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 6px 16px;
}

/* Context Menu */
.context-menu {
    position: fixed;
    width: 200px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 6px 0;
    z-index: 20003;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.context-menu-item {
    padding: 4px 16px;
    font-size: 14px;
    color: #333;
    cursor: default;
}

.context-menu-item:hover {
    background: #007aff;
    color: white;
}

.context-menu-separator {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 6px 16px;
}

/* === Launchpad Overlay === */
.launchpad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 20005;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.launchpad-overlay.active {
    opacity: 1;
}

.launchpad-content {
    width: 100%;
    height: 100%;
    padding: 80px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.launchpad-search {
    margin-bottom: 40px;
    width: 300px;
}

.launchpad-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 14px;
    text-align: center;
    transition: all 0.2s;
}

.launchpad-search input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    width: 340px;
    transform: translateX(-20px);
}

.launchpad-search input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.launchpad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 30px;
    width: 100%;
    max-width: 1000px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 20px;
}

.launchpad-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.launchpad-item:hover {
    transform: scale(1.05);
}

.launchpad-item:active {
    transform: scale(0.95);
}

.launchpad-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
}

.launchpad-icon img {
    width: 100%;
    height: 100%;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    object-fit: cover;
}

.launchpad-label {
    color: white;
    font-size: 13px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Scrollbar for Launchpad */
.launchpad-grid::-webkit-scrollbar {
    width: 6px;
}

.launchpad-grid::-webkit-scrollbar-track {
    background: transparent;
}

.launchpad-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.launchpad-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}