/**
 * Window System Styles
 * Floating windows with task bar - desktop environment in browser
 */

/* ===== DESKTOP CONTAINER ===== */
.desktop-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 48px; /* Space for taskbar */
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    overflow: hidden;
}

.desktop-container.dark-mode {
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
}

/* ===== WINDOW ===== */
.window {
    position: absolute;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
    min-height: 200px;
    user-select: none;
}

.window.active {
    border-color: #007bff;
    box-shadow: 0 8px 32px rgba(0, 123, 255, 0.3);
    z-index: 100;
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
}

.window.minimized {
    display: none;
}

/* ===== WINDOW HEADER ===== */
.window-header {
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    border-bottom: 1px solid #444;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: move;
    flex-shrink: 0;
}

.window.active .window-header {
    background: linear-gradient(180deg, #007bff 0%, #0056b3 100%);
}

.window-header-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.window-header-title {
    flex: 1;
    color: white;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.window-header-controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.window-control {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.window-control:hover {
    background: rgba(255, 255, 255, 0.1);
}

.window-control.close:hover {
    background: #e81123;
}

/* ===== WINDOW CONTENT ===== */
.window-content {
    flex: 1;
    overflow: auto;
    background: #1e1e1e;
    position: relative;
}

.window-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== RESIZE HANDLES ===== */
.window-resize {
    position: absolute;
    background: transparent;
}

.window-resize.n { top: 0; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.window-resize.s { bottom: 0; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.window-resize.e { right: 0; top: 8px; bottom: 8px; width: 8px; cursor: e-resize; }
.window-resize.w { left: 0; top: 8px; bottom: 8px; width: 8px; cursor: w-resize; }
.window-resize.ne { top: 0; right: 0; width: 12px; height: 12px; cursor: ne-resize; }
.window-resize.nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nw-resize; }
.window-resize.se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: se-resize; }
.window-resize.sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: sw-resize; }

/* ===== TASK BAR ===== */
.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #444;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    z-index: 1000;
}

.taskbar.start-button {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.taskbar.start-button:hover {
    transform: scale(1.05);
}

.taskbar-divider {
    width: 1px;
    height: 32px;
    background: #444;
    margin: 0 8px;
}

.taskbar-items {
    flex: 1;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
}

.taskbar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    min-width: 120px;
    max-width: 200px;
    transition: background 0.2s;
}

.taskbar-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.taskbar-item.active {
    background: rgba(0, 123, 255, 0.3);
    border-bottom: 2px solid #007bff;
}

.taskbar-item.minimized {
    opacity: 0.6;
}

.taskbar-item-icon {
    font-size: 14px;
}

.taskbar-item-title {
    flex: 1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.taskbar-item-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    display: none;
}

.taskbar-item:hover .taskbar-item-close {
    display: block;
}

.taskbar-item-close:hover {
    background: rgba(231, 76, 60, 0.3);
    color: white;
}

.taskbar-tray {
    display: flex;
    align-items: center;
    gap: 8px;
}

.taskbar-clock {
    color: white;
    font-size: 12px;
    padding: 0 12px;
}

/* ===== WINDOW SNAP OVERLAYS ===== */
.snap-overlay {
    position: fixed;
    background: rgba(0, 123, 255, 0.1);
    border: 2px dashed #007bff;
    pointer-events: none;
    z-index: 999;
    display: none;
}

.snap-overlay.visible {
    display: block;
}

.snap-overlay.left {
    top: 0;
    left: 0;
    bottom: 48px;
    width: 50%;
}

.snap-overlay.right {
    top: 0;
    right: 0;
    bottom: 48px;
    width: 50%;
}

.snap-overlay.top {
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
}

.snap-overlay.bottom {
    bottom: 48px;
    left: 0;
    right: 0;
    height: 50%;
}

.snap-overlay.maximize {
    top: 0;
    left: 0;
    right: 0;
    bottom: 48px;
}

/* ===== START MENU ===== */
.start-menu {
    position: fixed;
    bottom: 56px;
    left: 12px;
    width: 320px;
    background: rgba(30, 30, 30, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    display: none;
    padding: 16px;
}

.start-menu.visible {
    display: block;
}

.start-menu-section {
    margin-bottom: 16px;
}

.start-menu-section-title {
    color: #999;
    font-size: 11px;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding: 0 8px;
}

.start-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.2s;
}

.start-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.start-menu-item-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.start-menu-item-text {
    flex: 1;
}

.start-menu-item-title {
    font-size: 13px;
    font-weight: 500;
}

.start-menu-item-description {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .taskbar-items {
        font-size: 11px;
    }

    .taskbar-item {
        min-width: 40px;
        padding: 6px 8px;
    }

    .taskbar-item-title {
        display: none;
    }

    .taskbar-item:hover .taskbar-item-title {
        display: block;
    }

    .window {
        min-width: 200px;
        min-height: 150px;
    }

    .start-menu {
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes windowOpen {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes windowClose {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

.window.opening {
    animation: windowOpen 0.2s ease-out;
}

.window.closing {
    animation: windowClose 0.2s ease-out forwards;
}

/* ===== DARK MODE ===== */
.desktop-container.dark-mode .window {
    background: #0d0d0d;
    border-color: #333;
}

.desktop-container.dark-mode .window-content {
    background: #0d0d0d;
}

.desktop-container.dark-mode .window-header {
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
}

/* ===== SCROLLBARS ===== */
.window-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.window-content::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.window-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.window-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== MEDIA VIEWER ===== */
#media-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 40px;
}

#media-viewer[style*="display: flex"] {
    display: flex !important;
}

#viewer-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: none;
}

#viewer-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
    background: white;
}

.media-viewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background 0.2s ease, border-color 0.2s ease;
    z-index: 10001;
}

.media-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.media-viewer-download {
    position: absolute;
    top: 20px;
    right: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease, border-color 0.2s ease;
    z-index: 10001;
}

.media-viewer-download:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}
