/* FUBAR OS Theme System */
:root {
    /* DEFAULT THEME (FUBAR / HACKER) */
    --os-font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    --os-ui-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    /* BACKGROUNDS */
    --os-bg-color: #1e1e1e;
    --os-desktop-overlay: rgba(0, 0, 0, 0);

    /* TERMINAL */
    --term-bg: #1e1e1e;
    --term-text: #d4d4d4;
    --term-cmd: #569cd6;
    --term-success: #6a9955;
    --term-error: #f44747;
    --term-warn: #dcdcaa;
    --term-dim: #666;
    --term-highlight: #00ff41;

    /* WINDOWS */
    --win-bg: #0a0a0a;
    --win-border: #00ff41;
    --win-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    --win-title-bg: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);
    --win-title-text: #00ff41;
    --win-content-bg: #000;
    --win-content-text: #d4d4d4;

    /* UI ELEMENTS */
    --top-bar-bg: rgba(10, 10, 10, 0.95);
    --top-bar-border: #333;
    --footer-bg: rgba(10, 10, 10, 0.98);
    --footer-text: #888;
    --footer-highlight: #fff;
    --btn-hover: rgba(255, 255, 255, 0.1);

    /* DIMENSIONS (Variables for JS consumption if needed, but mostly CSS) */
    --top-bar-height: 30px;
    --footer-height: 48px;

    --radius-sm: 4px;
    --radius-md: 0px;
}

/* THEME PRESETS */

/* AMBER (Retro Terminal) */
[data-theme="amber"] {
    --os-bg-color: #1a1000;
    --term-text: #ffb000;
    --term-cmd: #ffcc00;
    --term-success: #ffb000;
    --term-error: #d00;
    --term-warn: #d60;
    --term-dim: #630;
    --term-highlight: #ffcc00;

    --win-bg: #110900;
    --win-border: #ffb000;
    --win-shadow: 0 0 15px rgba(255, 176, 0, 0.2);
    --win-title-bg: #221200;
    --win-title-text: #ffb000;
    --win-content-bg: #000;
}

/* CYBER (Neon Blue/Pink) */
[data-theme="cyber"] {
    --os-bg-color: #0b0014;
    --term-text: #e0e0ff;
    --term-cmd: #00f0ff;
    --term-success: #00f0ff;
    --term-error: #ff0055;
    --term-warn: #f0f;
    --term-dim: #5500aa;
    --term-highlight: #f0f;

    --win-bg: rgba(10, 0, 20, 0.9);
    --win-border: #00f0ff;
    --win-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
    --win-title-bg: linear-gradient(90deg, #ff0055, #5500aa);
    --win-title-text: #fff;
    --win-content-bg: #050010;

    --radius-md: 8px;
}

/* LIGHT (Corporate/Win95-ish) */
[data-theme="light"] {
    --os-bg-color: #008080;
    /* Classic Teal */
    --term-text: #000;
    --term-cmd: #000080;
    --term-success: #006600;
    --term-error: #cc0000;
    --term-warn: #884400;
    --term-dim: #666;
    --term-highlight: #000080;

    --win-bg: #c0c0c0;
    --win-border: #dfdfdf;
    --win-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
    --win-title-bg: #000080;
    --win-title-text: #fff;
    --win-content-bg: #fff;
    --win-content-text: #000;

    --top-bar-bg: #c0c0c0;
    --top-bar-border: #fff outset 2px;
    --footer-bg: #c0c0c0;
    --footer-text: #000;

    --radius-md: 0;
}

/* GLOBAL STYLES */
body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--os-bg-color);
    font-family: var(--os-font-family);
    font-size: 16px;
    line-height: 1.6;
    color: var(--term-text);
}

/* === CUSTOM SCROLLBARS (HIDDEN) === */
::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

html,
body,
* {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

/* TERMINAL OUTPUT CLASSES */
.term-output {
    color: var(--term-text);
}

.term-success {
    color: var(--term-success);
}

.term-error {
    color: var(--term-error);
}

.term-warn {
    color: var(--term-warn);
}

.term-dim {
    color: var(--term-dim);
}

.term-highlight {
    color: var(--term-highlight);
    font-weight: bold;
}

/* TERMINAL GRID (Responsive LS) */
.term-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 5px;
    width: 100%;
    margin-top: 5px;
}

.term-grid-item {
    font-family: var(--os-font-family);
    word-break: break-all;
}

/* WINDOW SYSTEM */
.os-window {
    display: flex;
    flex-direction: column;
    font-family: var(--os-ui-font);
    background: var(--win-bg);
    border: 1px solid var(--win-border);
    box-shadow: var(--win-shadow);
    border-radius: var(--radius-md);
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Smooth visual transition */
}

