/* ═══════════════════════════════════════════════════════════════════
   Windows 3.1 — Program Manager Theme
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --win-bg: #008080;
    --win-white: #ffffff;
    --win-ltgray: #c0c0c0;
    --win-gray: #808080;
    --win-dkgray: #404040;
    --win-black: #000000;
    --win-blue: #000080;
    --win-title-active: #000080;
    --win-title-inactive: #808080;
    --win-title-text: #ffffff;
    --win-btn-face: #c0c0c0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: 'MS Sans Serif', 'Segoe UI', 'Arial', sans-serif;
    font-size: 12px;
    color: var(--win-black);
    cursor: default;
}

/* ─── Desktop ────────────────────────────────────────────────────── */
.desktop {
    width: 100%; height: 100%;
    background: var(--win-bg);
    display: flex;
    flex-direction: column;
}

/* ─── 3D Bevel Helpers ───────────────────────────────────────────── */
.bevel-out {
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    box-shadow: inset 1px 1px 0 var(--win-ltgray), 1px 1px 0 var(--win-black);
}

.bevel-in {
    border: 2px solid;
    border-color: var(--win-gray) var(--win-white) var(--win-white) var(--win-gray);
    box-shadow: inset 1px 1px 0 var(--win-dkgray);
}

/* ─── Window ─────────────────────────────────────────────────────── */
.window {
    background: var(--win-ltgray);
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    box-shadow: 1px 1px 0 var(--win-black);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.window-main {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 640px;
    max-width: 95vw;
    max-height: 85vh;
}

/* ─── Title Bar ──────────────────────────────────────────────────── */
.title-bar {
    background: var(--win-title-active);
    color: var(--win-title-text);
    padding: 2px 3px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 12px;
    min-height: 20px;
    user-select: none;
}

.title-bar-text {
    flex: 1;
    padding-left: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.title-btn {
    width: 18px; height: 16px;
    background: var(--win-ltgray);
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--win-black);
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    font-family: 'Courier New', monospace;
}
.title-btn:active {
    border-color: var(--win-dkgray) var(--win-white) var(--win-white) var(--win-dkgray);
}

/* ─── Menu Bar ───────────────────────────────────────────────────── */
.menubar {
    background: var(--win-ltgray);
    border-bottom: 1px solid var(--win-gray);
    display: flex;
    align-items: stretch;
    padding: 0;
    font-size: 12px;
    user-select: none;
}

.menubar-item {
    padding: 3px 8px;
    cursor: pointer;
    position: relative;
}
.menubar-item:hover {
    background: var(--win-blue);
    color: var(--win-white);
}
.menubar-item.active {
    background: var(--win-blue);
    color: var(--win-white);
}
.menubar-item .underline { text-decoration: underline; }

/* ─── Dropdown ───────────────────────────────────────────────────── */
.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: var(--win-ltgray);
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    box-shadow: 2px 2px 0 var(--win-black);
    z-index: 2000;
    padding: 2px 0;
}
.dropdown.open { display: block; }

.dropdown-item {
    padding: 3px 20px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
}
.dropdown-item:hover {
    background: var(--win-blue);
    color: var(--win-white);
}

.dropdown-divider {
    height: 1px;
    background: var(--win-gray);
    margin: 3px 2px;
    border-bottom: 1px solid var(--win-white);
}

/* ─── Program Icons ──────────────────────────────────────────────── */
.program-area {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
}

.program-icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    cursor: pointer;
    border: 1px solid transparent;
    text-align: center;
}

.program-icon:hover {
    border: 1px dotted var(--win-black);
}

.program-icon.selected {
    background: var(--win-blue);
    color: var(--win-white);
    border: 1px dotted var(--win-white);
}

