/* ============================================================
   WINDOW CHROME
   Title bars, borders, resize handles, menu bars
   ============================================================ */

.win95-window {
    position: absolute;
    display: flex;
    flex-direction: column;
    background: var(--win95-bg);
    box-shadow:
        inset -1px -1px var(--win95-black),
        inset 1px 1px var(--win95-light),
        inset -2px -2px var(--win95-gray),
        inset 2px 2px var(--win95-white);
    min-width: 160px;
    min-height: 60px;
    font-family: var(--win95-font);
    font-size: var(--win95-font-size);
}

.win95-window.maximized {
    box-shadow: none;
}

/* ---- TITLE BAR ---- */

.win95-title-bar {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 3px;
    background: linear-gradient(to right, var(--win95-navy), var(--win95-navy-light));
    color: var(--win95-white);
    height: 18px;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
}

.win95-window:not(.active) .win95-title-bar {
    background: linear-gradient(to right, var(--win95-title-inactive), var(--win95-title-inactive-end));
}

.win95-title-bar-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.win95-title-bar-text {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: bold;
    font-size: 11px;
    line-height: 14px;
    letter-spacing: 0;
}

.win95-title-bar-controls {
    display: flex;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Title bar buttons */
.win95-title-btn {
    width: 16px;
    height: 14px;
    background: var(--win95-bg);
    border: none;
    box-shadow:
        inset -1px -1px var(--win95-black),
        inset 1px 1px var(--win95-white),
        inset -2px -2px var(--win95-gray),
        inset 2px 2px var(--win95-light);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    outline: none;
    position: relative;
}

.win95-title-btn:active {
    box-shadow:
        inset -1px -1px var(--win95-white),
        inset 1px 1px var(--win95-black),
        inset -2px -2px var(--win95-light),
        inset 2px 2px var(--win95-gray);
}

/* Minimize button: _ */
.win95-btn-minimize::after {
    content: '';
    width: 8px;
    height: 2px;
    background: var(--win95-black);
    position: absolute;
    bottom: 3px;
}

/* Maximize button: □ */
.win95-btn-maximize::after {
    content: '';
    width: 8px;
    height: 7px;
    border: 1px solid var(--win95-black);
    border-top: 2px solid var(--win95-black);
    position: absolute;
}

/* Restore button (when maximized): overlapping □□ */
.win95-btn-restore::after {
    content: '';
    width: 7px;
    height: 6px;
    border: 1px solid var(--win95-black);
    border-top: 2px solid var(--win95-black);
    position: absolute;
    top: 2px;
    right: 3px;
}

.win95-btn-restore::before {
    content: '';
    width: 7px;
    height: 6px;
    border: 1px solid var(--win95-black);
    border-top: 2px solid var(--win95-black);
    position: absolute;
    bottom: 2px;
    left: 3px;
    background: var(--win95-bg);
    z-index: 1;
}

/* Close button: X */
.win95-btn-close::before,
.win95-btn-close::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 2px;
    background: var(--win95-black);
}

.win95-btn-close::before {
    transform: rotate(45deg);
}

.win95-btn-close::after {
    transform: rotate(-45deg);
}

/* ---- MENU BAR ---- */

.win95-menu-bar {
    display: flex;
    align-items: stretch;
    padding: 0 2px;
    background: var(--win95-bg);
    height: 20px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--win95-gray);
}

.win95-menu-bar-item {
    display: flex;
    align-items: center;
    padding: 0 8px;
    background: none;
    border: none;
    font-family: var(--win95-font);
    font-size: var(--win95-font-size);
    color: var(--win95-text);
    cursor: default;
    outline: none;
    height: 100%;
    position: relative;
}

.win95-menu-bar-item.open,
.win95-menu-bar-item:active {
    box-shadow:
        inset -1px -1px var(--win95-white),
        inset 1px 1px var(--win95-gray);
    background: var(--win95-bg);
}

/* ---- DROPDOWN MENU ---- */

