/* css/style.css */

/*--- Global & Body ---*/
html {
    height: 100%;
    overflow: hidden;
}
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "Pixelated MS Sans Serif", Arial, sans-serif;
    font-size: 11px;
    background-color: #008080;
    cursor: default;
    display: flex;
    flex-direction: column;
}
body.desktop-background {
    background: url('../res/clouds.jpg') no-repeat center center fixed;
    background-size: cover;
}

body, .desktop-icon span {
    font-smooth: never;
    -webkit-font-smoothing: none;
}

.taskbar, #start-menu, #start-submenu, .desktop-icon, .window .title-bar {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
img {
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}
*:focus {
    outline: none;
    outline: 0;
}
::-moz-focus-inner {
    border: 0;
}

/*--- Layout ---*/
#desktop-area {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    height: calc(100% - 28px);
}
#window-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}
#window-area > .window {
    pointer-events: auto;
}
#desktop-icons-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 8px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px 4px;
    z-index: 0;
}

/*--- Desktop Icons (48x48) ---*/
.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 72px;
    height: 90px;
    padding: 4px;
    border: 1px solid transparent;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}
.desktop-icon a {
    text-decoration: none;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    width: 100%;
    height: 100%;
}
.desktop-icon a:focus { }
.desktop-icon img {
    width: 48px;
    height: 48px;
    margin-bottom: 5px;
}
.desktop-icon span {
    color: white;
    text-shadow: 1px 1px 1px black;
    font-size: 11px;
    line-height: 12px;
    max-height: 28px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-wrap: break-word;
    word-break: break-word;
    background-color: transparent;
    padding: 1px 2px;
    border: 1px solid transparent;
    box-sizing: border-box;
    width: 100%;
    text-align: center;
    flex-grow: 1;
    text-rendering: optimizeLegibility;
}
.desktop-icon.selected {
    border-color: white;
    border-style: dotted;
}
.desktop-icon.selected span {
     background-color: #0000a8;
     color: white;
     text-shadow: none;
}
.desktop-icon.selected a::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 48px;
    background-color: rgba(0, 0, 168, 0.4);
    pointer-events: none;
    z-index: 1;
}

/*--- Taskbar ---*/
.taskbar {
    height: 28px;
    width: 100%;
    box-sizing: border-box;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    padding: 2px;
    background-color: #c0c0c0;
    border-top: 1px solid white;
    box-shadow: inset 0px 1px 1px #dfdfdf;
}
#start-button {
    font-weight: bold;
    min-width: 60px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-right: 2px;
}
#start-button img { width: 16px; height: 16px; margin-right: 4px; }
#start-button.active img { position: relative; top: 1px; left: 1px; }
.taskbar-tasks-container { flex-grow: 1; display: flex; align-items: center; height: 100%; overflow: hidden; padding: 0 2px; }
.taskbar-button { flex-shrink: 1; min-width: 60px; max-width: 160px; height: 22px; margin-right: 2px; padding: 0 4px; display: flex; align-items: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.taskbar-button.active { padding-top: 2px; padding-left: 5px; border-style: inset; }
.taskbar-button img { width: 16px; height: 16px; margin-right: 4px; }
.taskbar-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-grow: 1; text-align: left; }
.system-tray { display: flex; align-items: center; margin-left: auto; }
#taskbar-clock { height: 22px; line-height: 22px; padding: 0 6px; }

