/* core/desktop.css */

body {
    height: 100vh;
    width: 100vw;
    margin: 0;
    overflow: hidden;
    background: #3A6EA5;
    background-size: cover;
    /* Main UI Font (Menus, Dialogs, Desktop Icons) is Tahoma */
    font-family: 'Tahoma', sans-serif;
    font-size: 11px;
    user-select: none;
    -webkit-user-select: none;
    visibility: hidden;
}

/* --- WINDOW FRAME (9-Slice Layout) --- */
.os-window {
    position: absolute;
    display: flex; flex-direction: column;
    background: transparent;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.3));
    min-width: 200px; 
    min-height: 100px;
    
    /* Authentic XP: Only transform (scale/move) allows animation. */
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1), 
                width 0.1s, height 0.1s; 
    transform-origin: bottom left; 
}

.os-window.minimized {
    transform: scale(0) !important;
    pointer-events: none;
}

/* --- MINIMIZE ANIMATION GHOST --- */
.os-minimize-ghost {
    position: absolute;
    z-index: 9998;
    overflow: hidden;
    pointer-events: none;
    transform-origin: top left;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.os-window.animating {
    pointer-events: none;
    will-change: transform, top, left, width, height;
	transition: all 0.25s cubic-bezier(0.2, 0, 0, 1) !important;
}

.os-window.maximized {
    transition: all 0.2s ease-in-out;
    top: 0 !important; left: 0 !important;
    width: 100% !important; height: calc(100% - 30px) !important;
    border-radius: 0; box-shadow: none;
}

/* --- TOP: Title Bar --- */
.window-top { 
    position: relative; height: 30px; width: 100%; overflow: hidden; user-select: none; 
}
.wt-left { 
    position: absolute; top: 0; left: 0; bottom: 0; width: 8px;
    background: url('../assets/xp/window_titlebar_left.png') no-repeat; z-index: 10;
}
.wt-right { 
    position: absolute; top: 0; right: 0; bottom: 0; width: 27px;
    background: url('../assets/xp/window_titlebar_right.png') no-repeat; z-index: 10;
}

/* Background is separated into pseudo-element so we can "whitewash" it independently of text */
.wt-mid { 
    position: absolute; top: 0; bottom: 0; left: 8px !important; right: 27px !important; width: auto !important;
    background: none; 
    z-index: 20; overflow: visible !important; 
    display: flex; align-items: flex-start; justify-content: space-between;
}

.wt-mid::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: url('../assets/xp/window_titlebar_background.png') repeat-x; 
    z-index: -1; 
}

.window-icon { width: 16px; height: 16px; margin-left: 5px; margin-top: 9px; pointer-events: none; }

/* [FIXED] Title Bar Font is Trebuchet MS in Luna Theme */
.window-title { 
    flex: 1; 
    font-family: 'Trebuchet MS', 'Tahoma', sans-serif; /* XP Specific */
    font-size: 10pt; 
    color: white; 
    /* XP Active Shadow is a hard drop, not blurry */
    text-shadow: 1px 1px 0px rgba(0,0,0,0.5); 
    font-weight: bold; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    padding-left: 4px; 
    margin-top: 9px; 
}

.window-controls { display: flex; gap: 2px; position: relative; margin-top: 6px; margin-right: -21px; }
.window-controls button {
    width: 21px; height: 21px; border: none; margin: 0; padding: 0;
    background-image: url('../assets/xp/window_titlebar_controls.png');
    background-repeat: no-repeat; background-color: transparent; 
    color: transparent; font-size: 0; cursor: pointer;
}
.window-controls .btn-min { background-position-x: 0px; }       
.window-controls .btn-max { background-position-x: -21px; }     
.window-controls .btn-close { background-position-x: -63px; }   
.window-controls button:hover { background-position-y: -21px; } 
.window-controls button:active { background-position-y: -42px; }

