/* 
 * Mac OS 9 Platinum CSS
 * Base styles for the Kaleidoscope desktop replica
 */

@font-face {
    font-family: 'Charcoal';
    src: url('/fonts/Charcoal.ttf') format('truetype');
}

/* CSS Variables - will be overridden by scheme */
:root {
    /* Window colors */
    --window-frame: #888888;
    --window-background: #dddddd;
    --window-title-active: #000000;
    --window-title-inactive: #888888;
    --window-highlight: #ffffff;
    --window-shadow: #666666;
    
    /* Window frame dimensions (updated per scheme) */
    --window-title-height: 22px;
    --window-border-left: 5px;
    --window-border-right: 5px;
    --window-border-bottom: 5px;
    
    /* Menu colors */
    --menu-bar-bg: #dddddd;
    --menu-text: #000000;
    --menu-highlight-bg: #3366cc;
    --menu-highlight-text: #ffffff;
    --menu-divider: #888888;
    
    /* Button colors */
    --button-face: #dddddd;
    --button-highlight: #ffffff;
    --button-shadow: #888888;
    --button-text: #000000;
    
    /* Desktop */
    --desktop-bg: #666699;
    
    /* Text */
    --text-color: #000000;
    --text-disabled: #888888;
    
    /* Scrollbar */
    --scrollbar-track: #cccccc;
    --scrollbar-thumb: #dddddd;
    --scrollbar-arrow: #000000;
    
    /* Finder content area */
    --finder-content-bg: #eeeeee;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base styles */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Charcoal', Geneva, Arial, sans-serif;
    font-size: 12px;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
}

/* Desktop */
#desktop {
    width: 100%;
    height: 100%;
    background: var(--desktop-bg);
    position: relative;
    user-select: none;
}

/* Menu Bar */
#menu-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--menu-bar-bg);
    border-bottom: 1px solid var(--window-shadow);
    display: flex;
    align-items: center;
    z-index: 10000;
}

.menu-bar-item {
    padding: 2px 10px;
    cursor: default;
    position: relative;
}

.menu-bar-item:hover,
.menu-bar-item.active {
    background: var(--menu-highlight-bg);
    color: var(--menu-highlight-text);
}

.menu-bar-item.apple-menu {
    font-size: 14px;
    padding: 2px 8px;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--menu-bar-bg);
    border: 1px solid var(--window-frame);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    min-width: 150px;
    display: none;
    z-index: 10001;
}

.dropdown-menu.visible {
    display: block;
}

.menu-item {
    padding: 4px 20px 4px 25px;
    cursor: default;
    white-space: nowrap;
    position: relative;
}

.menu-item:hover {
    background: var(--menu-highlight-bg);
    color: var(--menu-highlight-text);
}

.menu-item.disabled {
    color: var(--text-disabled);
}

.menu-item.disabled:hover {
    background: transparent;
    color: var(--text-disabled);
}

.menu-item .shortcut {
    float: right;
    margin-left: 20px;
    color: inherit;
}

.menu-divider {
    height: 1px;
    background: var(--menu-divider);
    margin: 4px 0;
}

.menu-item.has-submenu::after {
    content: '▶';
    position: absolute;
    right: 8px;
    font-size: 8px;
}

/* Windows Container */
#windows-container {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ============================================
   THEMED WINDOW STYLES
   ============================================ */

.window {
    position: absolute;
    min-width: 150px;
    min-height: 80px;
}

/* Window Frame - rendered by server */
.window-frame {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    image-rendering: pixelated;
    z-index: 0;
}

.window-frame img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

/* Window Title Bar - clickable overlay for dragging */
.window-title-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--window-title-height, 22px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    z-index: 1;
    background: transparent;
}

/* Window Title Text */
.window-title {
    font-size: 12px;
    font-weight: bold;
    color: var(--window-title-active);
    text-shadow: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 120px);
    text-align: center;
    pointer-events: none;
}

.window.inactive .window-title {
    color: var(--window-title-inactive);
}

/* Window Controls - positioned over the frame */
.window-controls {
    position: absolute;
    display: flex;
    gap: 4px;
    align-items: center;
    z-index: 2;
}

.window-controls.left {
    left: 8px;
    top: 4px;
}

.window-controls.right {
    right: 8px;
    top: 4px;
}

/* Window Control Boxes - clickable, transparent overlays */
.window-control {
    width: 14px;
    height: 14px;
    cursor: default;
    background: transparent;
    border: none;
}

.window-control:hover {
    background: rgba(255,255,255,0.3);
}

.window-control:active {
    background: rgba(0,0,0,0.2);
}

