/**
 * Mac OS 9 Themed Controls CSS
 */

/* ==================== Buttons ==================== */
.themed-button {
    display: inline-block;
    padding: 4px 16px;
    min-width: 60px;
    border: none;
    background: var(--button-bg, #ddd);
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    outline: none;
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
}

.themed-button:hover:not(.disabled) {
    filter: brightness(1.05);
}

.themed-button.default {
    font-weight: bold;
}

.themed-button.disabled {
    opacity: 0.6;
    cursor: default;
}

/* Push button fallback styles */
.push-button {
    display: inline-block;
    padding: 4px 16px;
    min-width: 60px;
    background: linear-gradient(to bottom, #fff 0%, #ddd 100%);
    border: 1px solid #888;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 12px;
    text-align: center;
    cursor: pointer;
}

.push-button:active {
    background: linear-gradient(to bottom, #ccc 0%, #aaa 100%);
}

.push-button.default {
    border: 2px solid #000;
    font-weight: bold;
}

/* ==================== Checkboxes ==================== */
.themed-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 12px;
    user-select: none;
}

.themed-checkbox.disabled {
    opacity: 0.6;
    cursor: default;
}

.checkbox-graphic {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-size: 100% 100%;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.checkbox-label {
    white-space: nowrap;
}

/* Fallback checkbox styles */
.themed-checkbox:not([data-themed]) .checkbox-graphic {
    border: 1px solid #666;
    background: #fff;
}

.themed-checkbox.checked:not([data-themed]) .checkbox-graphic::after {
    content: '✓';
    display: block;
    text-align: center;
    line-height: 10px;
    font-size: 10px;
}

/* ==================== Radio Buttons ==================== */
.themed-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 12px;
    user-select: none;
}

.themed-radio.disabled {
    opacity: 0.6;
    cursor: default;
}

.radio-graphic {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-size: 100% 100%;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.radio-label {
    white-space: nowrap;
}

/* Fallback radio styles */
.themed-radio:not([data-themed]) .radio-graphic {
    border: 1px solid #666;
    border-radius: 50%;
    background: #fff;
}

.themed-radio.checked:not([data-themed]) .radio-graphic::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    margin: 2px;
    background: #000;
    border-radius: 50%;
}

/* ==================== Tabs ==================== */
.themed-tabs {
    display: flex;
    flex-direction: column;
}

.tab-bar {
    display: flex;
    gap: -1px;
}

.tab-button {
    padding: 4px 12px;
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    background: var(--tab-bg, #ccc);
    border: 1px solid #888;
    border-bottom: none;
    position: relative;
    z-index: 1;
}

.tab-button.active {
    background: var(--tab-active-bg, #ddd);
    z-index: 2;
    margin-bottom: -1px;
    padding-bottom: 5px;
}

.tab-pane-container {
    border: 1px solid #888;
    background: var(--tab-pane-bg, #ddd);
    padding: 10px;
    position: relative;
    z-index: 0;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ==================== Progress Bars ==================== */
.themed-progress {
    height: 12px;
    background: var(--progress-frame-bg, #eee);
    border: 1px solid #888;
    border-radius: 2px;
    overflow: hidden;
}

.progress-track {
    height: 100%;
    background: var(--progress-track-bg, #fff);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--progress-fill-bg, linear-gradient(to bottom, #88f 0%, #44a 100%));
    transition: width 0.1s ease-out;
}

/* Indeterminate animation */
.themed-progress.indeterminate .progress-fill {
    width: 30%;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* ==================== Scrollbars ==================== */
.themed-scrollbar {
    background: var(--scrollbar-track-bg, #ccc);
    position: relative;
}

.themed-scrollbar.vertical {
    width: 16px;
    height: 100%;
}

.themed-scrollbar.horizontal {
    width: 100%;
    height: 16px;
}

.scrollbar-track {
    position: absolute;
    background: var(--scrollbar-track-bg, #eee);
}

.themed-scrollbar.vertical .scrollbar-track {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

.themed-scrollbar.horizontal .scrollbar-track {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

.scrollbar-thumb {
    position: absolute;
    background: var(--scrollbar-thumb-bg, linear-gradient(to bottom, #fff 0%, #bbb 100%));
    border: 1px solid #888;
    cursor: pointer;
    min-width: 16px;
    min-height: 16px;
}

.themed-scrollbar.vertical .scrollbar-thumb {
    left: 0;
    right: 0;
}

.themed-scrollbar.horizontal .scrollbar-thumb {
    top: 0;
    bottom: 0;
}

.scrollbar-thumb:hover {
    filter: brightness(1.05);
}

.scrollbar-thumb:active {
    filter: brightness(0.95);
}

/* ==================== Sliders ==================== */
.themed-slider {
    position: relative;
    height: 18px;
}

.slider-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    margin-top: -2px;
    background: var(--slider-track-bg, #aaa);
    border: 1px solid #666;
    border-radius: 2px;
}

.slider-thumb {
    position: absolute;
    width: 11px;
    height: 18px;
    top: 0;
    background: var(--slider-thumb-bg, linear-gradient(to right, #eee 0%, #ccc 100%));
    border: 1px solid #666;
    cursor: pointer;
}

/* ==================== Little Arrows ==================== */
.themed-arrows {
    display: inline-flex;
    flex-direction: column;
}

.themed-arrows.horizontal {
    flex-direction: row;
}

.arrow-button {
    width: 13px;
    height: 11px;
    background: var(--arrow-bg, #ddd);
    border: 1px solid #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
}

.arrow-button:active {
    background: var(--arrow-pressed-bg, #bbb);
}

/* ==================== Disclosure Triangle ==================== */
.disclosure-triangle {
    display: inline-block;
    width: 11px;
    height: 11px;
    cursor: pointer;
    background-size: 100% 100%;
    image-rendering: pixelated;
}

.disclosure-triangle.collapsed {
    transform: rotate(0deg);
}

.disclosure-triangle.expanded {
    transform: rotate(90deg);
}

/* Fallback */
.disclosure-triangle:not([data-themed])::after {
    content: '▶';
    font-size: 9px;
    display: block;
    text-align: center;
    line-height: 11px;
}

/* ==================== Placards ==================== */
.themed-placard {
    display: inline-block;
    padding: 2px 6px;
    background: var(--placard-bg, #ddd);
    border: 1px solid #888;
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 10px;
}

/* ==================== Bevel Buttons ==================== */
.bevel-button {
    display: inline-block;
    padding: 2px 8px;
    min-width: 30px;
    background: var(--bevel-bg, linear-gradient(to bottom, #fff 0%, #ddd 50%, #ccc 100%));
    border: 1px solid #888;
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 11px;
    text-align: center;
    cursor: pointer;
}

.bevel-button:active {
    background: var(--bevel-pressed-bg, linear-gradient(to bottom, #bbb 0%, #999 50%, #888 100%));
}

.bevel-button.small {
    padding: 1px 4px;
    font-size: 9px;
}

.bevel-button.large {
    padding: 4px 12px;
    font-size: 12px;
}

/* ==================== Group Boxes ==================== */
.group-box {
    border: 1px solid #888;
    padding: 12px;
    margin: 8px 0;
    position: relative;
}

.group-box-title {
    position: absolute;
    top: -8px;
    left: 10px;
    background: var(--window-content-bg, #ddd);
    padding: 0 4px;
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 12px;
    font-weight: bold;
}

/* ==================== Popup Menus ==================== */
.popup-menu {
    display: inline-flex;
    align-items: center;
    padding: 2px 20px 2px 8px;
    background: var(--popup-bg, linear-gradient(to bottom, #fff 0%, #ddd 100%));
    border: 1px solid #888;
    font-family: var(--system-font, 'Charcoal', 'Chicago', sans-serif);
    font-size: 12px;
    cursor: pointer;
    position: relative;
    min-width: 80px;
}

.popup-menu::after {
    content: '▼';
    position: absolute;
    right: 6px;
    font-size: 8px;
}

.popup-menu-items {
    display: none;
    position: absolute;
    top: 100%;
    left: -1px;
    right: -1px;
    background: var(--menu-bg, #fff);
    border: 1px solid #000;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    z-index: 1000;
}

.popup-menu.open .popup-menu-items {
    display: block;
}

.popup-menu-item {
    padding: 2px 8px;
    cursor: pointer;
}

.popup-menu-item:hover {
    background: var(--menu-highlight, #316ac5);
    color: #fff;
}
