/* ═══════════════════════════════════════════════════════════════
   ScoreWidget — Reusable compact/expandable scoring component
   ═══════════════════════════════════════════════════════════════ */

.sw-widget {
    display: flex;
    flex-direction: column;
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
}
/* ── Header row (always visible) ────────────────────────────── */

.sw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    gap: 8px;
}

.sw-header-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.sw-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Score button ───────────────────────────────────────────── */

.sw-btn {
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    border-radius: 7px;
    padding: 6px 18px;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: 0.02em;
    transition: all .18s;
    /* Default: teal (matches sbx-btn-generate) */
    color: #22d3ee;
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(34,211,238,0.09));
    border: 1px solid rgba(34,211,238,0.35);
}
.sw-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(34,211,238,0.28), rgba(34,211,238,0.18));
    box-shadow: 0 0 18px rgba(34,211,238,0.18);
}
.sw-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Variant: teal (explicit, same as default) */
.sw-variant-teal .sw-btn {
    color: #22d3ee;
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(34,211,238,0.09));
    border: 1px solid rgba(34,211,238,0.35);
}

/* Variant: amber (matches production buttons) */
.sw-variant-amber .sw-btn {
    color: #0a0600;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
}
.sw-variant-amber .sw-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 4px 14px rgba(245,158,11,0.35);
}

/* ── Shared action button (globally reusable outside ScoreWidget) ── */

.sw-action-btn {
    padding: 6px 18px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.02em;
    cursor: pointer;
    white-space: nowrap;
    transition: all .18s;
}
.sw-action-btn:disabled { opacity: .4; cursor: not-allowed; }

.sw-action-btn-teal {
    color: #22d3ee;
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(34,211,238,0.09));
    border: 1px solid rgba(34,211,238,0.35);
}
.sw-action-btn-teal:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(34,211,238,0.28), rgba(34,211,238,0.18));
    box-shadow: 0 0 18px rgba(34,211,238,0.18);
}

.sw-action-btn-amber {
    color: #0a0600;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
}
.sw-action-btn-amber:hover:not(:disabled) {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 4px 14px rgba(245,158,11,0.35);
}

/* ── Status badge ───────────────────────────────────────────── */

.sw-status-wrap { min-height: 0; }
.sw-status-wrap:empty { display: none; }

.sw-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 10px;
    padding: 2px 8px;
    white-space: nowrap;
}

