
/* Mac OS 9 "Platinum" Design System.
            Loaded AFTER Bootstrap so Mac element-level rules (body bg/font,
            scrollbar, etc.) override Bootstrap's Reboot. .mac-* classes never
            collide with Bootstrap's class namespace, so the two coexist:
            use .mac-* for the Mac OS 9 chrome and Bootstrap classes (.btn,
            .modal, .row, etc.) elsewhere. */
:root {
    /* Platinum palette */
    --mac-white: #FFFFFF;
    --mac-platinum: #DDDDDD;
    --mac-platinum-light: #ECECEC;
    --mac-silver: #BBBBBB;
    --mac-gray: #999999;
    --mac-dark-gray: #666666;
    --mac-charcoal: #333333;
    --mac-black: #000000;

    /* Selection blue (classic OS 9 highlight) */
    --mac-highlight: #3366CC;
    --mac-highlight-light: #6699FF;
    --mac-highlight-dark: #2255AA;

    /* Status */
    --mac-success: #339933;
    --mac-danger: #CC3333;
    --mac-warning: #FF9900;

    /* Chrome gradients */
    --mac-titlebar: linear-gradient(180deg, #F8F8F8 0%, #C8C8C8 100%);
    --mac-titlebar-inactive: linear-gradient(180deg, #EEEEEE 0%, #D6D6D6 100%);
    --mac-button: linear-gradient(180deg, #FDFDFD 0%, #E2E2E2 45%, #BFBFBF 100%);
    --mac-button-hover: linear-gradient(180deg, #FFFFFF 0%, #ECECEC 45%, #CCCCCC 100%);
    --mac-button-pressed: linear-gradient(180deg, #888888 0%, #B0B0B0 55%, #C8C8C8 100%);
    --mac-panel: linear-gradient(180deg, #ECECEC 0%, #D5D5D5 100%);

    /* Explicit 3D bevels (Platinum used a 2px bevel: outer light/dark + inner light/dark) */
    --bevel-outset: inset 1px 1px 0 #FFFFFF, inset -1px -1px 0 #888888,
                    inset 2px 2px 0 #EEEEEE, inset -2px -2px 0 #AAAAAA;
    --bevel-inset:  inset 1px 1px 0 #888888, inset -1px -1px 0 #FFFFFF,
                    inset 2px 2px 0 #AAAAAA, inset -2px -2px 0 #EEEEEE;
    --bevel-outset-thin: inset 1px 1px 0 #FFFFFF, inset -1px -1px 0 #888888;
    --bevel-inset-thin:  inset 1px 1px 0 #888888, inset -1px -1px 0 #FFFFFF;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Charcoal", "Geneva", "Lucida Grande", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 12px;
    /* Classic OS 9 desktop teal */
    background-color: #6B9BAD;
    background-image:
        radial-gradient(ellipse at top, #88B5C4 0%, transparent 60%),
        radial-gradient(ellipse at bottom, #4F7E8E 0%, transparent 70%);
    background-attachment: fixed;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    color: var(--mac-black);
}

/* Window */
.mac-window {
    background: var(--mac-platinum);
    border: 1px solid var(--mac-black);
    border-radius: 6px 6px 0 0;
    box-shadow:
        inset 1px 1px 0 #FFFFFF,
        inset -1px -1px 0 #888888,
        4px 4px 12px rgba(0, 0, 0, 0.45);
    margin: 0 auto;
    max-width: 1200px;
    overflow: hidden;
    padding: 0 !important;
}

/* Title Bar */
.mac-title-bar {
    background: var(--mac-titlebar);
    border-bottom: 1px solid var(--mac-dark-gray);
    box-shadow: inset 0 1px 0 #FFFFFF;
    padding: 3px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: default;
    user-select: none;
    border-radius: 5px 5px 0 0;
}

.mac-title-bar::before,
.mac-title-bar::after {
    content: '';
    flex: 1;
    height: 11px;
    background-image: repeating-linear-gradient(
        0deg,
        #6E6E6E 0px, #6E6E6E 1px,
        transparent 1px, transparent 3px
    );
    opacity: 0.85;
}

.mac-title {
    font-weight: bold;
    font-size: 12px;
    padding: 1px 10px;
    white-space: nowrap;
    background: var(--mac-titlebar);
    /* gives the title a "card" sitting on top of the pinstripes */
    box-shadow: 0 0 0 2px var(--mac-platinum-light);
}

/* Window Buttons (close/min/zoom) */
.mac-window-buttons {
    display: flex;
    gap: 5px;
    padding-left: 2px;
}

.mac-window-btn {
    width: 13px;
    height: 13px;
    border-radius: 2px;
    border: 1px solid var(--mac-black);
    background: var(--mac-button);
    box-shadow: var(--bevel-outset-thin);
    cursor: pointer;
    position: relative;
}

.mac-window-btn:hover {
    background: var(--mac-button-hover);
}

.mac-window-btn:active {
    background: var(--mac-button-pressed);
    box-shadow: var(--bevel-inset-thin);
}

.mac-close-btn::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: #000;
    clip-path: polygon(
        20% 0, 50% 30%, 80% 0, 100% 20%, 70% 50%, 100% 80%,
        80% 100%, 50% 70%, 20% 100%, 0 80%, 30% 50%, 0 20%
    );
    opacity: 0;
}

.mac-window-btn:hover.mac-close-btn::after {
    opacity: 1;
}

/* Window Content */
.mac-content {
    padding: 14px;
    background: var(--mac-white);
    box-shadow: var(--bevel-inset);
    margin: 8px;
    border-radius: 1px;
}

/* Buttons */
.mac-btn {
    font-family: inherit;
    font-size: 12px;
    padding: 3px 14px;
    background: var(--mac-button);
    border: 1px solid var(--mac-black);
    border-radius: 10px;
    color: var(--mac-black);
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--bevel-outset-thin);
    transition: background 0.08s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.4;
    min-height: 20px;
}

.mac-btn:hover {
    background: var(--mac-button-hover);
}

.mac-btn:active {
    background: var(--mac-button-pressed);
    box-shadow: var(--bevel-inset-thin);
    color: var(--mac-black);
}

.mac-btn:focus {
    outline: 2px solid var(--mac-highlight);
    outline-offset: 1px;
}

.mac-btn-primary {
    background: linear-gradient(180deg, #6699FF 0%, #3366CC 50%, #224499 100%);
    color: var(--mac-white);
    border-color: #112266;
    box-shadow:
        inset 1px 1px 0 #99BBFF,
        inset -1px -1px 0 #1A4488;
}

.mac-btn-primary:hover {
    background: linear-gradient(180deg, #88AAFF 0%, #4477DD 50%, #2255AA 100%);
}

.mac-btn-primary:active {
    background: linear-gradient(180deg, #224499 0%, #3366CC 100%);
    box-shadow: inset 1px 1px 0 #1A4488, inset -1px -1px 0 #99BBFF;
    color: var(--mac-white);
}

.mac-btn-danger {
    background: linear-gradient(180deg, #EE6666 0%, #CC3333 50%, #992222 100%);
    color: var(--mac-white);
    border-color: #661111;
    box-shadow: inset 1px 1px 0 #FFAAAA, inset -1px -1px 0 #881111;
}

.mac-btn-danger:hover {
    background: linear-gradient(180deg, #FF7777 0%, #DD4444 50%, #AA2222 100%);
}

.mac-btn-success {
    background: linear-gradient(180deg, #66CC66 0%, #339933 50%, #226622 100%);
    color: var(--mac-white);
    border-color: #114411;
    box-shadow: inset 1px 1px 0 #99DD99, inset -1px -1px 0 #226622;
}

.mac-btn-sm {
    padding: 1px 8px;
    font-size: 10px;
    min-height: 16px;
    border-radius: 8px;
}

/* Form Elements */
.mac-input, .mac-textarea, .mac-select {
    font-family: inherit;
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid var(--mac-dark-gray);
    background: var(--mac-white);
    border-radius: 0;
    outline: none;
    box-shadow: var(--bevel-inset-thin);
    color: var(--mac-black);
}

.mac-input:focus, .mac-textarea:focus, .mac-select:focus {
    border-color: var(--mac-highlight);
    box-shadow: var(--bevel-inset-thin), 0 0 0 2px var(--mac-highlight-light);
}

.mac-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: "Monaco", "Menlo", "Courier New", monospace;
}

.mac-label {
    display: block;
    margin-bottom: 3px;
    font-weight: bold;
    color: var(--mac-charcoal);
}

.mac-form-group {
    margin-bottom: 12px;
}

/* Table */
.mac-table-container {
    background: var(--mac-white);
    box-shadow: var(--bevel-inset);
    overflow: auto;
    max-height: 400px;
    padding: 2px;
}

.mac-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    background: var(--mac-white);
}

.mac-table th {
    background: var(--mac-panel);
    border-bottom: 1px solid var(--mac-dark-gray);
    box-shadow: inset 0 1px 0 #FFFFFF, inset 0 -1px 0 #AAAAAA;
    padding: 5px 8px;
    text-align: left;
    font-weight: bold;
    color: var(--mac-charcoal);
    position: sticky;
    top: 0;
    z-index: 1;
}

.mac-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--mac-platinum);
}

.mac-table tr:hover {
    background: #E8EEFF;
}

.mac-table tr.selected,
.mac-table tr:active {
    background: var(--mac-highlight);
    color: var(--mac-white);
}

/* Panel (gray box with platinum bevel) */
.mac-panel {
    background: var(--mac-panel);
    box-shadow: var(--bevel-outset);
    padding: 12px;
    margin-bottom: 14px;
    border-radius: 1px;
}

.mac-panel-title {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--mac-gray);
    box-shadow: 0 1px 0 #FFFFFF;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mac-charcoal);
}

.mac-panel-title i {
    color: var(--mac-highlight);
}

/* Toolbar */
.mac-toolbar {
    background: var(--mac-panel);
    box-shadow: var(--bevel-outset);
    padding: 6px 8px;
    margin-bottom: 14px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    border-radius: 1px;
}

.mac-toolbar-divider {
    width: 2px;
    height: 22px;
    background: var(--mac-gray);
    box-shadow: 1px 0 0 #FFFFFF;
    margin: 0 6px;
}

/* Alerts */
.mac-alert {
    background: var(--mac-panel);
    box-shadow: var(--bevel-outset);
    padding: 10px 14px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 1px;
}

.mac-alert-icon {
    font-size: 22px;
}

.mac-alert-success { border-left: 4px solid var(--mac-success); }
.mac-alert-success .mac-alert-icon { color: var(--mac-success); }
.mac-alert-danger  { border-left: 4px solid var(--mac-danger); }
.mac-alert-danger  .mac-alert-icon { color: var(--mac-danger); }
.mac-alert-warning { border-left: 4px solid var(--mac-warning); }
.mac-alert-warning .mac-alert-icon { color: var(--mac-warning); }

/* Menu Bar */
.mac-menu {
    background: var(--mac-panel);
    box-shadow:
        inset 0 1px 0 #FFFFFF,
        inset 0 -1px 0 #888888,
        0 1px 0 #FFFFFF;
    border-bottom: 1px solid var(--mac-dark-gray);
    padding: 3px 6px;
    display: flex;
    gap: 2px;
}

.mac-menu-item {
    padding: 3px 12px;
    cursor: pointer;
    border-radius: 2px;
    text-decoration: none;
    color: var(--mac-black);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
}

.mac-menu-item:hover,
.mac-menu-item.active {
    background: var(--mac-highlight);
    color: var(--mac-white);
}

/* Modal */
.mac-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.mac-modal {
    background: var(--mac-platinum);
    border: 1px solid var(--mac-black);
    border-radius: 6px 6px 0 0;
    min-width: 400px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow:
        inset 1px 1px 0 #FFFFFF,
        inset -1px -1px 0 #888888,
        6px 6px 18px rgba(0, 0, 0, 0.5);
}

.mac-modal-content {
    padding: 14px;
    background: var(--mac-white);
    box-shadow: var(--bevel-inset);
    margin: 8px;
    max-height: calc(90vh - 100px);
    overflow-y: auto;
}

.mac-modal-footer {
    padding: 6px 14px 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Badge */
.mac-badge {
    display: inline-block;
    padding: 1px 8px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 9px;
    background: var(--mac-gray);
    color: var(--mac-white);
    box-shadow: inset 1px 1px 0 rgba(255,255,255,0.4), inset -1px -1px 0 rgba(0,0,0,0.25);
}

.mac-badge-primary { background: var(--mac-highlight); }
.mac-badge-success { background: var(--mac-success); }

/* Layout helpers */
.mac-grid       { display: grid; gap: 14px; }
.mac-grid-2     { grid-template-columns: repeat(2, 1fr); }
.mac-grid-3     { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 768px) {
    .mac-grid-2, .mac-grid-3 { grid-template-columns: 1fr; }
}

.mac-flex         { display: flex; }
.mac-flex-between { justify-content: space-between; }
.mac-flex-center  { align-items: center; }
.mac-gap-8        { gap: 8px; }
.mac-gap-16       { gap: 16px; }

/* Text utilities */
.mac-text-muted {
    color: var(--mac-dark-gray);
}

.mac-text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mac-text-code {
    font-family: "Monaco", "Menlo", "Courier New", monospace;
    font-size: 11px;
    background: var(--mac-platinum-light);
    box-shadow: var(--bevel-inset-thin);
    padding: 1px 5px;
    border-radius: 2px;
}

/* Loader */
.mac-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--mac-silver);
    border-top-color: var(--mac-highlight);
    border-radius: 50%;
    animation: mac-spin 1s linear infinite;
}

@keyframes mac-spin {
    to { transform: rotate(360deg); }
}

/* HTMX indicator */
.htmx-indicator              { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

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

::-webkit-scrollbar-track {
    background: var(--mac-platinum-light);
    box-shadow: var(--bevel-inset-thin);
}

::-webkit-scrollbar-thumb {
    background: var(--mac-button);
    box-shadow: var(--bevel-outset-thin);
    border: 1px solid var(--mac-dark-gray);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mac-button-hover);
}

::-webkit-scrollbar-thumb:active {
    background: var(--mac-button-pressed);
    box-shadow: var(--bevel-inset-thin);
}

::-webkit-scrollbar-corner {
    background: var(--mac-platinum-light);
    box-shadow: var(--bevel-inset-thin);
}

/* Actions column */
.mac-actions {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}

/* Empty state */
.mac-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--mac-dark-gray);
}

.mac-empty i {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
    color: var(--mac-gray);
}

/* Version list */
.mac-version-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mac-version-item {
    padding: 6px 10px;
    border-bottom: 1px solid var(--mac-platinum);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mac-version-item:hover {
    background: #E8EEFF;
}

.mac-version-info { flex: 1; }

/* Code display */
.mac-code {
    font-family: "Monaco", "Menlo", "Courier New", monospace;
    font-size: 11px;
    background: #1E1E1E;
    color: #D4D4D4;
    padding: 10px;
    box-shadow: var(--bevel-inset);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Tabs */
.mac-tabs {
    display: flex;
    background: var(--mac-panel);
    box-shadow:
        inset 0 1px 0 #FFFFFF,
        inset 0 -1px 0 #888888;
    border-bottom: 1px solid var(--mac-dark-gray);
    padding: 4px 6px 0;
    gap: 2px;
}

.mac-tab {
    padding: 5px 14px;
    cursor: pointer;
    background: var(--mac-button);
    color: var(--mac-charcoal);
    border: 1px solid var(--mac-dark-gray);
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    box-shadow: inset 1px 1px 0 #FFFFFF;
    margin-bottom: -1px;
    font-weight: bold;
}

.mac-tab:hover {
    background: var(--mac-button-hover);
}

.mac-tab.active {
    background: var(--mac-white);
    color: var(--mac-black);
    box-shadow: inset 1px 1px 0 #FFFFFF;
}

.mac-tab-content {
    display: none;
    padding: 14px;
    background: var(--mac-white);
    box-shadow: var(--bevel-inset);
}

.mac-tab-content.active { display: block; }

/* Full width inputs */
.mac-input-full { width: 100%; }

/* Validation */
.mac-input.is-invalid {
    border-color: var(--mac-danger);
    box-shadow: var(--bevel-inset-thin), 0 0 0 1px var(--mac-danger);
}

.mac-validation-error {
    color: var(--mac-danger);
    font-size: 10px;
    margin-top: 3px;
    font-weight: bold;
}

/* Hidden */
.mac-hidden { display: none !important; }
