/* settings.css — the settings page.
 */

/* ===== Default theme picker (Settings > Appearance) ===== */
.theme-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.75rem;
    /* A card keeps its own height when a neighbour's contrast list opens. */
    align-items: start;
}
.theme-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.theme-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.theme-item-actions [data-remove-theme] {
    margin-left: auto;
}
.theme-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem;
    text-align: left;
    color: var(--color-fg);
    background: var(--color-card);
    border: 2px solid var(--color-card-border);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-option:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-hover);
}
.theme-option:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.25rem var(--color-focus-ring);
}
.theme-option.is-selected {
    border-color: var(--color-primary);
}
.theme-option-previews {
    display: flex;
    gap: 0.4rem;
}
.theme-option-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.theme-option-check {
    display: none;
    color: var(--color-accent);
}
.theme-option.is-selected .theme-option-check {
    display: inline-block;
}
/* The swatch carries its own data-theme and data-bs-theme, so the tokens
   below are that theme's, not the page's. */
.theme-swatch {
    flex: 1;
    display: block;
    padding: 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.theme-swatch-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.4rem;
    background: var(--color-card);
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-sm);
}
.theme-swatch-title,
.theme-swatch-line {
    display: block;
    height: 5px;
    border-radius: var(--radius-pill);
}
.theme-swatch-title {
    width: 60%;
    background: var(--color-accent);
}
.theme-swatch-line {
    width: 85%;
    background: var(--color-muted);
    opacity: 0.6;
}
.theme-swatch-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.15rem;
}
.theme-swatch-btn {
    width: 22px;
    height: 9px;
    margin-right: auto;
    background: var(--color-primary);
    border-radius: var(--radius-sm);
}
.theme-swatch-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}
.theme-swatch-dot--veg { background: var(--stage-veg); }
.theme-swatch-dot--flower { background: var(--stage-flower); }

/* ===== Settings page ===== */
.border-start.border-4 { border-left-width: 4px !important; }
.card-table .card-body { padding: 0; }
.card-table .table { margin-bottom: 0; }

/* A long table (breeders) scrolls inside its card and keeps its header. */
.settings-table-scroll {
    max-height: 400px;
    overflow-y: auto;
}
.settings-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--color-table-header);
}

/* Colour pairs an installed theme leaves hard to read. */
.theme-contrast {
    font-size: 0.8rem;
}
.theme-contrast summary {
    color: var(--color-warning-text);
    cursor: pointer;
}
.theme-contrast ul {
    max-height: 14rem;
    overflow-y: auto;
}
.theme-contrast li {
    margin-top: 0.35rem;
    overflow-wrap: anywhere;
}
.theme-contrast-ratio {
    font-weight: 600;
}

/* ===== Theme tokens reference (Settings > Appearance) ===== */
.theme-ref-intro {
    max-width: 70ch;
}
.theme-ref-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}
.theme-ref section {
    scroll-margin-top: 1rem;
}
.theme-ref-table th {
    font-size: 0.8rem;
    white-space: nowrap;
}
.theme-ref-col-preview {
    width: 3.5rem;
}
.theme-ref-name,
.theme-ref-value {
    color: var(--color-fg);
}
.theme-ref-name {
    white-space: nowrap;
    font-weight: 600;
}
.theme-ref-value {
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}
.theme-ref-preview,
.theme-ref-sample {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 1.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1;
}
/* A shadow, a corner or a letter needs a plain tile to be seen on. */
.theme-ref-preview--shadow,
.theme-ref-preview--radius,
.theme-ref-preview--font,
.theme-ref-preview--font-size,
.theme-ref-preview--percent {
    background: var(--color-bg);
    color: var(--color-fg);
}
.theme-ref-preview--shadow {
    border-color: transparent;
}
.theme-ref-preview--font-size {
    height: auto;
    min-height: 1.75rem;
}
.theme-ref-sample {
    font-weight: 600;
}
.theme-ref-ratio {
    font-variant-numeric: tabular-nums;
}
.theme-ref-ratio.is-low {
    color: var(--color-warning-text);
    font-weight: 600;
}

/* Narrow screens: a token is a block, not a row squeezed into columns. */
@media (max-width: 767.98px) {
    .theme-ref-table thead {
        display: none;
    }
    .theme-ref-table tr {
        display: grid;
        grid-template-columns: 3.5rem minmax(0, 1fr);
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--color-card-border);
    }
    .theme-ref-table tbody tr:last-child {
        border-bottom: 0;
    }
    .theme-ref-table td {
        grid-column: 2;
        padding: 0.1rem 0;
        border: 0;
        text-align: left !important;
    }
    .theme-ref-table td:first-child {
        grid-column: 1;
        grid-row: 1 / span 4;
    }
    .theme-ref-name {
        white-space: normal;
    }
}

