/* ========================================
   Marbos Audit – Competitor Comparison
   Extends the shared style.css
   ======================================== */

/* --- Site color tokens --- */
:root {
    --site-user:  #635BFF;
    --site-comp1: #3b82f6;
    --site-comp2: #f59e0b;
    --site-comp3: #10b981;
}

/* --- Input groups --- */
.input-group {
    margin-bottom: 20px;
}

.input-group-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 10px;
}

.input-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.input-dot--user    { background: var(--site-user); }
.input-dot--comp1   { background: var(--site-comp1); }
.input-dot--comp2   { background: var(--site-comp2); }
.input-dot--comp3   { background: var(--site-comp3); }
.input-dot--neutral { background: var(--color-text-muted); }

.input-wrapper--user .form-input {
    border-left: 3px solid var(--site-user);
    box-shadow: inset 4px 0 12px -6px rgba(99, 91, 255, 0.12);
}

.input-wrapper--user .form-input:focus {
    border-left-color: var(--site-user);
}

.competitor-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-wrapper--comp {
    position: relative;
}

.input-dot-inline {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    z-index: 2;
    pointer-events: none;
}

.form-input--comp {
    padding-left: 34px;
    padding-right: 36px;
}

.input-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.125rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.input-wrapper--comp:hover .input-clear,
.input-wrapper--comp .form-input:focus ~ .input-clear {
    opacity: 1;
}

.input-clear:hover {
    color: var(--color-poor);
}

.input-error {
    font-size: 0.75rem;
    color: var(--color-poor);
    margin-top: 4px;
    min-height: 0;
    transition: min-height 0.2s;
}

.input-error:empty {
    display: none;
}

.form-actions {
    margin-top: 24px;
    text-align: center;
}

.btn-primary--wide {
    min-width: 240px;
}

/* --- Loading: wide card + per-URL progress --- */
.loading-card--wide {
    max-width: 600px;
}

.progress-tracker {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    padding: 0 8px;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.progress-domain {
    min-width: 120px;
    font-weight: 700;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-status {
    flex: 1;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-status .mini-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--color-border);
    border-top-color: var(--marbos-violet);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

.progress-done {
    color: var(--color-good);
    font-weight: 700;
}

.progress-failed {
    color: var(--color-poor);
    font-weight: 700;
}

.progress-bar-wrap {
    margin-top: 18px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border-light);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--marbos-violet), var(--marbos-cyan));
    border-radius: 2px;
    transition: width 0.4s var(--ease);
}

/* --- Results legend --- */
.results-header--compare {
    text-align: center;
}

.results-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-item--user .legend-label {
    font-weight: 800;
}

.results-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* --- Score comparison grid --- */
.score-comparison-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 8px;
}

.score-comparison-row {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: box-shadow var(--duration) var(--ease);
}

.score-comparison-row:hover {
    box-shadow: var(--shadow-sm);
}

.score-row-label {
    min-width: 130px;
    flex-shrink: 0;
}

.score-row-label-name {
    font-size: 0.875rem;
    font-weight: 800;
    color: var(--marbos-navy);
}

.score-row-label-sub {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.score-row-sites {
    display: flex;
    flex: 1;
    gap: 16px;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
}

.score-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 70px;
    position: relative;
}

.score-cell--user {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: rgba(99, 91, 255, 0.05);
}

.score-cell-ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--color-border);
    background: var(--color-bg-elevated);
    transition: border-color 0.45s var(--ease);
}

.score-cell-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
}