.program-icon-img {
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.program-icon-label {
    font-size: 10px;
    line-height: 1.2;
    word-wrap: break-word;
    max-width: 72px;
}

.program-icon.selected .program-icon-label {
    color: var(--win-white);
}

/* ─── Status Bar ─────────────────────────────────────────────────── */
.statusbar {
    background: var(--win-ltgray);
    border-top: 2px solid;
    border-color: var(--win-gray) var(--win-white) var(--win-white) var(--win-gray);
    padding: 2px 6px;
    font-size: 11px;
    display: flex;
    align-items: center;
}

/* ─── Boot Screen ────────────────────────────────────────────────── */
.boot-screen {
    position: fixed;
    inset: 0;
    background: #000080;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: 'Courier New', monospace;
    transition: opacity 0.4s ease;
}
.boot-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.boot-logo {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
}
.boot-logo .block {
    width: 28px; height: 28px;
    border: 2px solid;
}
.boot-logo .block.red { background: #ff0000; border-color: #ff8080 #800000 #800000 #ff8080; }
.boot-logo .block.green { background: #00ff00; border-color: #80ff80 #008000 #008000 #80ff80; }
.boot-logo .block.blue { background: #0000ff; border-color: #8080ff #000080 #000080 #8080ff; }
.boot-logo .block.yellow { background: #ffff00; border-color: #ffff80 #808000 #808000 #ffff80; }

.boot-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 8px;
}
.boot-subtitle {
    font-size: 14px;
    color: #c0c0c0;
    margin-bottom: 30px;
}
.boot-progress-outer {
    width: 260px;
    height: 18px;
    background: #000080;
    border: 2px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    padding: 2px;
}
.boot-progress-inner {
    height: 100%;
    width: 0%;
    background: repeating-linear-gradient(
        90deg,
        #c0c0c0 0px, #c0c0c0 8px,
        #000080 8px, #000080 10px
    );
    transition: width 0.2s;
}

/* ─── Login Dialog ───────────────────────────────────────────────── */
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 3000;
    align-items: center;
    justify-content: center;
}
.dialog-overlay.open { display: flex; }

.dialog {
    background: var(--win-ltgray);
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    box-shadow: 2px 2px 0 var(--win-black);
    width: 340px;
}

.dialog .title-bar {
    cursor: default;
}

.dialog-body {
    padding: 16px;
}

.dialog-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.dialog-row label {
    min-width: 80px;
    font-size: 12px;
    text-align: right;
}

.dialog-input {
    flex: 1;
    padding: 2px 4px;
    border: 2px solid;
    border-color: var(--win-gray) var(--win-white) var(--win-white) var(--win-gray);
    box-shadow: inset 1px 1px 0 var(--win-dkgray);
    background: #fff;
    font-family: inherit;
    font-size: 12px;
    outline: none;
}

.dialog-error {
    color: #ff0000;
    font-size: 11px;
    min-height: 16px;
    margin-bottom: 6px;
}

.dialog-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.win-btn {
    min-width: 75px;
    padding: 4px 12px;
    background: var(--win-ltgray);
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
}
.win-btn:active {
    border-color: var(--win-dkgray) var(--win-white) var(--win-white) var(--win-dkgray);
}
.win-btn:focus {
    outline: 1px dotted var(--win-black);
    outline-offset: -4px;
}
.win-btn-default {
    border: 3px solid var(--win-black);
    padding: 3px 11px;
}
.win-btn-default > span {
    display: inline-block;
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    padding: 1px 8px;
    background: var(--win-ltgray);
}

/* ─── iframe Window ──────────────────────────────────────────────── */
.iframe-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 4000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.iframe-overlay.open { display: flex; }

.iframe-window {
    width: 90vw;
    height: 85vh;
    max-width: 1000px;
    background: var(--win-ltgray);
    border: 2px solid;
    border-color: var(--win-white) var(--win-dkgray) var(--win-dkgray) var(--win-white);
    box-shadow: 2px 2px 0 var(--win-black);
    display: flex;
    flex-direction: column;
}

.iframe-content {
    flex: 1;
    border: 2px solid;
    border-color: var(--win-gray) var(--win-white) var(--win-white) var(--win-gray);
    margin: 0 2px 2px;
    overflow: hidden;
}
.iframe-content iframe {
    width: 100%; height: 100%;
    border: none;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .window-main { width: 98vw; max-height: 90vh; }
    .program-icon { width: 64px; }
    .program-icon-img { font-size: 20px; width: 28px; height: 28px; }
    .program-icon-label { font-size: 9px; }
}