/* --- MIDDLE & BOTTOM --- */
.window-middle { display: flex; flex: 1; position: relative; overflow: hidden; }
.wm-left { width: 3px; background: url('../assets/xp/window_frame_left.png') repeat-y; flex-shrink: 0; }
.wm-content { 
    flex: 1; background: #fff; position: relative; 
    display: flex; flex-direction: column; overflow: hidden; 
    user-select: text; -webkit-user-select: text;
}
.wm-right { width: 3px; background: url('../assets/xp/window_frame_right.png') repeat-y; flex-shrink: 0; }
.window-bottom { display: flex; height: 3px; }
.wb-left { width: 3px; background: url('../assets/xp/window_frame_bottomleft.png') no-repeat; flex-shrink: 0; }
.wb-mid { flex: 1; background: url('../assets/xp/window_frame_bottom.png') repeat-x; }
.wb-right { width: 3px; background: url('../assets/xp/window_frame_bottomright.png') no-repeat; flex-shrink: 0; }

/* --- TASKBAR --- */
#taskbar {
    position: absolute; bottom: 0; left: 0; right: 0; height: 30px; 
    background: url('../assets/xp/taskbar_bg.png') repeat-x;
    display: flex; align-items: flex-start; z-index: 9999;
}
#start-button { width: 99px; height: 30px; cursor: pointer; margin-right: 10px; }
#start-button img { height: 30px; width: 99px; pointer-events: none; }
#start-button:active { transform: translateY(1px); }

#taskbar-tasks { flex: 1; display: flex; height: 30px; gap: 0px; padding: 0; overflow: hidden; }