.sw-status-queued  { color: #a78bfa; background: rgba(167,139,250,0.12); }
.sw-status-running { color: #38bdf8; background: rgba(56,189,248,0.12); animation: sw-pulse 1.5s ease-in-out infinite; }
.sw-status-done    { color: #34d399; background: rgba(52,211,153,0.12); }
.sw-status-error   { color: #f87171; background: rgba(248,113,113,0.12); }

@keyframes sw-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

/* ── Score dial ─────────────────────────────────────────────── */

.sw-dial {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255,255,255,0.02);
    transition: border-color .2s, background .2s;
}

.sw-dial-value {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    color: rgba(255,255,255,0.5);
}
.sw-dial-label {
    font-size: 7px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.3);
    margin-top: 1px;
}

/* Dial color states */
.sw-dial.sw-excellent { border-color: rgba(52,211,153,0.6);  background: rgba(52,211,153,0.06); }
.sw-dial.sw-excellent .sw-dial-value { color: #34d399; }
.sw-dial.sw-good      { border-color: rgba(167,139,250,0.5); background: rgba(167,139,250,0.06); }
.sw-dial.sw-good      .sw-dial-value { color: #a78bfa; }
.sw-dial.sw-fair      { border-color: rgba(251,146,60,0.5);  background: rgba(251,146,60,0.06); }
.sw-dial.sw-fair      .sw-dial-value { color: #fb923c; }
.sw-dial.sw-weak      { border-color: rgba(239,68,68,0.5);   background: rgba(239,68,68,0.06); }
.sw-dial.sw-weak      .sw-dial-value { color: #ef4444; }

/* ── Expand/collapse button ─────────────────────────────────── */

.sw-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    outline: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    transition: color .15s, background .15s;
}
.sw-expand-btn:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.06); }
.sw-expand-btn:disabled { opacity: .3; cursor: default; }
.sw-expand-btn:disabled:hover { background: transparent; color: rgba(255,255,255,0.35); }

.sw-chevron {
    transition: transform .2s ease;
}
.sw-expanded .sw-chevron {
    transform: rotate(180deg);
}

/* ── Details panel (expandable) ─────────────────────────────── */

.sw-details {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .25s ease, opacity .2s ease, padding .2s ease;
    padding: 0 12px;
}

.sw-expanded .sw-details {
    max-height: 400px;
    opacity: 1;
    padding: 0 12px 12px 12px;
}

/* ── Category rows ──────────────────────────────────────────── */

.sw-cat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.sw-cat-label {
    width: 100px;
    min-width: 100px;
    font-size: 10px;
    font-weight: 500;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sw-cat-bar {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.sw-cat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .4s ease;
}

.sw-cat-val {
    width: 28px;
    min-width: 28px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Timestamp ──────────────────────────────────────────────── */
.sw-timestamp {
    font-size: 9px;
    color: rgba(255,255,255,0.2);
    margin-top: 6px;
    text-align: right;
}


/* ═══════════════════════════════════════════════════════════════
   ScoreWidgetDialog — V2 per-dimension breakdown modal
   ═══════════════════════════════════════════════════════════════ */

.swd-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(6px);
}

.swd-panel {
    background: #0f172a;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    max-width: 1000px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    color: #e2e8f0;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.swd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.swd-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(255,255,255,0.95);
}

.swd-close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    transition: color .15s;
}
.swd-close:hover { color: rgba(255,255,255,0.95); }

.swd-loading,
.swd-error {
    padding: 32px 22px;
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
}
.swd-error { color: #f87171; }

/* ── Overall score banner ───────────────────────────────────── */

.swd-overall {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 22px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.swd-overall-score {
    font-size: 32px;
    font-weight: 700;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.swd-overall-score.swd-pass { color: #34d399; border-color: rgba(52,211,153,0.5);  background: rgba(52,211,153,0.06); }
.swd-overall-score.swd-warn { color: #fb923c; border-color: rgba(251,146,60,0.5);  background: rgba(251,146,60,0.06); }
.swd-overall-score.swd-fail { color: #ef4444; border-color: rgba(239,68,68,0.5);   background: rgba(239,68,68,0.06); }

.swd-overall-label {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 4px;
}
.swd-overall-ts {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
}

/* ── Gate-cap note banner ───────────────────────────────────── */

.swd-gate-note {
    margin: 12px 22px 0;
    padding: 10px 14px;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 12px;
    line-height: 1.5;
}
.swd-gate-note strong { color: #f87171; }

/* ── Dimension list ─────────────────────────────────────────── */

.swd-dim-list {
    padding: 14px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
/* Compact 3-column dimension row — score | name | body+chevron */

.swd-dim-row {
    display: grid;
    grid-template-columns: 60px 200px 1fr;
    align-items: start;
    gap: 14px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
}

/* Failing rows get a subtle red wash so they read as "needs attention"
   at a glance even before reading the score badge. */
.swd-dim-row.swd-dim-fail-row {
    background: rgba(239,68,68,0.04);
    border-color: rgba(239,68,68,0.18);
}

/* Col 1 — score */
.swd-dim-col-score {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-top: 1px;
}

.swd-dim-badge {
    font-size: 13px;
    font-weight: 700;
    padding: 3px 11px;
    border-radius: 7px;
    border: 1px solid;
    font-variant-numeric: tabular-nums;
    min-width: 42px;
    text-align: center;
}
.swd-dim-badge.swd-pass { color: #34d399; border-color: rgba(52,211,153,0.5);  background: rgba(52,211,153,0.08); }
.swd-dim-badge.swd-warn { color: #fb923c; border-color: rgba(251,146,60,0.5);  background: rgba(251,146,60,0.08); }
.swd-dim-badge.swd-fail { color: #ef4444; border-color: rgba(239,68,68,0.5);   background: rgba(239,68,68,0.08); }

/* Col 2 — dimension name + critical tag */
.swd-dim-col-name {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding-top: 4px;
}

.swd-dim-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.92);
    line-height: 1.3;
}

.swd-dim-critical {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fca5a5;
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 6px;
    padding: 1px 6px;
}

/* Col 3 — comment + fix + chevron, all visible inline */
.swd-dim-col-body {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.swd-dim-body-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 3px;
}

.swd-dim-comment {
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    line-height: 1.45;
}

.swd-dim-fix {
    font-size: 12px;
    color: rgba(255,255,255,0.88);
    line-height: 1.45;
    padding: 6px 9px;
    background: rgba(34,211,238,0.06);
    border-left: 2px solid rgba(34,211,238,0.5);
    border-radius: 4px;
}
.swd-dim-fix-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #22d3ee;
    margin-right: 6px;
}

.swd-dim-chevron {
    color: rgba(255,255,255,0.4);
    transition: transform .2s ease;
    flex-shrink: 0;
    margin-top: 6px;
}
.swd-dim-expanded .swd-dim-chevron {
    transform: rotate(180deg);
    color: rgba(255,255,255,0.7);
}

/* Analysis spans full row width when expanded */
.swd-dim-analysis {
    grid-column: 1 / -1;
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 11px;
    color: rgba(255,255,255,0.65);
    background: rgba(0,0,0,0.25);
    border-radius: 6px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* On narrow viewports collapse to vertical stacking so nothing
   gets crushed. The grid columns become single-column auto-flow. */
@media (max-width: 640px) {
    .swd-dim-row {
        grid-template-columns: auto 1fr;
    }
    .swd-dim-col-body {
        grid-column: 1 / -1;
    }
}

.sw-dial-clickable {
    cursor: pointer;
}
.sw-dial-clickable:hover {
    opacity: 0.85;
    transform: scale(1.05);
    transition: transform 0.15s ease, opacity 0.15s ease;
}