/* Windows 95 Retro Styling */
@import url('data:font/truetype;charset=utf-8;base64,AAEAAAARAQAABAAARkZUTQAAABwAAAAcTlRNUAAAAPQAAAD0T1MvMgAAAPQAAABgY21hcAAAA1wAAAFoY3Z0IAAAAxgAAAAgZnBnbQAAAwAAAAASZ2x5ZgAAAwAAAAASaGVhZAAAAkAAAAA2aGhlYQAAApgAAAAkaG10eAAAArwAAAAQbG9jYQAAAtAAAAAMbWF4cAAAA+QAAABQPGV0dQAAAAAAAAByUE9TVAAAAwAAAAATdmlkAAAAAAAAAA==');

* {
    box-sizing: border-box;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
    /* Disable text selection by default */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Re-enable text selection for input fields and textareas */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
.win95-input,
.win95-textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(to bottom, #008080, #004040);
    cursor: default;
}

#desktop {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#desktop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Desktop Icons */
.desktop-icon {
    position: absolute;
    width: 64px;
    text-align: center;
    cursor: pointer;
    z-index: 2;
}

.desktop-icon:hover {
    background: rgba(0, 0, 128, 0.3);
}

.icon-image {
    font-size: 32px;
    margin-bottom: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 32px;
}

.icon-image img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.icon-label {
    color: white;
    font-size: 11px;
    text-shadow: 1px 1px 1px #000;
    word-wrap: break-word;
}

/* Windows */
.window {
    position: absolute;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.window-title-bar {
    background: linear-gradient(to right, #000080, #000040);
    color: white;
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.window-title {
    font-weight: bold;
    font-size: 11px;
}

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

.window-control {
    width: 16px;
    height: 14px;
    background: #c0c0c0;
    border: 1px outset #c0c0c0;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.window-control.info {
    background: #ffff80;
    color: #000080;
}

.window-control:hover {
    background: #d4d0c8;
}

.window-control.info:hover {
    background: #ffffaa;
}

.window-control:active {
    border: 1px inset #c0c0c0;
}

.window-content {
    padding: 4px;
}

.window-content canvas {
    display: block;
    border: 1px inset #c0c0c0;
}

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

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

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

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

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

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

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

.resize-handle.resize-se {
    bottom: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    cursor: se-resize;
}

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

/* Show resize handles only on hover */
.window:hover .resize-handle {
    background: rgba(0, 0, 128, 0.1);
}

.window.resizing .resize-handle {
    background: rgba(0, 0, 128, 0.3);
}

/* Module Info Dialog */
.module-info-dialog code {
    background: #f0f0f0;
    padding: 2px 4px;
    font-family: 'Courier New', monospace;
    border: 1px inset #c0c0c0;
    display: block;
    margin: 8px 0;
    white-space: pre-wrap;
}

.module-info-dialog h3, .module-info-dialog h4 {
    margin: 12px 0 6px 0;
    color: #000080;
}

.module-info-dialog ul {
    margin: 6px 0;
    padding-left: 20px;
}

.module-info-dialog li {
    margin: 2px 0;
}

/* Taskbar */
#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #c0c0c0;
    border-top: 1px solid #white;
    display: flex;
    align-items: center;
    padding: 2px;
    z-index: 1000;
}

#start-button {
    height: 32px;
    padding: 4px 8px;
    margin-right: 4px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 4px;
}

.start-flag {
    display: flex;
    align-items: center;
}

.start-flag-icon {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#taskbar-buttons {
    flex: 1;
    display: flex;
    gap: 2px;
}

.taskbar-button {
    height: 32px;
    padding: 4px 8px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#system-tray {
    margin-left: auto;
    padding: 4px 8px;
    border: 1px inset #c0c0c0;
    background: #c0c0c0;
}

#clock {
    font-family: 'MS Sans Serif', monospace;
    font-size: 11px;
}

/* Windows 95 Button Style */
.win95-button {
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    color: black;
    padding: 4px 12px;
    cursor: pointer;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
}

.win95-button:hover {
    background: #d4d0c8;
}

.win95-button:active {
    border: 2px inset #c0c0c0;
}

/* Start Menu */
#start-menu {
    position: absolute;
    bottom: 40px;
    left: 2px;
    width: 200px;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 1001;
}

