/* BeOS R5 "Be" Design System — standalone theme.

   Self-contained: this replaces macos-9.css entirely (it does NOT depend on it
   being loaded). It defines the full set of .mac-* chrome classes used across
   the app — windows, the signature yellow title tab, buttons, forms, tables,
   menus, modals, tabs, scrollbars — in the BeOS visual language:
     - the famous BeOS UI gray rgb(216,216,216),
     - rectangular windows with a yellow tab riding the top edge,
     - near-flat controls with thin single-pixel bevels,
     - Swiss/Helvetica type on the dusty-blue Be desktop.

   Loaded after Bootstrap so element-level rules override Reboot. The .mac-*
   class names are kept (the markup references them); only their look changes. */
:root {
    /* The famous BeOS UI gray is rgb(216,216,216). */
    --mac-white: #FFFFFF;
    --mac-platinum: #D8D8D8;
    --mac-platinum-light: #ECECEC;
    --mac-silver: #C6C6C6;
    --mac-gray: #9A9A9A;
    --mac-dark-gray: #6B6B6B;
    --mac-charcoal: #2B2B2B;
    --mac-black: #000000;

    /* BeOS list/selection navy. */
    --mac-highlight: #2F5DAB;
    --mac-highlight-light: #6F93D6;
    --mac-highlight-dark: #234783;

    --mac-success: #2E8B2E;
    --mac-danger: #C23030;
    --mac-warning: #E0A000;

    /* The signature Be yellow window tab. */
    --beos-tab: linear-gradient(180deg, #FFD86B 0%, #F6BE26 100%);
    --beos-tab-inactive: linear-gradient(180deg, #E6E6E6 0%, #CFCFCF 100%);

    /* BeOS controls are near-flat with a thin bevel — not glossy. */
    --mac-titlebar: var(--beos-tab);
    --mac-titlebar-inactive: var(--beos-tab-inactive);
    --mac-button: linear-gradient(180deg, #F4F4F4 0%, #D4D4D4 100%);
    --mac-button-hover: linear-gradient(180deg, #FAFAFA 0%, #DEDEDE 100%);
    --mac-button-pressed: linear-gradient(180deg, #BEBEBE 0%, #D2D2D2 100%);
    --mac-panel: linear-gradient(180deg, #E2E2E2 0%, #D2D2D2 100%);

    /* Single-pixel BeOS bevels: light top-left, dark bottom-right. */
    --bevel-outset:      inset 1px 1px 0 #FFFFFF, inset -1px -1px 0 #808080;
    --bevel-inset:       inset 1px 1px 0 #808080, inset -1px -1px 0 #FFFFFF;
    --bevel-outset-thin: inset 1px 1px 0 #FFFFFF, inset -1px -1px 0 #808080;
    --bevel-inset-thin:  inset 1px 1px 0 #808080, inset -1px -1px 0 #FFFFFF;
}

* {
    box-sizing: border-box;
}

body {
    /* Swiss/Helvetica type, as on BeOS. */
    font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
    font-size: 12px;
    /* Flat dusty-blue workspace, the BeOS default desktop color. */
    background-color: #51688A;
    background-image: linear-gradient(180deg, #5B7196 0%, #475D7E 100%);
    background-attachment: fixed;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    color: var(--mac-black);
}

/* Window — rectangular, with the yellow tab riding the top edge. */
.mac-window {
    background: var(--mac-platinum);
    border: 1px solid #404040;
    border-radius: 0;
    box-shadow:
        inset 1px 1px 0 #FFFFFF,
        inset -1px -1px 0 #808080,
        3px 3px 9px rgba(0, 0, 0, 0.40);
    margin: 0 auto;
    max-width: 1200px;
    overflow: hidden;
    padding: 0 !important;
}

/* Title bar = the window's top edge; the yellow tab sits at the left. */
.mac-title-bar {
    background: var(--mac-platinum);
    border-bottom: 1px solid #808080;
    box-shadow: inset 0 1px 0 #FFFFFF;
    padding: 2px 4px 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    cursor: default;
    user-select: none;
    border-radius: 0;
}

/* No Platinum pinstripes; the right side is empty window edge. */
.mac-title-bar::after {
    content: '';
    flex: 1;
    height: 0;
}

/* The Be yellow tab. */
.mac-title {
    background: var(--beos-tab);
    color: #000000;
    font-weight: bold;
    font-size: 12px;
    padding: 3px 14px;
    white-space: nowrap;
    border: 1px solid #404040;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.6);
}

.mac-title i {
    color: #7A5A00;
}

/* Window buttons (close box) — a small square at the left of the tab. */
.mac-window-buttons {
    display: flex;
    gap: 5px;
    padding-left: 2px;
    align-self: center;
}

.mac-window-btn {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #404040;
    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 — rounded rectangles, near-flat. */
.mac-btn {
    font-family: inherit;
    font-size: 12px;
    padding: 3px 14px;
    background: var(--mac-button);
    border: 1px solid #555555;
    border-radius: 4px;
    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;
}

/* Default/primary button carries the BeOS focus-blue ring. */
.mac-btn-primary {
    background: linear-gradient(180deg, #6F93D6 0%, #2F5DAB 100%);
    color: var(--mac-white);
    border-color: #234783;
    box-shadow:
        inset 1px 1px 0 #A9C2EC,
        inset -1px -1px 0 #1E3D6E,
        0 0 0 1px #2F5DAB;
}

.mac-btn-primary:hover {
    background: linear-gradient(180deg, #85A6E0 0%, #3E6CBA 100%);
}

.mac-btn-primary:active {
    background: linear-gradient(180deg, #234783 0%, #2F5DAB 100%);
    box-shadow: inset 1px 1px 0 #1E3D6E, inset -1px -1px 0 #A9C2EC;
    color: var(--mac-white);
}

.mac-btn-danger {
    background: linear-gradient(180deg, #DB5C5C 0%, #C23030 100%);
    color: var(--mac-white);
    border-color: #8C1F1F;
    box-shadow: inset 1px 1px 0 #F0A8A8, inset -1px -1px 0 #7A1A1A;
}

.mac-btn-danger:hover {
    background: linear-gradient(180deg, #E47070 0%, #D04040 100%);
}

.mac-btn-success {
    background: linear-gradient(180deg, #4FB04F 0%, #2E8B2E 100%);
    color: var(--mac-white);
    border-color: #1F5F1F;
    box-shadow: inset 1px 1px 0 #A6DBA6, inset -1px -1px 0 #1F5F1F;
}

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

/* Form elements — square fields. */
.mac-input, .mac-textarea, .mac-select {
    font-family: inherit;
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid #808080;
    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-silver);
}

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

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

/* Panel (gray box with 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: flat gray, regular weight, blue highlight on hover. */
.mac-menu {
    background: var(--mac-panel);
    box-shadow:
        inset 0 1px 0 #FFFFFF,
        inset 0 -1px 0 #808080,
        0 1px 0 #FFFFFF;
    border-bottom: 1px solid #808080;
    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: normal;
}

.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 #404040;
    border-radius: 0;
    min-width: 400px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow:
        inset 1px 1px 0 #FFFFFF,
        inset -1px -1px 0 #808080,
        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 — squarer Be pill. */
.mac-badge {
    display: inline-block;
    padding: 1px 8px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 3px;
    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 — flat BeOS-style track and thumb. */
::-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 #808080;
    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-silver);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.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;
}

/* Tab view — BeOS gray/yellow tab language. */
.mac-tabs {
    display: flex;
    background: var(--mac-panel);
    box-shadow:
        inset 0 1px 0 #FFFFFF,
        inset 0 -1px 0 #808080;
    border-bottom: 1px solid #808080;
    padding: 4px 6px 0;
    gap: 2px;
}

.mac-tab {
    padding: 5px 14px;
    cursor: pointer;
    background: var(--mac-button);
    color: var(--mac-charcoal);
    border: 1px solid #808080;
    border-bottom: none;
    border-radius: 4px 4px 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(--beos-tab);
    color: #000000;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.6);
}

.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; }
