/* ============================================
   COMPARE FUNCTIONALITY
   ============================================ */

/* Card Component */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.compare-label {
    display: block;
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.compare-select {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: var(--border-radius);
    padding: 0.5rem 0.75rem;
    font-family: monospace;
    font-size: 0.85rem;
    min-width: 180px;
    cursor: pointer;
    transition: var(--transition);
}

.compare-select:hover {
    border-color: var(--primary-color);
}

.compare-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(53, 132, 228, 0.2);
}

.compare-btn-add {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.5rem 1.25rem;
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.compare-btn-add:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(53, 132, 228, 0.4);
}

.quick-compare-btn {
    background: var(--bg-secondary);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.quick-compare-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(53, 132, 228, 0.3);
}

.compare-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    min-height: 2rem;
}

.compare-chips-empty {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

.compare-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.35rem 0.75rem;
    font-family: monospace;
    font-size: 0.75rem;
}

.chip-device {
    color: var(--text-color);
    font-weight: 500;
}

.chip-sep {
    color: var(--text-secondary);
    opacity: 0.5;
}

.chip-os {
    color: var(--primary-color);
    font-weight: 500;
}

.chip-ver {
    color: var(--text-secondary);
}

.chip-remove {
    background: rgba(244, 67, 54, 0.15);
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 0.2rem;
    line-height: 1;
    border-radius: 3px;
    transition: var(--transition);
}

.chip-remove:hover {
    background: rgba(244, 67, 54, 0.25);
    color: var(--text-color);
    transform: scale(1.1);
}

.compare-filter-bar {
    display: none;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.compare-filter-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: monospace;
}

.compare-filter-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.compare-diff-count {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
}

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

.compare-th-feature {
    text-align: left;
    padding: 0.75rem 1rem;
    font-family: monospace;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    min-width: 150px;
    border-bottom: 1px solid var(--border-color);
}