/* ACTIVE STATE */
.os-window.active {
    border-color: var(--win-border);
    box-shadow: var(--win-shadow);
    z-index: 1000;
    /* Helper, though JS handles Z */
}

.os-window.active .title-bar {
    background: var(--win-title-bg);
    color: var(--win-title-text);
}

/* INACTIVE STATE */
.os-window.inactive {
    border-color: #444;
    box-shadow: none;
}

.os-window.inactive .title-bar {
    background: #252526;
    color: #888;
}

.os-window .title-bar {
    /* Base styles, overridden by active/inactive */
    background: var(--win-title-bg);
    color: var(--win-title-text);
    padding: 2px 4px;
    border-bottom: 1px solid var(--win-border);
    /* This might need dimming too, see below */
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    cursor: default;
    height: 24px;
}

.os-window.inactive .title-bar {
    border-bottom: 1px solid #444;
}

/* ADDED: Fix button stacking */
.win-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 100%;
}

.os-window .win-content {
    background: var(--win-content-bg);
    color: var(--win-content-text);
    border: none;
    flex: 1;
    overflow: auto;
    position: relative;
    padding: 10px;
}

/* WINDOW BUTTONS */
.win-btn-close {
    background: transparent;
    border: 1px solid var(--term-error);
    color: var(--term-error);
    font-weight: bold;
    cursor: pointer;
    width: 20px;
    height: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.win-btn-max {
    background: transparent;
    border: 1px solid var(--win-border);
    color: var(--win-title-text);
    font-weight: bold;
    cursor: pointer;
    width: 20px;
    height: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
    /* Let gap handle spacing */
    line-height: 1;
}

.win-btn-close:hover {
    background: var(--term-error);
    color: #fff;
}

.win-btn-max:hover {
    background: var(--win-border);
    color: #000;
}

/* MOBILE RESPONSIVE OVERRIDES */
@media (max-width: 768px) {
    :root {
        --top-bar-height: 50px;
    }

    .os-window {
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .win-btn-close,
    .win-btn-max {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    #desktop-layer {
        top: 20px;
        bottom: 48px;
    }

    #terminal-layer {
        padding-top: 80px;
        padding-bottom: 60px;
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Force show input bar on mobile */
    .mobile-input-bar {
        display: flex !important;
    }
}

/* === LAYOUT STRUCTURE === */

/* TOP BAR */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--top-bar-height);
    background: var(--top-bar-bg);
    border-bottom: 2px solid var(--top-bar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    box-sizing: border-box;
    z-index: 2000;
    backdrop-filter: blur(10px);
    font-size: 12px;
}



#top-links {
    display: flex;
    gap: 15px;
}

/* TERMINAL LAYER */
#terminal-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    padding: 10px;
    box-sizing: border-box;
    color: var(--term-text);
    overflow-y: auto;
    text-shadow: none;
    padding-top: calc(var(--top-bar-height) + 10px);
}

#terminal-output div {
    white-space: pre-wrap;
    font-family: var(--os-font-family);
    line-height: 1.2;
}

/* DESKTOP LAYER */
#desktop-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.os-window {
    pointer-events: auto;
    /* Enable interaction for windows */
    position: absolute;
    /* Essential for dragging */
}


/* RESIZE HANDLES & UTILITIES */
.resize-handle {
    position: absolute;
    width: 15px;
    height: 15px;
    bottom: 0px;
    right: 0px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, #666 50%);
}

.blink {
    animation: blinking 1s infinite;
}

@keyframes blinking {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* DROPDOWN MENU STYLES (from legacy JS injection) */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-link {
    color: var(--footer-text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--footer-highlight);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.dropdown-menu {
    border: 1px solid var(--term-highlight) !important;
    background: var(--top-bar-bg) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.dropdown-item {
    color: var(--term-highlight) !important;
}

.dropdown-item:hover {
    background: var(--btn-hover) !important;
}

/* Window Minimization Animation */
@keyframes minimizeSuck {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }

    100% {
        transform: scale(0.1) translateY(300px);
        /* Suck down */
        opacity: 0;
    }
}

@keyframes shockwave {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(255, 0, 0, 0));
    }

    50% {
        transform: scale(1.05) skewX(2deg);
        filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.8));
    }

    55% {
        transform: scale(0.95) skewX(-2deg);
        filter: drop-shadow(0 0 15px rgba(255, 0, 0, 0.9));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(255, 0, 0, 0));
    }
}

.os-window.minimizing {
    /* This rule was incomplete in the provided snippet.
       It has been left empty to maintain syntactical correctness. */
}

/* === START MENU & TASKBAR REFACTOR === */

@keyframes chopRight {
    0% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-10px);
    }

    100% {
        transform: translateX(0);
    }
}