.win95-menu-dropdown {
    position: fixed;
    background: var(--win95-bg);
    box-shadow:
        inset -1px -1px var(--win95-black),
        inset 1px 1px var(--win95-white),
        inset -2px -2px var(--win95-gray),
        inset 2px 2px var(--win95-light);
    padding: 2px;
    z-index: 9000;
    min-width: 160px;
}

.win95-menu-item {
    display: flex;
    align-items: center;
    padding: 3px 24px 3px 28px;
    cursor: default;
    white-space: nowrap;
    gap: 8px;
    position: relative;
}

.win95-menu-item:hover:not(.disabled) {
    background: var(--win95-navy);
    color: var(--win95-white);
}

.win95-menu-item.disabled {
    color: var(--win95-gray);
    text-shadow: 1px 1px 0 var(--win95-white);
}

.win95-menu-item .menu-icon {
    position: absolute;
    left: 6px;
    width: 16px;
    height: 16px;
}

.win95-menu-item .menu-shortcut {
    margin-left: auto;
    padding-left: 24px;
    color: inherit;
}

.win95-menu-item .menu-arrow {
    margin-left: auto;
    font-size: 8px;
}

.win95-menu-item .menu-check {
    position: absolute;
    left: 8px;
    font-size: 10px;
}

.win95-menu-separator {
    height: 2px;
    margin: 2px 2px;
    box-shadow:
        inset 0 1px var(--win95-gray),
        inset 0 -1px var(--win95-white);
}

/* ---- WINDOW BODY ---- */

.win95-window-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* ---- STATUS BAR ---- */

.win95-status-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px;
    background: var(--win95-bg);
    flex-shrink: 0;
    min-height: 20px;
}

.win95-status-bar-field {
    box-shadow:
        inset -1px -1px var(--win95-white),
        inset 1px 1px var(--win95-gray);
    padding: 1px 4px;
    font-family: var(--win95-font);
    font-size: var(--win95-font-size);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 14px;
}

.win95-status-bar-field:first-child {
    flex: 1;
}

/* ---- RESIZE HANDLES ---- */

.win95-resize-handle {
    position: absolute;
    z-index: 10;
}

.win95-resize-n {
    top: -3px;
    left: 4px;
    right: 4px;
    height: 6px;
    cursor: n-resize;
}

.win95-resize-s {
    bottom: -3px;
    left: 4px;
    right: 4px;
    height: 6px;
    cursor: s-resize;
}

.win95-resize-e {
    right: -3px;
    top: 4px;
    bottom: 4px;
    width: 6px;
    cursor: e-resize;
}

.win95-resize-w {
    left: -3px;
    top: 4px;
    bottom: 4px;
    width: 6px;
    cursor: w-resize;
}

.win95-resize-ne {
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    cursor: ne-resize;
}

.win95-resize-nw {
    top: -3px;
    left: -3px;
    width: 8px;
    height: 8px;
    cursor: nw-resize;
}

.win95-resize-se {
    bottom: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    cursor: se-resize;
}

.win95-resize-sw {
    bottom: -3px;
    left: -3px;
    width: 8px;
    height: 8px;
    cursor: sw-resize;
}

/* Hide resize handles on maximized windows */
.win95-window.maximized .win95-resize-handle {
    display: none;
}

/* ---- GRIP PATTERN (bottom-right status bar corner) ---- */

.win95-grip {
    width: 12px;
    height: 12px;
    position: absolute;
    bottom: 2px;
    right: 2px;
    background:
        linear-gradient(135deg,
            transparent 0%, transparent 33%,
            var(--win95-white) 33%, var(--win95-white) 38%,
            var(--win95-gray) 38%, var(--win95-gray) 43%,
            transparent 43%, transparent 55%,
            var(--win95-white) 55%, var(--win95-white) 60%,
            var(--win95-gray) 60%, var(--win95-gray) 65%,
            transparent 65%, transparent 77%,
            var(--win95-white) 77%, var(--win95-white) 82%,
            var(--win95-gray) 82%, var(--win95-gray) 87%,
            transparent 87%
        );
}
