/* ─── Gate Calculator — Component styles ─────────────────────────────────── */

/* Unit selector next to width input */
.gc-unit-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
    background: #fff;
    cursor: pointer;
}

/* Gate type / mounting type choice grid */
#gc-gate-type-choice,
#gc-mounting-type-choice {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

/* ─── Results grid ───────────────────────────────────────────────────────── */
#gc-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

/* Full-width notices inside the grid */
#gc-results > .pwc-notice,
#gc-results > .gc-closest-notice {
    grid-column: 1 / -1;
}

/* ─── Result items ──────────────────────────────────────────────────────── */
.gc-result-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff;
    border: 1px solid #e0ddd8;
    border-radius: 6px;
    padding: 16px;
}

/* Fit quality modifiers */
.gc-result-item--tight    { border-color: #e8b84b; }
.gc-result-item--critical { border-color: #e07800; }
.gc-result-item--over     { border-color: #d9342c; background: #fdf8f6; }

.gc-result-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.gc-result-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
}

.gc-result-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.gc-result-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.gc-result-name {
    font-size: 1rem;
    color: #641E14;
}

.gc-result-badge {
    display: inline-block;
    font-size: 0.78rem;
    background: #e8f0cc;
    color: #3a5200;
    border-radius: 20px;
    padding: 2px 10px;
    width: fit-content;
}

.gc-result-actions {
    flex: 0 0 auto;
}

.gc-product-link {
    white-space: nowrap;
}

.gc-result-other-widths {
    font-size: 0.82rem;
    color: #888;
}

/* ─── Calculation breakdown ─────────────────────────────────────────────── */
.gc-breakdown {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 5px 16px;
    font-size: 0.85rem;
    background: #f8f7f4;
    border-radius: 4px;
    padding: 10px 12px;
}

.gc-breakdown-row {
    display: contents;
}

.gc-breakdown-label {
    color: #666;
}

.gc-breakdown-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: #444;
}

.gc-breakdown-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: #ddd;
    margin: 2px 0;
}

.gc-breakdown-total .gc-breakdown-label,
.gc-breakdown-total .gc-breakdown-value {
    font-weight: 600;
    color: #333;
}

.gc-breakdown-remaining--fits .gc-breakdown-label,
.gc-breakdown-remaining--fits .gc-breakdown-value {
    color: #3a6e00;
    font-weight: 600;
}

.gc-breakdown-remaining--over .gc-breakdown-label,
.gc-breakdown-remaining--over .gc-breakdown-value {
    color: #c0390b;
    font-weight: 600;
}

/* ─── Visual width bar ──────────────────────────────────────────────────── */
.gc-width-bar {
    height: 14px;
    background: #e8e8e8;
    border-radius: 7px;
    overflow: hidden;
}

.gc-width-bar__fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.4s ease;
}

.gc-width-bar__fill--good     { background: #6aaa40; }
.gc-width-bar__fill--tight    { background: #e8b84b; }
.gc-width-bar__fill--critical { background: #e07800; }
.gc-width-bar__fill--over     { background: #d9342c; }

/* ─── Result summary ─────────────────────────────────────────────────────── */
.gc-result-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.88rem;
    color: #555;
}

.gc-result-summary__row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.gc-result-summary__remaining {
    font-size: 0.9rem;
}

/* ─── Fit state colours ──────────────────────────────────────────────────── */
.gc-fit-state--good     { color: #3a6e00; }
.gc-fit-state--tight    { color: #8a6000; }
.gc-fit-state--critical { color: #974f00; }
.gc-fit-state--over     { color: #c0390b; font-weight: 600; }

/* ─── Fit warnings ───────────────────────────────────────────────────────── */
.gc-fit-warning {
    font-size: 0.82rem;
    padding: 5px 9px;
    border-radius: 4px;
    border-left: 3px solid;
    margin: 0;
}

.gc-fit-warning--tight    { background: #fffae0; border-color: #e8b84b; color: #7a5a00; }
.gc-fit-warning--critical { background: #fff3e0; border-color: #e07800; color: #7a4000; }
.gc-fit-warning--over     { background: #fdf0ef; border-color: #d9342c; color: #8b0000; }

/* ─── Breakdown toggle ───────────────────────────────────────────────────── */
.gc-breakdown-details {
    margin-top: 2px;
}

.gc-breakdown-summary {
    cursor: pointer;
    user-select: none;
    font-size: 0.82rem;
    color: #aaa;
    list-style: none;
    padding: 2px 0;
}

.gc-breakdown-summary::marker,
.gc-breakdown-summary::-webkit-details-marker { display: none; }

.gc-breakdown-summary::before { content: '\25b6\00a0'; font-size: 0.65rem; }
details[open] > .gc-breakdown-summary::before { content: '\25bc\00a0'; }

.gc-breakdown-summary:hover { color: #555; }
.gc-breakdown-details[open] .gc-breakdown-summary { margin-bottom: 6px; }

/* ─── Debug section ──────────────────────────────────────────────────────── */
.gc-debug {
    font-size: 0.78rem;
}

.gc-debug summary {
    cursor: pointer;
    user-select: none;
    color: #bbb;
    list-style: none;
}

.gc-debug summary:hover {
    color: #888;
}

.gc-debug-pre {
    background: #f4f4f4;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 0.78rem;
    overflow-x: auto;
    margin-top: 6px;
    color: #444;
    line-height: 1.5;
}

/* "Closest match" notice */
.gc-closest-notice {
    margin-bottom: 0;
}

/* ─── Admin table ─────────────────────────────────────────────────────────── */
.gc-product-table th {
    vertical-align: top;
}

.gc-product-table td {
    vertical-align: middle;
}

.gc-product-table input[type="number"] {
    width: 80px;
}
