/* --------------------------------------------------
 * Theme tokens for app-specific components.
 * Bootstrap 5.3+ handles its own components via data-bs-theme="dark".
 * -------------------------------------------------- */
:root {
    --tm-mono-font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --tm-panel-bg: var(--bs-body-bg);
    --tm-panel-header-bg: var(--bs-tertiary-bg);
    --tm-border: var(--bs-border-color);
    --tm-navbar-height: 56px;
}

/* --------------------------------------------------
 * Typography — unify across all headings
 * -------------------------------------------------- */
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}
h1, h2, h3, h4, h5, h6 {
    font-family: inherit;
    font-weight: 600;
    line-height: 1.25;
}
h1 { font-size: 1.75rem; }   /* ~28px */
h2 { font-size: 1.375rem; }  /* ~22px */
h3 { font-size: 1.125rem; }  /* ~18px */
h4 { font-size: 0.9375rem; } /* ~15px */
h5 { font-size: 0.875rem; }
h6 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* --------------------------------------------------
 * Layout
 * -------------------------------------------------- */
#body-content {
    padding-top: calc(var(--tm-navbar-height) + 16px);
    scroll-padding-top: var(--tm-navbar-height);
}

.taskmaster-brand {
    height: 32px;
    width: auto;
    vertical-align: middle;
}

.thumbnail {
    width: 128px;
    height: 128px;
}

/* --------------------------------------------------
 * Theme toggle button in the navbar
 * -------------------------------------------------- */
.theme-toggle {
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
}
.theme-toggle:hover, .theme-toggle:focus {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}
html[data-bs-theme="dark"] .theme-toggle .icon-light { display: inline; }
html[data-bs-theme="dark"] .theme-toggle .icon-dark { display: none; }
html:not([data-bs-theme="dark"]) .theme-toggle .icon-light { display: none; }
html:not([data-bs-theme="dark"]) .theme-toggle .icon-dark { display: inline; }

/* --------------------------------------------------
 * Tables — tighter density + optional sticky headers
 * -------------------------------------------------- */
.table.table-tight > :not(caption) > * > * {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    vertical-align: middle;
}
.table.table-tight th {
    font-weight: 600;
    white-space: nowrap;
}

.table-sticky thead th {
    position: sticky;
    top: var(--tm-navbar-height);
    z-index: 1;
    background: var(--bs-body-bg);
    box-shadow: inset 0 -1px 0 var(--bs-border-color);
}

/* --------------------------------------------------
 * Monospace identifiers (UUIDs, task_ids, cwd, args, paths)
 * -------------------------------------------------- */
.mono, code, pre {
    font-family: var(--tm-mono-font);
}
.mono {
    font-size: 0.8125rem;
}
.id-cell {
    font-family: var(--tm-mono-font);
    font-size: 0.75rem;
    max-width: 14ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

/* --------------------------------------------------
 * Job status badges — color-coded labels
 * -------------------------------------------------- */
.badge.status,
.badge.status-NEW, .badge.status-PENDING, .badge.status-RECEIVED,
.badge.status-STARTED, .badge.status-RETRY,
.badge.status-SUCCESS,
.badge.status-FAILURE, .badge.status-ABANDONED, .badge.status-REVOKED {
    font-family: var(--tm-mono-font);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.25em 0.5em;
}
.badge.status-NEW, .badge.status-PENDING, .badge.status-RECEIVED { background: var(--bs-secondary-bg); color: var(--bs-secondary-color); border: 1px solid var(--bs-border-color); }
.badge.status-STARTED, .badge.status-RETRY { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); border: 1px solid var(--bs-warning-border-subtle); }
.badge.status-SUCCESS { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); border: 1px solid var(--bs-success-border-subtle); }
.badge.status-FAILURE, .badge.status-ABANDONED, .badge.status-REVOKED { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); border: 1px solid var(--bs-danger-border-subtle); }

/* --------------------------------------------------
 * Filter row above tables (replaces .form-inline)
 * -------------------------------------------------- */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}
.filter-row .filter-group {
    display: flex;
    flex-direction: column;
}
.filter-row label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.125rem;
}
.filter-row .form-control,
.filter-row .form-select {
    width: auto;
    min-width: 8rem;
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* --------------------------------------------------
 * Dashboard cards on home.html
 * -------------------------------------------------- */
.dashboard-card {
    background: var(--tm-panel-bg);
    border: 1px solid var(--tm-border);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}
.dashboard-card .card-header {
    background: var(--tm-panel-header-bg);
    border-bottom: 1px solid var(--tm-border);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
}
.dashboard-card .card-body {
    padding: 0.75rem;
}
.nav-list a {
    display: block;
    padding: 0.25rem 0;
    color: var(--bs-link-color);
    font-weight: 500;
}
.nav-list a:hover {
    text-decoration: none;
    color: var(--bs-link-hover-color);
}
.nav-list .desc {
    color: var(--bs-secondary-color);
    font-weight: normal;
    margin-left: 0.5rem;
    font-size: 0.8125rem;
}

/* --------------------------------------------------
 * Site autocomplete dropdown on home.html
 * -------------------------------------------------- */
.site-autocomplete-wrapper {
    position: relative;
}
#site-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}
#site-autocomplete div {
    padding: 0.375rem 0.75rem;
    cursor: pointer;
}
#site-autocomplete div:hover {
    background: var(--bs-tertiary-bg);
}

/* --------------------------------------------------
 * HTMX: hide loader after first render so it doesn't flash on auto-refresh
 * Containers that have already swapped real content get .htmx-loaded.
 * -------------------------------------------------- */
.htmx-loader-only-first.htmx-loaded > .htmx-loader { display: none; }

/* --------------------------------------------------
 * Misc
 * -------------------------------------------------- */
footer {
    margin-top: 1.5rem;
    color: var(--bs-secondary-color);
}

pre {
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-word;
}