/* --- TASKBAR ITEM --- */
.taskbar-item { 
    display: flex; height: 30px; flex: 1 1 0; min-width: 0; max-width: 160px; 
    cursor: pointer; margin-right: -1px; align-items: stretch;
    overflow: hidden; 
    transition: max-width 0.2s cubic-bezier(0.2, 0, 0, 1), 
                flex-grow 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.taskbar-item.adding { max-width: 10px; flex-grow: 0.0001; }
.taskbar-item.removing { max-width: 0px !important; flex-grow: 0 !important; border: 0 !important; margin: 0 !important; }
.taskbar-item:hover .tb-mid { filter: brightness(1.1); }

.tb-left { width: 4px; background: url('../assets/xp/btn_idle_left.png') no-repeat 0 0; }
.tb-mid { 
    flex: 1; background: url('../assets/xp/btn_idle_bg.png') repeat-x 0 0; 
    display: flex; align-items: center; padding: 0 5px; overflow: hidden; 
}
.tb-right { width: 4px; background: url('../assets/xp/btn_idle_right.png') no-repeat 0 0; }

.taskbar-item img { width: 16px; height: 16px; margin-right: 5px; }
.taskbar-item span { color: white; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-group-count { color: #FF9900 !important; font-weight: bold; margin-right: 2px; text-shadow: none; }

.taskbar-item.active .tb-left { background-image: url('../assets/xp/btn_active_left.png'); }
.taskbar-item.active .tb-mid { background-image: url('../assets/xp/btn_active_bg.png'); }
.taskbar-item.active .tb-right { background-image: url('../assets/xp/btn_active_right.png'); }

@keyframes taskbar-flash {
    0% { background-image: url('../assets/xp/btn_active_bg.png'); } 
    50% { background-image: url('../assets/xp/btn_flash_bg.png'); } 
    100% { background-image: url('../assets/xp/btn_active_bg.png'); }
}
.taskbar-item.flashing .tb-left { background-image: url('../assets/xp/btn_flash_left.png'); }
.taskbar-item.flashing .tb-mid { background-image: url('../assets/xp/btn_flash_bg.png'); animation: taskbar-flash 1s infinite; color: white; }
.taskbar-item.flashing .tb-right { background-image: url('../assets/xp/btn_flash_right.png'); }

.taskbar-item.grouped .tb-mid { padding-right: 8px; }
.taskbar-item.grouped .tb-mid::after {
    content: ''; display: block; width: 0; height: 0; 
    border-left: 3px solid transparent; border-right: 3px solid transparent; border-top: 3px solid white; 
    margin-left: auto; 
}

.taskbar-group-menu {
    position: fixed; bottom: 30px; background-color: white;
    border: 1px solid #003c74; border-bottom: none;
    min-width: 150px; box-shadow: 2px -2px 5px rgba(0,0,0,0.2);
    z-index: 9000; display: none;
    font-family: 'Tahoma', sans-serif; font-size: 11px; color: black;
}
.taskbar-group-menu.visible { display: block; }
.taskbar-group-item { padding: 6px 10px; display: flex; align-items: center; gap: 8px; cursor: pointer; border-bottom: 1px solid #ececec; }
.taskbar-group-item:hover { background-color: #316ac5; color: white; }
.taskbar-group-item img { width: 16px; height: 16px; }

/* --- SYSTEM TRAY --- */
#tray {
    background: url('../assets/xp/taskbar_tray_bg.png') repeat-x; height: 30px; padding: 0 10px;
    display: flex; align-items: center; border-left: 1px solid rgba(0,0,0,0.2);
    font-size: 11px; color: white; margin-left: auto; 
}
.tray-icon { width: 16px; margin-right: 5px; margin-top: 4px; cursor: pointer; }

/* --- DESKTOP ICONS --- */
#desktop-icons { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 20px; z-index: 10; }
.desktop-icon { position: relative; width: 70px; display: flex; flex-direction: column; align-items: center; cursor: pointer; text-align: center; color: white; text-shadow: 1px 1px 2px black; }
.desktop-icon-img { width: 32px; height: 32px; margin-bottom: 5px; pointer-events: none; z-index: 1; }
.desktop-icon-shortcut { position: absolute; width: 11px; height: 11px; left: 19px; top: 21px; z-index: 2; pointer-events: none; }
.desktop-icon-label { background: transparent; padding: 2px; font-size: 11px; border: 1px solid transparent; }
.desktop-icon:hover .desktop-icon-label, .desktop-icon.selected .desktop-icon-label { background-color: #0055EA; border: 1px dotted #fff; }

/* --- RESIZE HANDLES --- */
.resize-handle { position: absolute; z-index: 100; }
.resize-handle.n { top: 0; left: 0; width: 100%; height: 5px; cursor: ns-resize; }
.resize-handle.s { bottom: 0; left: 0; width: 100%; height: 5px; cursor: ns-resize; }
.resize-handle.e { top: 0; right: 0; width: 5px; height: 100%; cursor: ew-resize; }
.resize-handle.w { top: 0; left: 0; width: 5px; height: 100%; cursor: ew-resize; }
.resize-handle.ne { top: 0; right: 0; width: 10px; height: 10px; cursor: ne-resize; z-index: 101; }
.resize-handle.nw { top: 0; left: 0; width: 10px; height: 10px; cursor: nw-resize; z-index: 101; }
.resize-handle.se { bottom: 0; right: 0; width: 10px; height: 10px; cursor: se-resize; z-index: 101; }
.resize-handle.sw { bottom: 0; left: 0; width: 10px; height: 10px; cursor: sw-resize; z-index: 101; }

/* --- GLOBAL BUSY --- */
/* [FIX] Use 'progress' (Arrow + Hourglass) instead of 'wait' so user feels they can still interact */
body.global-busy, body.global-busy * { cursor: progress !important; }

/* --- START MENU --- */
#start-menu {
    position: absolute; bottom: 30px; left: 0; width: 280px;
    background: white; border: 1px solid #000;
    border-top-right-radius: 5px; border-top-left-radius: 5px;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.5); z-index: 10000;
    display: flex; flex-direction: column; font-family: 'Tahoma', sans-serif;
}
#start-menu.hidden { display: none; }
.start-header {
    height: 50px; background: linear-gradient(to bottom, #245edb 0%, #1543b5 100%);
    border-top-right-radius: 5px; border-top-left-radius: 5px;
    display: flex; align-items: center; padding: 0 10px;
    color: white; font-weight: bold; font-size: 14px; border-bottom: 2px solid #e76d1e;
}
.start-user-icon {
    width: 32px; height: 32px; background: white; border-radius: 3px;
    border: 1px solid #8ba1d5; margin-right: 10px;
    background-image: url('../assets/msn/displaypictures/ChessPieces.webp'); 
    background-size: cover;
}
.start-body { flex: 1; display: flex; flex-direction: column; padding: 2px; background: white; }
.start-list { padding: 5px; background: white; border-right: 1px solid #d3d3d3; min-height: 200px; }
.start-item { display: flex; align-items: center; padding: 5px; cursor: pointer; height: 42px; margin-bottom: 2px; }
.start-item:hover { background-color: #2f71cd; color: white; }
.start-item img { width: 24px; height: 24px; margin-right: 8px; }
.start-item-content { display: flex; flex-direction: column; line-height: 1.2; }
.start-item-title { font-weight: bold; font-size: 11px; }
.start-item-desc { font-size: 9px; color: #666; }
.start-item:hover .start-item-desc { color: #ddd; }
.start-footer {
    height: 30px; background: linear-gradient(to bottom, #245edb 0%, #1543b5 100%);
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: 10px; margin-top: auto;
}
.start-btn { color: white; font-size: 11px; cursor: pointer; display: flex; align-items: center; }
.start-btn img { width: 16px; height: 16px; margin-right: 5px; }
.start-btn:hover { opacity: 0.8; }

/* --- NOTEPAD COMPONENT --- */
.notepad-wrapper { display: flex; flex-direction: column; background: #ece9d8; height: 100%; overflow: hidden; }
.notepad-menubar { height: 19px; background: #ece9d8; border-bottom: 1px solid #ffffff; display: flex; align-items: center; padding: 0 4px; flex-shrink: 0; cursor: default; user-select: none; }
.notepad-menu-item { 
    font-family: 'Tahoma', sans-serif; 
    font-size: 11px; 
    margin-right: 12px; 
    color: #a29f90; /* XP Disabled Text Color */
    cursor: default; 
    user-select: none;
}
.notepad-menu-item:first-letter { text-decoration: underline; }
.notepad-body { flex: 1; display: flex; overflow: hidden; }
.notepad-textarea {
    flex: 1; margin: 0; border: none;
    border-top: 1px solid #7f9db9; border-left: 1px solid #7f9db9; border-right: 1px solid #dcdad5; border-bottom: 1px solid #dcdad5;
    font-family: 'Lucida Console', 'Consolas', monospace; font-size: 14px; resize: none; outline: none; padding: 4px; background: white; color: black; white-space: pre-wrap; overflow-y: auto; border-radius: 0;
}

/* --- INACTIVE WINDOW STATE --- */
.os-window:not(.active) .wt-left,
.os-window:not(.active) .wt-right,
.os-window:not(.active) .wt-mid::before,
.os-window:not(.active) .wm-left,
.os-window:not(.active) .wm-right,
.os-window:not(.active) .window-bottom,
.os-window:not(.active) .window-controls {
    filter: contrast(0.6) brightness(1.4) grayscale(0.2);
    cursor: default;
}

.os-window:not(.active) .window-title {
    color: #d8e4f8; 
    text-shadow: none !important; 
}

.os-window:not(.active) .wm-content {
    filter: none;
    opacity: 1; 
}

/* --- CONTEXT MENU (XP Style) --- */
.os-context-menu {
    position: fixed;
    z-index: 99999;
    min-width: 150px;
    background-color: #ffffff;
    border: 1px solid #aca899;
    padding: 2px;
    box-shadow: 4px 4px 3px rgba(0,0,0,0.2); /* XP Drop Shadow */
    font-family: 'Tahoma', sans-serif;
    font-size: 11px;
    cursor: default;
    display: flex; flex-direction: column;
}

.os-context-item {
    display: flex; align-items: center;
    padding: 3px 2px 3px 0;
    border: 1px solid transparent;
}

/* [UPDATED] Label takes available space to push arrow right */
.os-context-item span {
    flex: 1;
    white-space: nowrap;
}

.os-context-item:hover {
    background-color: #316ac5;
    border-color: #316ac5;
    color: white;
}

.os-context-item.disabled {
    color: #b9b5a8; /* [UPDATED] Accurate XP Disabled Color */
}
.os-context-item.disabled:hover {
    background: none; border-color: transparent; color: #b9b5a8;
}

.os-context-icon {
    width: 22px; margin-right: 4px;
    display: flex; justify-content: center; align-items: center;
    flex-shrink: 0;
}
.os-context-icon img { width: 16px; height: 16px; }

/* [UPDATED] Right Arrow for Submenus */
.os-context-arrow {
    width: 0; 
    height: 0; 
    border-top: 3.5px solid transparent;
    border-bottom: 3.5px solid transparent;
    border-left: 3.5px solid black;
    margin-right: 4px;
    margin-left: 10px;
    flex-shrink: 0;
}
.os-context-item.disabled .os-context-arrow {
    border-left-color: #b9b5a8;
}
.os-context-item:hover:not(.disabled) .os-context-arrow {
    border-left-color: white;
}

.os-context-separator {
    height: 1px;
    background-color: #b9b5a8; /* [UPDATED] Accurate XP Separator Color */
    margin: 3px 2px;
}