.score-cell-domain {
    font-size: 0.625rem;
    color: var(--color-text-muted);
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-cell.score-good .score-cell-ring  { border-color: var(--color-good); }
.score-cell.score-good .score-cell-value { color: var(--color-good); }
.score-cell.score-average .score-cell-ring  { border-color: var(--color-avg); }
.score-cell.score-average .score-cell-value { color: var(--color-avg); }
.score-cell.score-poor .score-cell-ring  { border-color: var(--color-poor); }
.score-cell.score-poor .score-cell-value { color: var(--color-poor); }

.score-cell-winner {
    position: absolute;
    top: -6px;
    right: -4px;
    font-size: 0.75rem;
    line-height: 1;
}

.delta-badge {
    font-size: 0.625rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    animation: popIn 0.3s var(--ease);
}

@keyframes popIn {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.delta-badge--ahead {
    background: var(--color-good-bg);
    color: var(--color-good);
}

.delta-badge--behind {
    background: var(--color-poor-bg);
    color: var(--color-poor);
}

/* --- Missed opportunities card --- */
.missed-opportunities {
    position: relative;
    border: none;
    padding: 0;
    overflow: hidden;
}

.missed-border {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    padding: 2px;
    background: linear-gradient(135deg, var(--marbos-violet), var(--marbos-cyan));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.missed-inner {
    padding: clamp(20px, 3vw, 28px);
    background: linear-gradient(180deg, #fafaff 0%, #f5f5ff 100%);
    border-radius: var(--radius-lg);
}

.missed-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.8125rem;
    line-height: 1.65;
    color: var(--color-text-secondary);
}

.missed-item:last-child {
    border-bottom: none;
}

.missed-severity {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.4;
}

.missed-cta {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(99, 91, 255, 0.15);
    text-align: center;
}

.btn-missed-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.875rem;
    font-weight: 700;
    font-family: var(--font);
    color: #fff;
    background: linear-gradient(135deg, var(--marbos-violet) 0%, #4f46e5 100%);
    border: none;
    border-radius: var(--radius-full);
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow var(--duration) var(--ease), transform 0.12s var(--ease);
}

.btn-missed-cta:hover {
    box-shadow: 0 8px 28px rgba(99, 91, 255, 0.35);
    transform: translateY(-1px);
}

/* --- Bar charts --- */
.cwv-chart-group {
    margin-bottom: 24px;
}

.cwv-chart-group:last-child {
    margin-bottom: 0;
}

.cwv-chart-title {
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--marbos-navy);
    margin-bottom: 4px;
}

.cwv-chart-subtitle {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    margin-bottom: 14px;
}

.cwv-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.cwv-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cwv-bar-label {
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.cwv-bar-track {
    flex: 1;
    height: 24px;
    background: var(--color-bg-elevated);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.cwv-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s var(--ease);
    min-width: 2px;
}

.cwv-bar-value {
    min-width: 70px;
    font-size: 0.75rem;
    font-weight: 800;
    text-align: right;
    flex-shrink: 0;
    color: var(--color-text);
}

.cwv-bar-best {
    font-size: 0.625rem;
    margin-left: 4px;
}

.cwv-thresholds {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    font-size: 0.625rem;
    color: var(--color-text-muted);
}

.cwv-threshold {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cwv-threshold-line {
    width: 14px;
    height: 0;
    border-top: 2px dashed;
}

.cwv-threshold-line.good  { border-color: var(--color-good); }
.cwv-threshold-line.poor  { border-color: var(--color-poor); }

/* --- Security comparison --- */
.security-grades-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.security-grade-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.security-grade-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.security-grade-letter {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-text);
}

.security-grade-item.grade-good .security-grade-circle  { border-color: var(--color-good); }
.security-grade-item.grade-good .security-grade-letter  { color: var(--color-good); }
.security-grade-item.grade-average .security-grade-circle { border-color: var(--color-avg); }
.security-grade-item.grade-average .security-grade-letter { color: var(--color-avg); }
.security-grade-item.grade-poor .security-grade-circle    { border-color: var(--color-poor); }
.security-grade-item.grade-poor .security-grade-letter    { color: var(--color-poor); }

.security-grade-domain {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-align: center;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.security-grade-na {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Security header table */
.sec-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sec-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.sec-table th,
.sec-table td {
    padding: 10px 14px;
    text-align: center;
    border-bottom: 1px solid var(--color-border-light);
    white-space: nowrap;
}

.sec-table th:first-child,
.sec-table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--color-surface);
    z-index: 1;
    font-weight: 700;
    color: var(--color-text);
}

.sec-table th {
    font-size: 0.6875rem;
    font-weight: 800;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-bg-elevated);
}

.sec-table th:first-child {
    background: var(--color-bg-elevated);
}

.sec-cell-pass {
    color: var(--color-good);
    font-weight: 700;
}

.sec-cell-fail {
    color: var(--color-poor);
    opacity: 0.6;
}

.sec-cell-gap {
    background: rgba(220, 38, 38, 0.04);
}

.sec-cell-na {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* --- CrUX comparison --- */
.crux-compare-table-wrap {
    overflow-x: auto;
}

.crux-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.crux-compare-table th,
.crux-compare-table td {
    padding: 12px 14px;
    text-align: center;
    border-bottom: 1px solid var(--color-border-light);
}

.crux-compare-table th:first-child,
.crux-compare-table td:first-child {
    text-align: left;
    font-weight: 700;
    color: var(--color-text);
}

.crux-compare-table th {
    font-size: 0.6875rem;
    font-weight: 800;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-bg-elevated);
}

.crux-no-data-inline {
    text-align: center;
    padding: 28px 18px;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
    background: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    border: 1px dashed var(--color-border);
}

/* --- Recommendations --- */
.recs-group {
    margin-bottom: 20px;
}

.recs-group:last-child {
    margin-bottom: 0;
}

.recs-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 800;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border-light);
}