.start-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid #808080;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.menu-icon {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.start-menu-separator {
    height: 1px;
    background: #808080;
    margin: 2px 8px;
}

/* Multi-level Programs Menu */
.programs-submenu {
    position: fixed;
    width: 250px;
    max-height: 500px;
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    overflow-y: auto;
    /* Ensure menus don't exceed viewport bounds */
    max-width: calc(100vw - 10px);
}

.submenu-item {
    padding: 6px 16px;
    cursor: pointer;
    font-size: 11px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.submenu-item:hover {
    background: #0080ff;
    color: white;
}

.submenu-item:last-child {
    border-bottom: none;
}

.submenu-item.has-submenu {
    position: relative;
}

.submenu-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.submenu-icon {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}

.submenu-arrow {
    font-size: 10px;
    color: #808080;
}

.submenu-item.has-submenu:hover .submenu-arrow {
    color: white;
}

.submenu-separator {
    height: 1px;
    background: #808080;
    margin: 2px 8px;
}

.submenu-custom-app {
    background: #ffffe0;
    font-weight: bold;
    color: #000080;
    border-top: 2px solid #808080;
    display: flex;
    align-items: center;
    gap: 8px;
}

.submenu-custom-app:hover {
    background: #ffff80;
    color: #000080;
}

/* Category submenus */
.category-submenu {
    width: 220px;
    /* Ensure category submenus also respect viewport bounds */
    max-width: calc(100vw - 10px);
}

.category-submenu .submenu-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Modal Dialog */
#modal-overlay, #settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.win95-dialog {
    background: #c0c0c0;
    border: 2px outset #c0c0c0;
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.5);
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.dialog-title-bar {
    background: linear-gradient(to right, #000080, #000040);
    color: white;
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.dialog-close {
    width: 16px;
    height: 14px;
    background: #c0c0c0;
    border: 1px outset #c0c0c0;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.dialog-content {
    padding: 16px;
}

.dialog-content p {
    margin: 0 0 12px 0;
}

.win95-input {
    width: 100%;
    padding: 4px;
    border: 2px inset #c0c0c0;
    background: white;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
    margin-bottom: 16px;
}

.win95-textarea {
    width: 100%;
    padding: 4px;
    border: 2px inset #c0c0c0;
    background: white;
    font-family: 'MS Sans Serif', sans-serif;
    font-size: 11px;
    margin-bottom: 16px;
    resize: vertical;
    min-height: 80px;
}

.help-text {
    background: #ffffcc;
    border: 1px solid #e6e600;
    padding: 8px;
    margin: 8px 0;
    font-size: 10px;
}

.help-text p {
    margin: 0;
}

.help-text code {
    background: #f0f0f0;
    padding: 1px 3px;
    font-family: 'Courier New', monospace;
    border: 1px inset #c0c0c0;
}

.dialog-buttons {
    text-align: right;
}

.dialog-buttons .win95-button {
    margin-left: 8px;
}

/* Settings specific styles */
.settings-section {
    margin-bottom: 20px;
}

.settings-section label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    color: #000080;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Scrollbars (Windows 95 style) */
::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

::-webkit-scrollbar-track {
    background: #c0c0c0;
    border: 1px inset #c0c0c0;
}

::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border: 1px outset #c0c0c0;
}

::-webkit-scrollbar-thumb:hover {
    background: #d4d0c8;
}

::-webkit-scrollbar-corner {
    background: #c0c0c0;
}

/* Footer */
.footer {
    position: fixed;
    bottom: 45px;
    right: 10px;
    background: rgba(192, 192, 192, 0.9);
    padding: 4px 8px;
    border: 1px outset #c0c0c0;
    font-size: 10px;
    z-index: 999;
}

.footer a {
    color: #000080;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}