.compare-th-col {
    text-align: center;
    padding: 0.75rem;
    font-family: monospace;
    font-weight: 400;
    font-size: 0.75rem;
    white-space: nowrap;
    min-width: 155px;
    border-left: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.col-device {
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.85rem;
}

.col-os {
    color: var(--primary-color);
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

.col-ver {
    color: var(--text-secondary);
    font-size: 0.7rem;
    margin-bottom: 0.4rem;
}

.col-remove {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 4px;
    color: var(--error-color);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    font-family: monospace;
    transition: var(--transition);
}

.col-remove:hover {
    background: rgba(244, 67, 54, 0.25);
    border-color: var(--error-color);
    color: var(--error-color);
}

.compare-group-row td {
    background: var(--bg-color);
    padding: 0.4rem 1rem;
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

.compare-row {
    border-bottom: 1px solid var(--border-color);
    opacity: 0.3;
}

.compare-row-diff {
    background: rgba(53, 132, 228, 0.04);
}

.compare-td-feature {
    padding: 0.6rem 1rem;
    color: var(--text-color);
    font-size: 0.85rem;
    white-space: nowrap;
}

.diff-marker {
    color: var(--primary-color);
    margin-right: 0.4rem;
    font-size: 0.7rem;
    vertical-align: middle;
}

.compare-td-status {
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-left: 1px solid var(--border-color);
}

.compare-td-footer {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: monospace;
    border-top: 1px solid var(--border-color);
}

.compare-td-footer-val {
    padding: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    vertical-align: top;
}

/* Legend bar */
.compare-legend-bar {
    display: none;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-family: monospace;
    overflow: hidden;
}

.legend-summary {
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-summary::-webkit-details-marker { display: none; }

.legend-summary::after {
    content: '▸';
    font-size: 0.65rem;
    transition: transform 0.15s;
}

details[open] .legend-summary::after {
    transform: rotate(90deg);
}

.legend-content {
    padding: 0.75rem 0.9rem 0.9rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.legend-section {
    flex: 1;
    min-width: 220px;
}

.legend-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    opacity: 0.6;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.legend-bar-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.legend-segs {
    display: inline-flex;
    gap: 1px;
    align-items: center;
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.legend-bar-row p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.78rem;
}

.legend-green { color: #4ade80; }
.legend-red   { color: #f87171; }

html[data-theme="light"] .legend-green { color: #16a34a; }
html[data-theme="light"] .legend-red   { color: #dc2626; }

.legend-pct-demo {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    margin-left: 3px;
}

.legend-metrics {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.legend-metric-row {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.legend-metric-row dt {
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.78rem;
}

.legend-metric-row dd {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.4;
}

/* World map */
.compare-map-wrap {
    margin-top: 1.5rem;
}

.compare-map-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.compare-map-title {
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.compare-map-hint {
    font-family: monospace;
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.compare-map-container {
    position: relative;
}

/* ── UI environment percentage bar ── */
.ui-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ui-bar-track {
    width: 4.5rem;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.ui-bar-fill {
    height: 100%;
    background: #4a8fdd;
    border-radius: 3px;
    min-width: 0;
    transition: width 0.2s;
}

.ui-bar-pct {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.compare-row-ui td {
    background: rgba(74, 143, 221, 0.04);
}

.light-theme .ui-bar-fill {
    background: #2a70c0;
}

.light-theme .compare-row-ui td {
    background: rgba(42, 112, 192, 0.04);
}

/* ── Expandable sub-feature rows (tech preview) ── */
.expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.55rem;
    color: var(--text-secondary);
    padding: 0;
    margin-right: 0.3rem;
    vertical-align: middle;
    transition: color 0.15s, border-color 0.15s;
    line-height: 1;
}

.expand-btn::before { content: '▶'; }
.expand-btn.expanded::before { content: '▼'; }

.expand-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.compare-row-expandable .compare-td-feature {
    font-weight: 500;
}

.compare-sub-row {
    background: rgba(0, 0, 0, 0.06);
}

.compare-td-sub {
    padding-left: 2.5rem !important;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.tech-preview-badge {
    display: inline-block;
    font-size: 0.5rem;
    background: #6d5fc7;
    color: #fff;
    border-radius: 2px;
    padding: 1px 3px;
    margin-left: 4px;
    vertical-align: middle;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.75;
}

.light-theme .compare-sub-row {
    background: rgba(0, 0, 0, 0.03);
}

.compare-map-attribution {
    margin-top: 0.4rem;
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

.compare-map-attribution a {
    color: inherit;
    text-decoration: underline;
}

/* Applied via JS to the inlined #world-map SVG */
.compare-world-map {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    background: #111c2b;
}

html[data-theme="light"] .compare-world-map {
    background: #b8cfe0;
}

/* Country paths that haven't been grouped yet (before JS runs) */
#world-map path,
#world-map g > path {
    fill: #243447;
    stroke: #1a2840;
    stroke-width: 0.5;
}

.continent path {
    fill: #243447;
    stroke: #1a2840;
    stroke-width: 0.5;
    cursor: pointer;
    transition: fill 0.15s, stroke 0.15s;
}

html[data-theme="light"] #world-map path,
html[data-theme="light"] #world-map g > path,
html[data-theme="light"] .continent path {
    fill: #c9d8a8;
    stroke: #9ab068;
}

.continent-active path,
.continent:hover path {
    fill: #3584e4;
    stroke: #62a0ea;
}

html[data-theme="light"] .continent-active path,
html[data-theme="light"] .continent:hover path {
    fill: #3584e4;
    stroke: #1d5fa8;
}

.continent-label {
    fill: rgba(255, 255, 255, 0.25);
    font-size: 11px;
    font-family: monospace;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
    transition: fill 0.15s;
}

html[data-theme="light"] .continent-label {
    fill: rgba(0, 0, 0, 0.28);
}

.continent-active .continent-label,
.continent:hover .continent-label {
    fill: rgba(255, 255, 255, 0.85);
}

html[data-theme="light"] .continent-active .continent-label,
html[data-theme="light"] .continent:hover .continent-label {
    fill: rgba(255, 255, 255, 0.9);
}

/* Map tooltip */
.map-tooltip {
    position: absolute;
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.6rem 0.75rem;
    font-family: monospace;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 10;
    min-width: 210px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.map-tip-title {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-color);
    margin-bottom: 0.45rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.map-tip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.18rem 0;
}

.map-tip-col {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
}

.map-tip-count {
    font-weight: 600;
    color: var(--text-color);
    min-width: 18px;
    text-align: right;
}

.map-tip-zero {
    color: var(--text-secondary);
    opacity: 0.4;
    font-weight: 400;
}

.map-tip-empty {
    color: var(--text-secondary);
    font-size: 0.72rem;
    opacity: 0.6;
}

/* Totals summary row in thead */
.compare-totals-row {
    background: var(--bg-color);
    border-bottom: 2px solid var(--border-color);
}

.compare-th-totals-label {
    padding: 0.45rem 1rem;
    font-family: monospace;
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    font-weight: 500;
}

.compare-th-totals-val {
    padding: 0.45rem 0.75rem;
    text-align: center;
    border-left: 1px solid var(--border-color);
}

.totals-report-meta {
    margin-top: 0.25rem;
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 400;
}

.totals-report-meta strong {
    color: var(--text-color);
    font-weight: 600;
}

/* Feature bar — segmented passed/failed visualization */
.feature-bar {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: default;
}

.bar-segs {
    display: flex;
    gap: 1px;
    align-items: center;
}

.bar-seg {
    width: 6px;
    height: 14px;
    border-radius: 1px;
    flex-shrink: 0;
}

.bar-passed {
    background: rgba(34, 197, 94, 0.72);
}

.bar-failed {
    background: rgba(239, 68, 68, 0.72);
}

.bar-pct {
    font-size: 0.68rem;
    font-family: monospace;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

html[data-theme="light"] .bar-passed { background: rgba(22, 163, 74, 0.75); }
html[data-theme="light"] .bar-failed { background: rgba(220, 38, 38, 0.75); }

.contributor-tag {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--primary-color);
    margin-right: 0.5rem;
}

/* Status Badge Styles */
.status-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-family: monospace;
    font-size: 0.72rem;
    padding: 0.15em 0.55em;
    border-radius: 3px;
    font-weight: 500;
    white-space: nowrap;
}

.status-cell::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/* Dark theme status styles */
.status-cell-full {
    color: #22c55e;
    background: #052e16;
    border: 1px solid #14532d;
}

.status-cell-full::before {
    background: #22c55e;
}

.status-cell-partial {
    color: #f59e0b;
    background: #292524;
    border: 1px solid #78350f;
}

.status-cell-partial::before {
    background: #f59e0b;
}

.status-cell-none {
    color: #ef4444;
    background: #2d0a0a;
    border: 1px solid #7f1d1d;
}

.status-cell-none::before {
    background: #ef4444;
}

.status-cell-unknown {
    color: #6b7280;
    background: #1a1c22;
    border: 1px solid #374151;
}

.status-cell-unknown::before {
    background: #6b7280;
}

/* Light Theme Specific Adjustments */
html[data-theme="light"] .compare-row {
    opacity: 1;
}

html[data-theme="light"] .compare-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .compare-td-status {
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

/* Light theme status badges */
html[data-theme="light"] .status-cell-full {
    color: #15803d;
    background: #dcfce7;
    border: 1px solid #86efac;
}

html[data-theme="light"] .status-cell-full::before {
    background: #22c55e;
}

html[data-theme="light"] .status-cell-partial {
    color: #c2410c;
    background: #fed7aa;
    border: 1px solid #fdba74;
}

html[data-theme="light"] .status-cell-partial::before {
    background: #f97316;
}

html[data-theme="light"] .status-cell-none {
    color: #b91c1c;
    background: #fee2e2;
    border: 1px solid #fca5a5;
}

html[data-theme="light"] .status-cell-none::before {
    background: #dc2626;
}

html[data-theme="light"] .status-cell-unknown {
    color: #4b5563;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
}

html[data-theme="light"] .status-cell-unknown::before {
    background: #9ca3af;
}

/* UI filter checkboxes */
.ui-filter-cb {
    width: 14px;
    height: 14px;
    margin-right: 5px;
    cursor: pointer;
    accent-color: var(--primary-color);
    vertical-align: middle;
    flex-shrink: 0;
}

.ui-row-disabled {
    opacity: 0.45;
}

.ui-row-disabled .ui-bar-fill {
    background: var(--text-secondary);
}

.totals-filter-tag {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(53, 132, 228, 0.12);
    border: 1px solid rgba(53, 132, 228, 0.3);
    border-radius: 8px;
    padding: 0.05rem 0.4rem;
    vertical-align: middle;
    margin-left: 0.2rem;
}

/* Kernel / Config info cells */
.compare-info-text {
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.compare-config-link {
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
}

.compare-config-link:hover {
    text-decoration: underline;
}
