/* Window Manager Styles */
.window-manager {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f0f0f0;
}

body.dark-mode .window-manager {
    background: #1a1a1a;
}

/* Window Styles */
.window {
    position: absolute;
    border: 1px solid #ccc;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 0.2s ease;
}

body.dark-mode .window {
    border: 1px solid #404040;
    background: #252525;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.window.at-boundary {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.3);
}

.window.focused {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-color: #0066cc;
}

body.dark-mode .window.focused {
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
    border-color: #4a9eff;
}

.window.minimized {
    display: none;
}

.window.maximized {
    border-radius: 0;
}

/* Title Bar */
.window-titlebar {
    height: 32px;
    background: linear-gradient(to bottom, #f7f7f7, #e8e8e8);
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    cursor: move;
    user-select: none;
}

body.dark-mode .window-titlebar {
    background: linear-gradient(to bottom, #2a2a2a, #202020);
    border-bottom: 1px solid #404040;
    color: #e0e0e0;
}

.window.focused .window-titlebar {
    background: linear-gradient(to bottom, #0066cc, #0055aa);
    color: white;
}

body.dark-mode .window.focused .window-titlebar {
    background: linear-gradient(to bottom, #4a9eff, #357abd);
    color: white;
}

.window-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Window Controls */
.window-controls {
    display: flex;
    gap: 5px;
}

.window-control {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    transition: all 0.2s ease;
}

.window.focused .window-control {
    color: white;
}

.window-control:hover {
    background: rgba(255, 255, 255, 0.2);
}

.window-control.close:hover {
    background: #e81123;
    color: white;
}

.window-control.maximize:hover,
.window-control.minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Window Content */
.window-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex child overflow */
}

body.dark-mode .window-content {
    background: var(--card-bg, #252525);
}

/* Scrollbar styling for window content */
.window-content::-webkit-scrollbar {
    width: 12px;
}

.window-content::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.window-content::-webkit-scrollbar-thumb {
    background: #007bff;
    border-radius: 6px;
    border: 2px solid #f8f9fa;
    min-height: 30px;
}

.window-content::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* Firefox scrollbar styling */
.window-content {
    scrollbar-width: thin;
    scrollbar-color: #007bff #f8f9fa;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    background: transparent;
}

.resize-n, .resize-s {
    left: 10px;
    right: 10px;
    height: 5px;
    cursor: ns-resize;
}

.resize-n {
    top: 0;
}

.resize-s {
    bottom: 0;
}

.resize-e, .resize-w {
    top: 10px;
    bottom: 10px;
    width: 5px;
    cursor: ew-resize;
}

.resize-e {
    right: 0;
}

.resize-w {
    left: 0;
}

.resize-ne, .resize-nw, .resize-se, .resize-sw {
    width: 10px;
    height: 10px;
}

.resize-ne {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.resize-nw {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.resize-se {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

.resize-sw {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

/* Window animations */
@keyframes windowOpen {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.window {
    animation: windowOpen 0.2s ease-out;
}

/* Taskbar for minimized windows */
.window-taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 5px;
}

.taskbar-item {
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.taskbar-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.taskbar-item.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Exhibitor Board Window Maximize Fixes */
/* Base window content fix for all windows */
.window .window-content {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100% - 32px) !important; /* Subtract titlebar height */
}

/* Ensure board container fills the window content area */
.window-content .board-container {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    width: 100% !important;
    position: relative !important;
    overflow: hidden !important;
    flex: 1 1 auto !important;
}

/* Ensure top sections don't shrink but don't take more space than needed */
.board-container .board-top-section,
.board-container .board-view-section {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* Main content should expand to fill available space */
.board-container .board-main-content {
    flex: 1 1 auto !important;
    min-height: 0 !important; /* Important for nested flex containers */
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    height: auto !important; /* Let flex handle the height */
    margin: 0 !important;
    padding: 0 !important;
}

/* Columns container should fill its parent - override inline styles */
.board-main-content .board-columns-container,
.board-main-content #board-columns-container {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    padding: 10px !important;
    box-sizing: border-box !important;
}

/* Fix for maximized windows specifically */
/* The JavaScript will handle positioning to respect the toolbar */
.window.maximized {
    border-radius: 0;
    /* Let JavaScript handle the exact positioning */
}

.window.maximized .window-content {
    height: calc(100% - 32px) !important; /* Account for title bar */
}

.window.maximized .board-container {
    height: 100% !important;
}

/* Ensure proper scrollbar behavior in maximized state */
.window.maximized .board-columns-container {
    height: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    align-items: stretch !important; /* Make columns stretch to full height */
}

/* Fix column heights in maximized windows */
.window.maximized .board-column {
    height: calc(100% - 20px) !important; /* Account for container padding */
    min-height: calc(100% - 20px) !important;
    display: flex !important;
    flex-direction: column !important;
}

.window.maximized .board-column .board-cards,
.window.maximized .board-column .column-cards {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    height: 100% !important;
}

/* Ensure no white space at bottom in any mode */
.window-content > *:last-child {
    margin-bottom: 0 !important;
}

/* Fix for 3D editor windows */
.window.maximized .three-d-panel {
    height: 100% !important;
    margin: 0 !important;
}

/* General window manager container fix */
.window-manager {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
}

/* Editor windows container fills all available space */
#editor-windows {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100% !important;
    overflow: hidden !important; /* Prevent scrollbars */
}

/* Exhibition workspace windowed mode */
.exhibition-workspace-windowed {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* Workspace toolbar positioning */
.workspace-toolbar {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 40px !important;
    z-index: 999 !important;
}

/* Adjust window manager container when toolbar is present */
.exhibition-workspace-windowed .window-manager {
    position: absolute !important;
    top: 40px !important; /* Below toolbar */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: calc(100% - 40px) !important;
}

/* Dark mode adjustments for maximized windows */
body.dark-mode .window.maximized {
    background-color: var(--dark-bg, #252525) !important;
}

body.dark-mode .window.maximized .window-content,
body.dark-mode .window.maximized .board-container,
body.dark-mode .window.maximized .board-main-content {
    background-color: var(--dark-bg, #252525) !important;
}

body.dark-mode .window.maximized .board-columns-container {
    background-color: transparent !important;
}