/* Basic Setup */
:root {
    --bg-teal: #008080;
    --win-gray: #c0c0c0;
    --win-dark-gray: #808080;
    --win-light-gray: #dfdfdf;
    --title-blue: #000080;
    --text-black: #000000;
    --text-white: #ffffff;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Modern fallback that looks decent */
    background-color: var(--bg-teal);
    overflow: hidden;
    user-select: none;
    height: 100vh;
    font-size: 12px;
}

/* Utils */
.bevel-out {
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    box-shadow: 1px 1px 0px 0px #808080, inset 1px 1px 0px 0px #dfdfdf;
    background-color: var(--win-gray);
}

.bevel-in {
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-right: 1px solid white;
    border-bottom: 1px solid white;
    background-color: white;
}

/* Desktop */
#desktop {
    width: 100%;
    height: calc(100% - 28px);
    /* Minus taskbar height */
    position: relative;
    padding: 5px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
}

.desktop-icon {
    width: 75px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
    cursor: default;
    color: white;
    text-shadow: 1px 1px black;
    /* Poor man's outline */
    text-align: center;
}

.desktop-icon img {
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
}

.desktop-icon span {
    padding: 2px;
    border: 1px dotted transparent;
}

.desktop-icon:hover span {
    /* background-color: var(--title-blue); */
}

.desktop-icon:active span {
    background-color: var(--title-blue);
    border: 1px dotted yellow;
}

/* Taskbar */
#taskbar {
    position: absolute;
    bottom: 0px;
    left: 0;
    width: 100%;
    height: 28px;
    background-color: var(--win-gray);
    border-top: 1px solid white;
    display: flex;
    align-items: center;
    padding: 2px;
    box-sizing: border-box;
    z-index: 1000;
}

#start-button {
    height: 22px;
    display: flex;
    align-items: center;
    padding: 0 4px;
    margin-right: 2px;
    font-weight: bold;
    font-size: 13px;
    /* Bevel out manual attempt for button */
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    background-color: var(--win-gray);
    box-shadow: 1px 1px 0px 0px black;
    cursor: pointer;
}

#start-button:active,
#start-button.active {
    border-top: 1px solid black;
    border-left: 1px solid black;
    border-right: 1px solid white;
    border-bottom: 1px solid white;
    box-shadow: none;
    transform: translate(1px, 1px);
}

#start-button img {
    height: 16px;
    width: 16px;
    margin-right: 4px;
}

#taskbar-divider {
    width: 2px;
    height: 20px;
    border-left: 1px solid #808080;
    border-right: 1px solid white;
    margin: 0 2px;
}

#task-list {
    flex-grow: 1;
    display: flex;
    padding: 0 2px;
    gap: 2px;
}

.taskbar-item {
    min-width: 100px;
    max-width: 150px;
    height: 22px;
    background-color: var(--win-gray);
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    display: flex;
    align-items: center;
    padding: 0 5px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
}

.taskbar-item img {
    width: 16px;
    height: 16px;
    margin-right: 4px;
}

.taskbar-item.active {
    border-top: 1px solid black;
    border-left: 1px solid black;
    border-right: 1px solid white;
    border-bottom: 1px solid white;
    background-color: #e0e0e0;
    /* Dotted pattern simulation */
    font-weight: bold;
}

#tray {
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-right: 1px solid white;
    border-bottom: 1px solid white;
    background-color: var(--win-gray);
    padding: 0 10px;
    margin-right: 2px;
    height: 22px;
    display: flex;
    align-items: center;
    font-size: 11px;
}

/* Start Menu */
#start-menu {
    position: absolute;
    bottom: 28px;
    left: 2px;
    width: 200px;
    background-color: var(--win-gray);
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    box-shadow: 2px 2px 0px 0px black;
    z-index: 1001;
    display: flex;
}

.sidebar {
    width: 25px;
    background: linear-gradient(to bottom, #000080, #0000ff);
    color: white;
    display: flex;
    align-items: flex-end;
    padding-bottom: 10px;
    overflow: hidden;
}

.vertical-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 16px;
    font-weight: bold;
    padding-right: 2px;
    white-space: nowrap;
}

.menu-items {
    flex-grow: 1;
    padding: 2px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: default;
}

.menu-item:hover {
    background-color: var(--title-blue);
    color: white;
}

.menu-item img {
    width: 24px;
    height: 24px;
    margin-right: 8px;
}

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

.menu-items hr {
    border: 0;
    border-top: 1px solid #808080;
    border-bottom: 1px solid white;
    margin: 2px 0;
}

/* Window Interface */
.window {
    position: absolute;
    background-color: var(--win-gray);
    padding: 2px;
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    box-shadow: 1px 1px 0px 0px black;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
    /* Prevent content from spilling out of the border */
}