/* ===== Theme editor (Settings > Appearance) ===== */
.theme-editor {
    max-width: 1500px;
}
.te-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.te-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.te-layout {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 1.25rem;
    align-items: start;
}
/* The preview stays in view while the controls scroll. */
.te-side {
    position: sticky;
    top: 0.75rem;
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
}
.te-group > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.te-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 15rem);
    gap: 0.75rem;
    align-items: center;
    padding: 0.45rem 0;
    border-top: 1px solid var(--color-card-border);
}
.te-row:first-of-type {
    border-top: 0;
}
.te-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.te-label code {
    color: var(--color-muted);
    overflow-wrap: anywhere;
}
.te-label small {
    line-height: 1.3;
}
/* A token the theme sets stands out from one left at Classic's value. */
.te-row.is-set .te-label code {
    color: var(--color-fg);
    font-weight: 600;
}
.te-row:not(.is-set) .te-text {
    color: var(--color-muted);
}
.te-control {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}
.te-control .te-text {
    flex: 1;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.te-control .te-pick {
    flex: none;
    width: 2.4rem;
    height: 1.9rem;
    padding: 0.15rem;
}
.te-control .te-range {
    flex: 1.2;
    min-width: 0;
}
.te-control .te-range + .te-text {
    flex: 0 0 5.5rem;
}
.te-reset {
    flex: none;
}

.te-status {
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--color-card-border);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: var(--color-card);
    font-size: 0.85rem;
}
.te-status:empty {
    display: none;
}
.te-status-title {
    font-weight: 600;
}
.te-status ul {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
    max-height: 9rem;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}
.te-status--ok { border-left-color: var(--color-success); }
.te-status--ok .te-status-title { color: var(--color-success-text); }
.te-status--warn { border-left-color: var(--color-warning); }
.te-status--warn .te-status-title { color: var(--color-warning-text); }
.te-status--bad { border-left-color: var(--color-danger); }
.te-status--bad .te-status-title { color: var(--color-danger-text); }

/* The preview is a theme scope of its own, so it restates what <body>
   takes from the tokens. */
.te-preview {
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg) var(--bg-image);
    color: var(--color-fg);
    font-family: var(--font-body);
    font-size: var(--font-size);
}
.te-preview h2 {
    font-family: var(--font-heading);
}
.te-pv-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}
.te-pv-header .site-logo {
    width: 44px;
    height: 44px;
}
.te-pv-brand {
    font-family: var(--font-heading);
    font-size: 1.3rem;
}
.te-pv-nav {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-left: auto;
}
.te-pv-nav .nav-link {
    color: var(--color-accent);
    white-space: nowrap;
}
.te-pv-nav .nav-link.active {
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius);
    background: var(--color-primary);
    color: var(--color-on-primary);
}
.te-pv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}
.te-pv-wide {
    grid-column: 1 / -1;
}
.te-pv-stage {
    display: inline-block;
    margin: 0 0.15rem 0.25rem 0;
    padding: 0.1rem 0.55rem;
    border-radius: var(--radius-pill);
    color: var(--color-on-stage);
    font-size: 0.75rem;
    font-weight: 600;
}
.te-pv-stage[data-stage="germ"] { background: var(--stage-germ); }
.te-pv-stage[data-stage="seedling"] { background: var(--stage-seedling); }
.te-pv-stage[data-stage="veg"] { background: var(--stage-veg); }
.te-pv-stage[data-stage="flower"] { background: var(--stage-flower); }
.te-pv-stage[data-stage="dry"] { background: var(--stage-dry); }
.te-pv-stage[data-stage="cure"] { background: var(--stage-cure); }
.te-pv-stage[data-stage="harvest"] { background: var(--stage-harvest); }
.te-pv-stage[data-stage="dead"] { background: var(--stage-dead); }
.te-pv-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.te-pv-t[data-text="accent"] { color: var(--color-accent); }
.te-pv-t[data-text="success-text"] { color: var(--color-success-text); }
.te-pv-t[data-text="warning-text"] { color: var(--color-warning-text); }
.te-pv-t[data-text="danger-text"] { color: var(--color-danger-text); }
.te-pv-t[data-text="info-text"] { color: var(--color-info-text); }
.te-pv-t[data-text="indica-text"] { color: var(--color-indica-text); }
.te-pv-t[data-text="sativa-text"] { color: var(--color-sativa-text); }
.te-pv-stars [data-star="star"] { color: var(--color-star); }
.te-pv-stars [data-star="star-preview"] { color: var(--color-star-preview); }
.te-pv-stars [data-star="star-empty"] { color: var(--color-star-empty); }
.te-pv-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 3.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--chart-grid);
}
.te-pv-chart span {
    flex: 1;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.te-pv-chart [data-chart="1"] { height: 60%; background: var(--chart-1); }
.te-pv-chart [data-chart="2"] { height: 85%; background: var(--chart-2); }
.te-pv-chart [data-chart="3"] { height: 45%; background: var(--chart-3); }
.te-pv-chart [data-chart="4"] { height: 100%; background: var(--chart-4); }
.te-pv-chart [data-chart="5"] { height: 70%; background: var(--chart-5); }
.te-pv-chart [data-chart="6"] { height: 35%; background: var(--chart-6); }

@media (max-width: 991.98px) {
    .te-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    /* Preview first, and still in view, but short enough to leave room
       for the controls under it. */
    .te-side {
        order: -1;
        position: sticky;
        top: 0;
        z-index: 5;
        max-height: 48vh;
        padding-bottom: 0.5rem;
        background: var(--color-bg);
    }
    /* The list of pairs gives way to the preview; it scrolls. */
    .te-status {
        margin-bottom: 0.4rem;
        padding: 0.4rem 0.6rem;
    }
    .te-status ul {
        max-height: 2.6rem;
    }
    .te-preview-label {
        display: none;
    }
}
@media (max-width: 575.98px) {
    .te-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.3rem;
    }
    .te-pv-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .te-pv-nav .nav-link:not(.active) {
        display: none;
    }
    .te-preview {
        padding: 0.75rem;
    }
}