.recs-group-title .recs-icon {
    font-size: 1rem;
}

.recs-group-title--high   { color: var(--color-poor); }
.recs-group-title--medium { color: var(--color-avg); }
.recs-group-title--low    { color: var(--color-good); }

.rec-compare-card {
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-border);
    background: var(--color-bg-elevated);
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    line-height: 1.65;
}

.rec-compare-card:last-child {
    margin-bottom: 0;
}

.rec-compare-card--high {
    border-left-color: var(--color-poor);
    background: linear-gradient(90deg, rgba(254, 242, 242, 0.4) 0%, var(--color-bg-elevated) 12%);
}

.rec-compare-card--medium {
    border-left-color: var(--color-avg);
    background: linear-gradient(90deg, rgba(255, 251, 235, 0.4) 0%, var(--color-bg-elevated) 12%);
}

.rec-compare-card--low {
    border-left-color: var(--color-good);
    background: linear-gradient(90deg, rgba(236, 253, 245, 0.4) 0%, var(--color-bg-elevated) 12%);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .score-comparison-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .score-row-sites {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .results-controls {
        flex-direction: column;
        gap: 10px;
    }

    .score-row-sites {
        gap: 10px;
    }

    .score-cell-ring {
        width: 48px;
        height: 48px;
    }

    .score-cell-value {
        font-size: 1rem;
    }

    .cwv-bar-label {
        min-width: 90px;
        font-size: 0.6875rem;
    }

    .cwv-bar-value {
        min-width: 60px;
        font-size: 0.6875rem;
    }

    .sec-table th,
    .sec-table td {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .security-grades-row {
        gap: 10px;
    }

    .security-grade-circle {
        width: 52px;
        height: 52px;
    }

    .security-grade-letter {
        font-size: 1rem;
    }
}

@media (max-width: 640px) {
    .btn-primary--wide {
        width: 100%;
        min-width: 0;
    }

    /* Score comparison: vertical list per category */
    .score-comparison-row {
        padding: 14px 16px;
        gap: 10px;
    }

    .score-row-label {
        min-width: 0;
        width: 100%;
    }

    .score-row-sites {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        overflow: visible;
    }

    .score-cell {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        min-width: 0;
        width: 100%;
        position: relative;
    }

    .score-cell--user {
        padding: 8px 10px;
        border-radius: var(--radius-sm);
    }

    .score-cell-ring {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }

    .score-cell-value {
        font-size: 1rem;
    }

    .score-cell-domain {
        flex: 1;
        text-align: left;
        max-width: none;
        font-size: 0.75rem;
    }

    .score-cell-winner {
        position: static;
        font-size: 0.875rem;
        flex-shrink: 0;
    }

    .delta-badge {
        position: static;
        font-size: 0.6875rem;
        flex-shrink: 0;
    }

    .progress-domain {
        min-width: 80px;
    }

    .missed-inner {
        padding: 18px 16px;
    }

    .cwv-bar-row {
        flex-wrap: wrap;
    }

    .cwv-bar-label {
        min-width: 100%;
    }

    .cwv-bar-track {
        min-width: 0;
    }
}
