/* Window Manager Specific Styles */
#window-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through empty areas to desktop */
    z-index: 10;
}

.window {
    position: absolute;
    min-width: 300px;
    min-height: 200px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    pointer-events: auto; /* Catch clicks on the window itself */
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    transition: transform 0.2s, opacity 0.2s;
    overflow: hidden;
}

.window.focused {
    box-shadow: 0 8px 30px rgba(0,0,0,0.7);
}

.window.minimized {
    transform: scale(0.1) translateY(500px);
    opacity: 0;
    pointer-events: none;
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
    transform: none;
}

.window-titlebar {
    height: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px 0 10px;
    cursor: default; /* Will be changed to move cursor on drag */
    background: linear-gradient(to bottom, rgba(230, 240, 250, 0.8) 0%, rgba(190, 210, 230, 0.8) 50%, rgba(160, 190, 220, 0.9) 51%, rgba(180, 200, 230, 0.8) 100%);
    border-bottom: 1px solid rgba(255,255,255,0.5);
}

.window.focused .window-titlebar {
    background: linear-gradient(to bottom, rgba(162, 189, 219, 0.8) 0%, rgba(132, 168, 205, 0.8) 50%, rgba(100, 142, 186, 0.9) 51%, rgba(119, 159, 199, 0.8) 100%);
}

.window-title {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    pointer-events: none;
}

.window-title img {
    width: 16px;
    height: 16px;
    margin-right: 8px;
}

.window-controls {
    display: flex;
    gap: 2px;
}

.win-btn {
    width: 25px;
    height: 18px;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 3px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(200,200,200,0.5) 100%);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.win-btn:hover {
    background: linear-gradient(to bottom, rgba(255,255,255,0.8) 0%, rgba(220,220,220,0.8) 100%);
}

.win-btn.close {
    background: linear-gradient(to bottom, rgba(250, 150, 150, 0.5) 0%, rgba(200, 50, 50, 0.5) 100%);
    border-color: rgba(200, 0, 0, 0.4);
}

.win-btn.close:hover {
    background: linear-gradient(to bottom, rgba(255, 100, 100, 0.8) 0%, rgba(220, 0, 0, 0.8) 100%);
}

.win-btn svg {
    width: 10px;
    height: 10px;
    fill: #000;
}

.win-btn.close svg {
    fill: #fff;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5));
}

.window-content {
    flex: 1;
    background: #fff;
    position: relative;
    border: 1px solid rgba(0,0,0,0.2);
    /* For iframe covering */
}

.window-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    opacity: 0;
    transition: opacity 0.16s ease;
    background: #fff;
}

.window-content iframe.is-ready {
    opacity: 1;
}

.window-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(to bottom, rgba(250, 252, 255, 0.95), rgba(235, 242, 250, 0.95));
    color: #244b73;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.window-loading-label {
    font-size: 12px;
    opacity: 0.9;
}

.window-loading.hidden {
    opacity: 0;
}

.window-loading.error {
    color: #8f1b1b;
    text-align: center;
    padding: 0 20px;
}

.window-loading-spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #9cb6d3;
    border-top-color: #2d7dd2;
    animation: window-spin 0.7s linear infinite;
}

.window-loading.error .window-loading-spinner {
    display: none;
}

@keyframes window-spin {
    to { transform: rotate(360deg); }
}

/* Invisible overlay to prevent iframe stealing mouse events during drag */
.window-drag-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    display: none;
}

.window.dragging .window-drag-overlay {
    display: block;
}