/* New Taskbar Layout */
#top-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

#taskbar-apps {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100%;
    scrollbar-width: none;
    /* Firefox */
}

#taskbar-apps::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.task-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    height: 80%;
    border: 1px solid transparent;
    color: #888;
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    white-space: nowrap;
    max-width: 150px;
    transition: all 0.2s;
}

.task-item:hover {
    background: rgba(0, 255, 65, 0.1);
    color: #ccffcc;
}

.task-item.active {
    background: rgba(0, 255, 65, 0.2);
    border: 1px solid #00ff41;
    color: #00ff41;
    box-shadow: 0 0 5px rgba(0, 255, 65, 0.2);
}

.task-item.minimized {
    opacity: 0.5;
    font-style: italic;
}

.task-label {
    font-size: 0.8em;
    font-family: var(--os-ui-font);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile: Hide label, show icon */
@media (max-width: 768px) {
    .task-label {
        display: none;
    }

    .task-item {
        padding: 2px 6px;
        max-width: none;
    }
}

.start-btn {
    background: #000;
    color: #00ff41;
    border: 2px solid #00ff41;
    padding: 5px 15px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 5px #00ff41;
    transition: all 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 24px;
}

.start-btn:hover,
.start-btn.active {
    background: #00ff41;
    color: #000;
    box-shadow: 0 0 15px #00ff41;
}

.start-btn-logo {
    font-size: 1.2em;
}

.sys-tray {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #00ff41;
    font-size: 0.9em;
}

.tray-item {
    cursor: pointer;
    text-decoration: none;
    color: #00ff41;
    font-size: 1.2em;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tray-item:hover {
    transform: scale(1.2);
    text-shadow: 0 0 8px #00ff41;
}

.mem-gauge {
    font-family: monospace;
    border: 1px solid #004411;
    padding: 2px 6px;
    background: #001100;
    font-size: 0.8em;
    color: #00ff41;
    min-width: 60px;
    text-align: center;
    cursor: default;
}

/* Start Menu Overlay */
.start-menu {
    position: absolute;
    top: 45px;
    /* Just below top bar */
    left: 10px;
    width: 300px;
    max-width: 90vw;
    background: rgba(10, 15, 10, 0.98);
    border: 2px solid #00ff41;
    box-shadow: 0 5px 20px rgba(0, 255, 65, 0.2);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    animation: menuPop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes menuPop {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.menu-header {
    background: #00ff41;
    color: #000;
    padding: 8px 15px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-body {
    display: flex;
    flex-direction: row;
    height: 350px;
}

.menu-sidebar {
    width: 40px;
    background: #002205;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: #005511;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 0;
    font-weight: bold;
    font-size: 1.5em;
    user-select: none;
    border-right: 1px solid #004411;
}

.menu-content {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-category {
    border-bottom: 1px solid #004411;
    padding-bottom: 5px;
}

.cat-title {
    color: #55ff88;
    font-size: 0.8em;
    text-transform: uppercase;
    margin-bottom: 5px;
    opacity: 0.7;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    text-decoration: none;
    color: #00ff41;
    border: 1px solid transparent;
    transition: all 0.1s;
    font-size: 0.9em;
}

.menu-item:hover {
    background: #00ff41;
    color: #000;
    box-shadow: 2px 2px 0 #005511;
    transform: translate(-1px, -1px);
}

.menu-item .icon {
    font-size: 1.2em;
}

/* Mobile Tweaks */
@media (max-width: 600px) {
    .start-menu {
        width: 100%;
        left: 0;
        top: 50px;
        border-right: none;
        border-left: none;
        max-width: 100vw;
    }

    .sys-tray {
        gap: 10px;
    }

    .mem-gauge {
        display: none;
    }
}

/* --- CHAOS MINIMIZE ANIMATIONS --- */

@keyframes min-spin {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: scale(0.5) rotate(180deg);
    }

    100% {
        transform: scale(0) rotate(720deg);
        opacity: 0;
    }
}

@keyframes min-twist {
    0% {
        transform: skew(0deg) scale(1);
        opacity: 1;
    }

    30% {
        transform: skew(40deg) scale(1.1);
    }

    100% {
        transform: skew(90deg) scale(0);
        opacity: 0;
    }
}

@keyframes min-blast {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }

    40% {
        transform: scale(1.2);
        filter: brightness(2) hue-rotate(90deg);
    }

    100% {
        transform: scale(0.1) translate(0, 500px);
        opacity: 0;
    }
}

.os-window.min-spin {
    animation: min-spin 1s ease-in forwards !important;
}

.os-window.min-twist {
    animation: min-twist 1s ease-in-out forwards !important;
}

.os-window.min-blast {
    animation: min-blast 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards !important;
}