/* Content Area */
.window-content {
    position: absolute;
    top: var(--window-title-height, 22px);
    left: var(--window-border-left, 5px);
    right: var(--window-border-right, 5px);
    bottom: var(--window-border-bottom, 5px);
    background: var(--finder-content-bg, #eeeeee);
    overflow: auto;
    z-index: 1;
}

/* Grow Box */
.window-grow-box {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: nwse-resize;
    z-index: 3;
    background: transparent;
}

/* ============================================
   FALLBACK WINDOW STYLES (when no scheme)
   ============================================ */

.window.fallback-style {
    background: var(--window-background);
    border: 1px solid var(--window-frame);
    box-shadow: 1px 1px 0 var(--window-shadow);
}

.window.fallback-style .window-title-bar {
    height: 20px;
    background: linear-gradient(to bottom, #dddddd 0%, #bbbbbb 50%, #999999 51%, #cccccc 100%);
    border-bottom: 1px solid var(--window-shadow);
    padding: 0 4px;
}

.window.fallback-style.inactive .window-title-bar {
    background: linear-gradient(to bottom, #dddddd, #bbbbbb);
}

.window.fallback-style .window-content {
    top: 20px;
    left: 1px;
    right: 1px;
    bottom: 1px;
}

.window.fallback-style .window-control {
    width: 13px;
    height: 11px;
    border: 1px solid var(--window-frame);
    background: var(--window-background);
}

.window.fallback-style .window-grow-box {
    background: linear-gradient(135deg, transparent 60%, var(--window-shadow) 60%);
}

/* Desktop Icons */
#desktop-icons {
    position: absolute;
    top: 30px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px;
    cursor: default;
    width: 75px;
}

.desktop-icon:hover {
    background: rgba(255,255,255,0.2);
}

.desktop-icon.selected {
    background: var(--menu-highlight-bg);
}

.desktop-icon.selected .icon-label {
    color: var(--menu-highlight-text);
}

.desktop-icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.icon-label {
    margin-top: 4px;
    text-align: center;
    font-size: 10px;
    color: #ffffff;
    text-shadow: 1px 1px 0 #000000;
    word-break: break-word;
}

/* Finder specific styles */
.finder-window .window-content {
    display: flex;
    flex-direction: column;
}

.finder-toolbar {
    height: 32px;
    background: var(--window-background);
    border-bottom: 1px solid var(--window-shadow);
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 8px;
    flex-shrink: 0;
}

.finder-toolbar button {
    font-family: inherit;
    font-size: 11px;
    padding: 2px 8px;
    background: var(--button-face);
    border: 1px solid var(--window-frame);
    border-top-color: var(--button-highlight);
    border-left-color: var(--button-highlight);
    cursor: default;
}

.finder-toolbar button:active {
    border-top-color: var(--button-shadow);
    border-left-color: var(--button-shadow);
    border-bottom-color: var(--button-highlight);
    border-right-color: var(--button-highlight);
}

.finder-path {
    flex: 1;
    font-size: 11px;
    color: var(--text-color);
}

.finder-files {
    flex: 1;
    overflow: auto;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    background: #ffffff;
}

.file-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px;
    width: 75px;
    cursor: default;
}

.file-icon:hover {
    background: rgba(0,0,0,0.05);
}

.file-icon.selected {
    background: var(--menu-highlight-bg);
}

.file-icon.selected .file-label {
    color: var(--menu-highlight-text);
}

.file-icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.file-label {
    margin-top: 4px;
    text-align: center;
    font-size: 10px;
    word-break: break-word;
    max-width: 70px;
}

/* Scrollbars */
.window-content::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

.window-content::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border: 1px solid var(--window-frame);
}

.window-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 1px solid var(--window-frame);
}

.window-content::-webkit-scrollbar-button {
    background: var(--scrollbar-thumb);
    border: 1px solid var(--window-frame);
    height: 16px;
    width: 16px;
}

/* Push Button */
.push-button {
    font-family: 'Charcoal', Geneva, Arial, sans-serif;
    font-size: 12px;
    padding: 4px 16px;
    background: var(--button-face);
    border: 2px solid;
    border-top-color: var(--button-highlight);
    border-left-color: var(--button-highlight);
    border-bottom-color: var(--button-shadow);
    border-right-color: var(--button-shadow);
    cursor: default;
    outline: none;
}

.push-button:active {
    border-top-color: var(--button-shadow);
    border-left-color: var(--button-shadow);
    border-bottom-color: var(--button-highlight);
    border-right-color: var(--button-highlight);
}

.push-button.default {
    border: 3px solid #000000;
    border-radius: 4px;
}

.push-button:disabled {
    color: var(--text-disabled);
}

/* Checkbox */
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: default;
}

.checkbox-box {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 1px solid var(--window-frame);
}

.checkbox.checked .checkbox-box::after {
    content: '✓';
    display: block;
    text-align: center;
    line-height: 12px;
    font-size: 10px;
}

/* Radio Button */
.radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: default;
}

.radio-circle {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 1px solid var(--window-frame);
    border-radius: 50%;
}

.radio.checked .radio-circle::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #000000;
    border-radius: 50%;
    margin: 2px;
}

/* Text Input */
.text-input {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    padding: 2px 4px;
    background: #ffffff;
    border: 2px solid;
    border-top-color: var(--button-shadow);
    border-left-color: var(--button-shadow);
    border-bottom-color: var(--button-highlight);
    border-right-color: var(--button-highlight);
    outline: none;
}

/* Text Editor */
.text-editor {
    width: 100%;
    height: 100%;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    padding: 4px;
    border: none;
    resize: none;
    outline: none;
    background: #ffffff;
}

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

.dragging {
    opacity: 0.9;
}

/* Selection highlight */
::selection {
    background: var(--menu-highlight-bg);
    color: var(--menu-highlight-text);
}
