/* ============================================
   Windows93 - Window Styles
   Classic Windows 93/95 Windows
   ============================================ */

/* Window Base */
.window {
    position: absolute;
    display: flex;
    flex-direction: column;
    background: var(--win-gray);
    border: 2px solid;
    border-color: var(--win-btn-highlight) var(--win-btn-dark-shadow) var(--win-btn-dark-shadow) var(--win-btn-highlight);
    box-shadow:
        inset 1px 1px 0 var(--win-white),
        inset -1px -1px 0 var(--win-btn-shadow),
        2px 2px 0 rgba(0, 0, 0, 0.3);
    min-width: 200px;
    min-height: 150px;
    overflow: hidden;
    animation: windowOpen 0.15s ease;
}

.window.focused {
    z-index: 100;
}

.window.closing {
    animation: windowClose 0.15s ease forwards;
}

.window.minimizing {
    animation: windowMinimize 0.2s ease forwards;
}

.window.maximized {
    animation: none;
}

@keyframes windowOpen {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes windowClose {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.9);
        opacity: 0;
    }
}

@keyframes windowMinimize {
    from {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    to {
        transform: scale(0.3) translateY(100px);
        opacity: 0;
    }
}

/* Window Header / Title Bar */
.window-header {
    display: flex;
    align-items: center;
    padding: 2px 3px;
    background: linear-gradient(90deg, var(--win-titlebar), #1084d0);
    cursor: default;
    user-select: none;
    -webkit-app-region: drag;
    flex-shrink: 0;
    height: 20px;
}

.window:not(.focused) .window-header {
    background: linear-gradient(90deg, var(--win-titlebar-inactive), #a0a0a0);
}

/* Window Controls (Right side in Windows 93) */
.window-controls {
    display: flex;
    gap: 2px;
    margin-left: auto;
    -webkit-app-region: no-drag;
}

.window-control {
    width: 16px;
    height: 14px;
    background: var(--win-gray);
    border: 2px solid;
    border-color: var(--win-btn-highlight) var(--win-btn-dark-shadow) var(--win-btn-dark-shadow) var(--win-btn-highlight);
    box-shadow:
        inset 1px 1px 0 var(--win-white),
        inset -1px -1px 0 var(--win-btn-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: var(--win-black);
    font-family: var(--font-system);
    padding: 0;
    line-height: 1;
}

.window-control:active {
    border-color: var(--win-btn-dark-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-dark-shadow);
    box-shadow:
        inset 1px 1px 0 var(--win-btn-shadow),
        inset -1px -1px 0 var(--win-white);
    padding-left: 1px;
    padding-top: 1px;
}

.window-control.minimize::after {
    content: '_';
    margin-bottom: 4px;
}

.window-control.maximize::after {
    content: '□';
    font-size: 9px;
}

.window-control.close::after {
    content: '×';
    font-size: 12px;
}

/* Window Icon */
.window-icon {
    width: 16px;
    height: 16px;
    margin-right: 4px;
    flex-shrink: 0;
    font-size: 12px;
}

/* Window Title */
.window-title {
    flex: 1;
    font-size: 11px;
    font-weight: bold;
    color: var(--win-titlebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.window:not(.focused) .window-title {
    color: var(--win-gray-light);
}

/* Window Menu Bar */
.window-menubar {
    display: flex;
    background: var(--win-gray);
    border-bottom: 1px solid var(--win-btn-shadow);
    padding: 2px 0;
}

.menubar-item {
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
}

.menubar-item:hover {
    background: var(--win-selection);
    color: var(--win-selection-text);
}

.menubar-item.active {
    background: var(--win-selection);
    color: var(--win-selection-text);
}

/* Window Content */
.window-content {
    flex: 1;
    overflow: auto;
    position: relative;
    background: var(--win-gray);
}

/* Inset content area (for text fields, etc) */
.window-content-inset {
    background: var(--win-white);
    border: 2px solid;
    border-color: var(--win-btn-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-shadow);
    box-shadow: inset 1px 1px 0 var(--win-btn-dark-shadow);
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    z-index: 10;
}

.resize-handle.n {
    top: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    cursor: n-resize;
}

.resize-handle.s {
    bottom: 0;
    left: 4px;
    right: 4px;
    height: 4px;
    cursor: s-resize;
}

.resize-handle.e {
    right: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    cursor: e-resize;
}

.resize-handle.w {
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    cursor: w-resize;
}

.resize-handle.ne {
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    cursor: ne-resize;
}

.resize-handle.nw {
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    cursor: nw-resize;
}

.resize-handle.se {
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
}

.resize-handle.sw {
    bottom: 0;
    left: 0;
    width: 8px;
    height: 8px;
    cursor: sw-resize;
}

/* Windows 93 Resize Grip */
.resize-handle.se::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 12px;
    height: 12px;
    background:
        linear-gradient(135deg,
            transparent 0%, transparent 30%,
            var(--win-btn-highlight) 30%, var(--win-btn-highlight) 40%,
            transparent 40%, transparent 50%,
            var(--win-btn-shadow) 50%, var(--win-btn-shadow) 60%,
            transparent 60%, transparent 70%,
            var(--win-btn-highlight) 70%, var(--win-btn-highlight) 80%,
            transparent 80%, transparent 90%,
            var(--win-btn-shadow) 90%, var(--win-btn-shadow) 100%
        );
}

/* Snap Preview */
.snap-preview {
    position: fixed;
    background: repeating-linear-gradient(
        45deg,
        var(--win-selection),
        var(--win-selection) 2px,
        transparent 2px,
        transparent 4px
    );
    border: 2px solid var(--win-selection);
    pointer-events: none;
    z-index: 99;
}

/* Dragging state */
.window.dragging {
    opacity: 0.85;
    cursor: move;
}

.window.dragging .window-header {
    cursor: move;
}

/* Resizing state */
.window.resizing {
    transition: none;
}

body.resizing * {
    cursor: inherit !important;
}

/* Dialog Windows */
.window.dialog {
    min-width: 300px;
    max-width: 450px;
}

.dialog-content {
    padding: 16px;
    display: flex;
    gap: 12px;
}

.dialog-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    font-size: 32px;
}

.dialog-text {
    flex: 1;
    font-size: 11px;
    line-height: 1.4;
}

.dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px 16px;
}

.dialog-btn {
    min-width: 75px;
}

/* Window Toolbar */
.window-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px;
    background: var(--win-gray);
    border-bottom: 1px solid var(--win-btn-shadow);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 23px;
    height: 22px;
    background: var(--win-gray);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
}

.toolbar-btn:hover {
    border: 1px solid;
    border-color: var(--win-btn-highlight) var(--win-btn-shadow) var(--win-btn-shadow) var(--win-btn-highlight);
}

.toolbar-btn:active {
    border-color: var(--win-btn-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-shadow);
}

.toolbar-btn.active {
    background: var(--win-btn-shadow);
    border-color: var(--win-btn-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-shadow);
}

.toolbar-separator {
    width: 2px;
    height: 22px;
    border-left: 1px solid var(--win-btn-shadow);
    border-right: 1px solid var(--win-btn-highlight);
    margin: 0 2px;
}

.toolbar-spacer {
    flex: 1;
}

/* Window Status Bar */
.window-statusbar {
    display: flex;
    align-items: center;
    padding: 2px 4px;
    background: var(--win-gray);
    border-top: 1px solid var(--win-btn-shadow);
    font-size: 11px;
    min-height: 20px;
}

.statusbar-item {
    padding: 0 8px;
    border: 1px solid;
    border-color: var(--win-btn-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-shadow);
    height: 16px;
    display: flex;
    align-items: center;
}

.statusbar-item:first-child {
    flex: 1;
}

.statusbar-separator {
    width: 1px;
}

/* Group Box (common Windows 93 UI element) */
.group-box {
    border: 2px solid;
    border-color: var(--win-btn-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-shadow);
    padding: 12px 8px 8px;
    margin: 8px;
    position: relative;
}

.group-box-title {
    position: absolute;
    top: -8px;
    left: 8px;
    background: var(--win-gray);
    padding: 0 4px;
    font-size: 11px;
}

/* Tab Control */
.tab-control {
    display: flex;
    flex-direction: column;
}

.tab-buttons {
    display: flex;
    padding: 0 4px;
}

.tab-btn {
    padding: 4px 12px;
    background: var(--win-gray);
    border: 2px solid;
    border-color: var(--win-btn-highlight) var(--win-btn-dark-shadow) var(--win-btn-dark-shadow) var(--win-btn-highlight);
    border-bottom: none;
    margin-right: 2px;
    position: relative;
    top: 2px;
    cursor: pointer;
    font-size: 11px;
}

.tab-btn.active {
    background: var(--win-gray);
    border-bottom: 2px solid var(--win-gray);
    top: 0;
    padding-bottom: 6px;
}

.tab-content {
    border: 2px solid;
    border-color: var(--win-btn-highlight) var(--win-btn-dark-shadow) var(--win-btn-dark-shadow) var(--win-btn-highlight);
    padding: 8px;
    background: var(--win-gray);
}

/* List View */
.list-view {
    background: var(--win-white);
    border: 2px solid;
    border-color: var(--win-btn-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-shadow);
    box-shadow: inset 1px 1px 0 var(--win-btn-dark-shadow);
}

.list-item {
    padding: 2px 4px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.list-item:hover {
    background: var(--win-selection);
    color: var(--win-selection-text);
}

.list-item.selected {
    background: var(--win-selection);
    color: var(--win-selection-text);
}

/* Tree View */
.tree-view {
    background: var(--win-white);
    border: 2px solid;
    border-color: var(--win-btn-shadow) var(--win-btn-highlight) var(--win-btn-highlight) var(--win-btn-shadow);
    box-shadow: inset 1px 1px 0 var(--win-btn-dark-shadow);
    font-size: 11px;
}

.tree-item {
    padding: 1px 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 2px;
}

.tree-item:hover {
    background: var(--win-selection);
    color: var(--win-selection-text);
}

.tree-expand {
    width: 9px;
    height: 9px;
    border: 1px solid var(--win-black);
    background: var(--win-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    line-height: 1;
    margin-right: 2px;
}