/*--- Start Menu ---*/
#start-menu {
    position: fixed;
    bottom: 28px;
    left: 0;
    min-width: 170px;
    background-color: #c0c0c0;
    border: 1px solid;
    border-color: white #808080 #808080 white;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
    z-index: 100;
    padding: 2px;
    box-sizing: border-box;
}
.start-menu-sidebar {
    background-color: #808080;
    width: 25px;
    position: absolute;
    top: 2px;
    left: 2px;
    bottom: 2px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    box-sizing: border-box;
}
.sidebar-text { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: bold; font-size: 18px; color: #c0c0c0; text-shadow: 1px 1px 1px black; }
.menu {
     background-color: #c0c0c0;
}
#start-menu-pane {
    margin-left: 25px;
    padding: 1px;
    min-height: 200px;
    box-sizing: border-box;
}
#start-submenu {
    position: fixed;
    min-width: 150px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
    padding: 1px;
    z-index: 101;
}
.menu-icon { width: 16px; height: 16px; margin-right: 6px; vertical-align: middle; }
#start-menu-pane > .menu-item > .menu-icon { width: 20px; height: 20px; }
.menu-item {
    padding: 2px 8px 2px 4px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    position: relative;
}
.menu-item.selected { background-color: #0000a8; color: white; }
.menu-item.has-arrow::after { content: ''; display: inline-block; width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 4px solid black; position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.menu-item.has-arrow.selected::after { border-left-color: white; }
.separator { height: 1px; background-color: #808080; border-bottom: 1px solid white; margin: 2px 0; padding: 0 !important; list-style: none; }

/*--- Windows ---*/
.window {
    box-sizing: border-box;
}
.window .window-body {
    box-sizing: border-box;
    height: calc(100% - 18px);
    overflow: hidden;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    background-color: #c0c0c0;
}
.window:not(.dialog-window) .toolbar.window-menubar {
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    height: 21px;
    border-bottom: 1px solid #808080;
    box-shadow: 0px 1px 0px 0px white;
    margin: 0;
    padding: 0 2px;
    list-style: none;
    display: flex;
    align-items: center;
}
.window:not(.dialog-window) .window-content-inner.inset-deep {
    padding: 2px;
    overflow: auto;
    flex-grow: 1;
    background-color: white;
    border: 1px solid;
    border-color: #808080 white white #808080;
    margin: 2px;
    box-sizing: border-box;
}
.window:not(.dialog-window) .status-bar {
    flex-shrink: 0;
    height: 17px;
    border-top: 1px solid white;
    border-bottom: none;
    box-sizing: border-box;
    display: flex;
}
.window:not(.dialog-window) .status-bar-field {
    border: 1px solid;
    border-color: #808080 white white #808080;
    margin: -1px 0 0 -1px;
    padding: 0 4px;
    height: 100%;
    line-height: 15px;
    box-sizing: border-box;
    background-color: #c0c0c0;
}
.window:not(.dialog-window) .status-bar-field:first-child {
     margin-left: 0;
}
.window:not(.dialog-window) .status-bar-field:nth-child(2) {
    flex-grow: 1;
}
.window.active > .title-bar { background-color: #0000a8; color: white; }
.window.active > .title-bar .title-bar-text { color: white; }

/*--- Window Menu Bar Styles ---*/
.window-menubar > li.menu-item {
    padding: 2px 6px;
    border: 1px solid transparent;
    box-sizing: border-box;
    height: 100%;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}
.window-menubar > li.menu-item.active {
    background-color: #0000a8;
    color: white;
    border: 1px solid #0000a8;
}
.window-menu-dropdown {
    position: absolute;
    min-width: 120px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
    border: 1px solid;
    border-color: white #808080 #808080 white;
    padding: 1px;
    background-color: #c0c0c0; /* Ensure dropdown has background */
    z-index: 3; /* Above toolbar */
}
.window-menu-dropdown li.menu-item.checked {
     position: relative;
     padding-left: 20px;
}
.window-menu-dropdown li.menu-item.checked::before {
     content: '✓';
     position: absolute;
     left: 5px;
     top: 50%;
     transform: translateY(-50%);
     font-weight: bold;
}
.window-menu-dropdown li.menu-item.selected::before {
     color: white;
}

/*--- Dialog Window Styles ---*/
.dialog-window .title-bar-controls button[aria-label="Minimize"],
.dialog-window .title-bar-controls button[aria-label="Maximize"] {
    display: none;
}
.dialog-window .window-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    height: calc(100% - 18px);
    background-color: #c0c0c0;
    overflow: hidden;
}
.dialog-content {
    display: flex;
    align-items: center;
    flex-grow: 1;
}
.dialog-icon {
    width: 32px;
    height: 32px;
    margin-right: 15px;
    flex-shrink: 0;
}
.dialog-message {
    font-size: 11px;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
}
.dialog-buttons {
    padding: 8px;
    margin: 0;
    margin-top: 15px;
    border: none;
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}
.dialog-buttons button {
    min-width: 70px;
}

/*--- Window Content Icons ---*/
.window-icon-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 5px;
}
.window-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 60px;
    cursor: default;
    padding: 4px;
    border: 1px solid transparent;
}
.window-icon-item:focus {
     border: 1px dotted black;
     background-color: #ddd;
}
.window-icon-item img {
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
}
.window-icon-item span {
    font-size: 11px;
    line-height: 1.2;
    word-wrap: break-word;
    max-height: calc(1.2em * 2);
    overflow: hidden;
}

/* For Window Resizing */
.window-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px; /* Slightly larger for easier grab */
    height: 12px;
    cursor: nwse-resize;
    z-index: 1; /* Ensures it's above window content if overlaps */
}

.window.maximized .window-resize-handle {
    display: none; /* Hide when maximized */
}

/* Optional: Change cursor during resize globally */
body.resizing-window {
    cursor: nwse-resize !important;
}
/* Optional: Change cursor during dragging globally */
body.dragging-window {
    cursor: grabbing !important; /* Or 'move' */
}


/* For Icon Wrapping in Window Content */
.window-icon-grid {
    display: flex;
    flex-wrap: wrap;
    padding: 8px; /* Give some padding inside the content area */
    gap: 10px; /* Spacing between icons horizontally and vertically */
    align-content: flex-start; /* Important for wrapping from the top */
    overflow-y: auto; /* Allow vertical scrolling if many icons */
    height: 100%; /* Make the grid take full height of its container */
    box-sizing: border-box;
}

.window-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 75px; /* Adjust as needed for icon size + padding */
    padding: 4px;
    cursor: default;
    /* To make selection look more like Win98, you might add:
    border: 1px solid transparent; */
}


.window-icon-item:hover {
    background-color: #000080;  Highlight color
    color: white;
    border: 1px dotted #FFFFFF;
}
.window-icon-item:focus, .window-icon-item.selected {
    background-color: #000080;
    color: white;
    border: 1px dotted #FFFFFF;
}
.window-icon-item:focus img, .window-icon-item.selected img {
     filter: brightness(0) invert(1); // If you want to invert icon colors on selection
}



.window-icon-item img {
    margin-bottom: 4px;
}

.window-icon-item span {
    word-break: break-word;
    font-size: 11px;
    line-height: 1.2;
    max-height: 2.4em; /* Approx 2 lines */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Ensure window-content-inner allows its children to take height */
.window .window-content-inner {
    display: flex; /* This helps .window-icon-grid take up available space */
    flex-direction: column;
    overflow: hidden; /* Important if content inside grid is also scrollable */
}

/*--- Interaction Styles ---*/
body.dragging-window, body.dragging-window * { cursor: move !important; }