.title-bar {
    background: linear-gradient(to right, var(--title-blue), #1084d0);
    padding: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-weight: bold;
    cursor: default;
}

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

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-controls button {
    width: 16px;
    height: 14px;
    background-color: var(--win-gray);
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    padding: 0;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-weight: bold;
}

.title-bar-controls button:active {
    border-top: 1px solid black;
    border-left: 1px solid black;
    border-right: 1px solid white;
    border-bottom: 1px solid white;
}

/* Pseudo-icons for minimize/maximize/close - simplified */
.title-bar-controls button[aria-label="Minimize"]::after {
    content: "_";
    position: relative;
    top: -2px;
}

.title-bar-controls button[aria-label="Maximize"]::after {
    content: "☐";
}

.title-bar-controls button[aria-label="Close"]::after {
    content: "✕";
    font-size: 10px;
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100% - 28px) !important;
    border: none;
    box-shadow: none;
}

/* Terminal Styles */
.terminal-body {
    background-color: black;
    color: #c0c0c0;
    font-family: 'Consolas', 'Lucida Console', monospace;
    font-size: 14px;
    padding: 5px;
    height: 100%;
    box-sizing: border-box;
    cursor: text;
    overflow-y: hidden;
    /* Scroll handled by window-body parent usually, but here we want full height */
}

/* Force window body to be black for terminal if generic styles override */
#terminal .window-body {
    background-color: black;
}

.cmd-line {
    display: flex;
    align-items: center;
}

.cmd-line .prompt {
    margin-right: 5px;
}

#cmd-input {
    background: transparent;
    border: none;
    color: #c0c0c0;
    font-family: 'Consolas', 'Lucida Console', monospace;
    font-size: 14px;
    flex-grow: 1;
    outline: none;
}


/* News App Styles */
.news-item {
    border-bottom: 1px dotted #ccc;
    padding-bottom: 10px;
    margin-bottom: 10px;
    color: black;
}

.news-item h3 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #000080;
}

.window-body {
    margin-top: 2px;
    flex-grow: 1;
    min-height: 0;
    /* Important for flex child scrolling */
    display: flex;
    /* Make content fill space */
    flex-direction: column;
}

.window-body>* {
    flex-grow: 1;
    /* Force direct children to fill height */
}

.news-item p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
}

.news-item a {
    color: blue;
}

/* Resizer Handle */
.resizer {
    width: 15px;
    height: 15px;
    position: absolute;
    right: 0;
    bottom: 0;
    cursor: se-resize;
    z-index: 100;
    background: linear-gradient(135deg, transparent 50%, #808080 50%, #808080 60%, transparent 60%, transparent 70%, #808080 70%, #808080 80%, transparent 80%);
}

/* Responsive Styles for Mobile */
@media (max-width: 768px) {

    /* Windows take up most of the screen */
    .window {
        width: 95% !important;
        left: 2.5% !important;
        /* We allow top to still be variable so they can stack a bit, 
           but in a real mobile OS they might be fullscreen. */
    }

    /* Start Menu adjustments */
    #start-menu {
        width: 85%;
        left: 5px;
        bottom: 35px;
        /* Above taskbar */
    }

    /* Taskbar Compact Mode */
    .taskbar-item {
        min-width: 40px;
        max-width: 40px;
        padding: 0;
        justify-content: center;
    }

    .taskbar-item span {
        display: none;
        /* Hide text, show only icon */
    }

    .taskbar-item img {
        margin-right: 0;
    }

    /* Hide clock/tray on very small screens if needed, or keep it compact */
    #tray {
        padding: 0 4px;
        font-size: 10px;
    }

    /* Adjust desktop icon grid */
    #desktop {
        padding: 10px;
        align-content: flex-start;
    }

    .desktop-icon {
        margin: 5px;
        width: 70px;
    }
}

/* Modal Alert Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    z-index: 20000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-window {
    background-color: var(--win-gray);
    padding: 2px;
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    box-shadow: 2px 2px 0px 0px black;
    min-width: 300px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
}

.modal-body {
    padding: 15px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
}

.modal-icon img {
    width: 32px;
    height: 32px;
}

.modal-message {
    font-size: 13px;
    color: black;
    flex-grow: 1;
    align-self: center;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-bottom: 10px;
}

.modal-button {
    min-width: 75px;
    height: 23px;
    background-color: var(--win-gray);
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    box-shadow: 1px 1px 0px 0px black;
    font-size: 12px;
    cursor: pointer;
}

.modal-button:active {
    border-top: 1px solid black;
    border-left: 1px solid black;
    border-right: 1px solid white;
    border-bottom: 1px solid white;
    box-shadow: none;
    transform: translate(1px, 1px);
}

.modal-button:focus {
    outline: 1px dotted black;
    outline-offset: -4px;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: #c0c0c0;
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-right: 1px solid #404040;
    border-bottom: 1px solid #404040;
    padding: 2px;
    z-index: 10000;
    width: 150px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    font-family: 'Segoe UI', sans-serif;
    font-size: 12px;
}

.context-menu .menu-item {
    padding: 4px 10px;
    cursor: default;
}

.context-menu .menu-item:hover {
    background: #000080;
    color: white;
}

.context-menu .menu-separator {
    height: 1px;
    background: #808080;
    border-bottom: 1px solid white;
    margin: 2px 1px;
}