/* =========================================================
   Compare Tray + Compare Matrix
   White-card theme on the purple page gradient.
   ========================================================= */

/* ---------- Floating tray ---------- */
.compare-tray {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1090;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(15, 12, 40, 0.18), 0 2px 6px rgba(15, 12, 40, 0.06);
    font-family: inherit;
    color: #1a1a2e;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
}
.compare-tray.is-minimized .compare-tray__body {
    display: none;
}
.compare-tray.is-minimized {
    width: 220px;
}
.compare-tray__inner {
    padding: 10px 12px 12px;
}
.compare-tray__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 2px 8px;
    border-bottom: 1px solid #f0f1f5;
    margin-bottom: 10px;
}
.compare-tray__count {
    font-weight: 700;
    font-size: 14px;
    color: #1a1a2e;
}
.compare-tray__hint {
    font-size: 11px;
    color: #888;
    margin-right: auto;
}
.compare-tray__min {
    background: transparent;
    border: 1px solid transparent;
    color: #555;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.compare-tray__min:hover {
    background: #f6f6fa;
    color: #1a1a2e;
}
.compare-tray.is-minimized .compare-tray__min i {
    transform: rotate(180deg);
}

.compare-tray__slots {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.compare-tray__slot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #fafbff;
    border: 1px solid #eef0f7;
    border-radius: 8px;
    min-height: 40px;
}
.compare-tray__slot--empty {
    border-style: dashed;
    background: #fff;
}
.compare-tray__logo {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    object-fit: contain;
    background: #fff;
    flex-shrink: 0;
}
.compare-tray__logo--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}
.compare-tray__logo--ghost {
    background: #f0f1f5;
}
.compare-tray__name {
    flex: 1 1 auto;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a2e;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.compare-tray__name--ghost {
    color: #aaa;
    font-weight: 500;
}
.compare-tray__remove {
    background: transparent;
    border: 0;
    color: #888;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.compare-tray__remove:hover {
    background: #fee2e2;
    color: #dc2626;
}

.compare-tray__actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.compare-tray__compare-btn {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.compare-tray__compare-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
    color: #fff;
}
.compare-tray__compare-btn[aria-disabled="true"] {
    background: #e5e7eb;
    color: #888;
    box-shadow: none;
    cursor: not-allowed;
}
.compare-tray__compare-btn[aria-disabled="true"]:hover {
    transform: none;
    color: #888;
}
.compare-tray__clear-btn {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #666;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.compare-tray__clear-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

@media (max-width: 576px) {
    .compare-tray {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 12px;
        border-radius: 12px;
    }
    .compare-tray.is-minimized {
        width: 180px;
    }
    .compare-tray__slots {
        grid-template-columns: 1fr;
    }
}

/* ---------- Add-to-compare button on firm cards ---------- */
.compare-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #fff;
    border: 1px dashed #c7cae0;
    color: #4f46e5;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, border-style 0.15s;
}
.compare-add-btn i {
    font-size: 14px;
}
.compare-add-btn:hover {
    background: #eef0ff;
    border-color: #6366f1;
    color: #4f46e5;
}
.compare-add-btn.is-added {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
    border-style: solid;
}
.compare-add-btn.is-added:hover {
    background: #ef4444;
    border-color: transparent;
}
.compare-add-btn.is-added:hover [data-compare-add-label]::after {
    content: ' (remove)';
    font-weight: 500;
    opacity: 0.85;
}

/* Compact variant for table action cells */
.compare-add-btn--compact {
    padding: 4px 8px;
    font-size: 11px;
}

/* Firm card row containing the +Compare button + Similar link */
.firm-card__compare-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.firm-card__compare-row .compare-add-btn {
    flex: 1 1 auto;
    min-width: 110px;
}
.firm-card__compare-row .firm-card__similar-link {
    flex: 1 1 auto;
    text-align: center;
}

/* Inline variant for firm-show hero */
.compare-add-btn--hero {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}
.compare-add-btn--hero:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.65);
    color: #fff;
}

/* ---------- Toast ---------- */
.compare-toast {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translate(-50%, 12px);
    background: #1a1a2e;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: calc(100vw - 32px);
}
.compare-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
@media (max-width: 576px) {
    .compare-toast {
        bottom: 96px; /* sit above the tray on mobile */
    }
}
@media (prefers-reduced-motion: reduce) {
    .compare-tray,
    .compare-toast,
    .compare-tray__compare-btn,
    .compare-add-btn {
        transition: none !important;
    }
}

/* =========================================================
   Compare Matrix (rendered on /compare?firms=...)
   ========================================================= */
.compare-matrix {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 20px 22px;
    margin: 0 0 24px;
    box-shadow: 0 4px 16px rgba(15, 12, 40, 0.06);
    color: #1a1a2e;
}
.compare-matrix__header {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f1f5;
}
.compare-matrix__title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    display: flex;
    align-items: center;
    gap: 8px;
}
.compare-matrix__title i {
    color: #6366f1;
    font-size: 22px;
}
.compare-matrix__sub {
    margin: 0;
    font-size: 13px;
    color: #666;
}
.compare-matrix__sub a {
    color: #4f46e5;
    text-decoration: underline;
}

.compare-matrix__scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -22px;
    padding: 0 22px;
}
.compare-matrix__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 540px;
    font-size: 13px;
}
.compare-matrix__table thead th {
    background: #fafbff;
    border-bottom: 2px solid #eef0f7;
    padding: 12px 10px;
    vertical-align: top;
}
.compare-matrix__row-label {
    font-weight: 600;
    color: #555;
    text-align: left;
    width: 150px;
    background: #fff;
    padding: 12px 10px;
    border-bottom: 1px solid #f0f1f5;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.compare-matrix__firm-col {
    text-align: center;
    min-width: 160px;
}
.compare-matrix__firm-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.compare-matrix__firm-logo {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: contain;
    background: #fff;
    border: 1px solid #f0f1f5;
}
.compare-matrix__firm-name {
    font-weight: 700;
    font-size: 15px;
    color: #1a1a2e;
    text-decoration: none;
    line-height: 1.2;
}
.compare-matrix__firm-name:hover {
    color: #4f46e5;
    text-decoration: underline;
}
.compare-matrix__firm-type {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.compare-matrix__remove {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #888;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
    transition: all 0.15s ease;
}
.compare-matrix__remove:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

.compare-matrix__cell {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid #f0f1f5;
    color: #333;
    font-size: 13px;
    vertical-align: middle;
}
.compare-matrix__cell.is-winner {
    background: rgba(16, 185, 129, 0.08);
    position: relative;
}
.compare-matrix__cell.is-winner::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 6px;
    color: #10b981;
    font-weight: 700;
    font-size: 14px;
}
.compare-matrix__na {
    color: #aaa;
}
.compare-matrix__cell-note {
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.compare-matrix__score-pill {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
}

.compare-matrix__grade {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    color: #fff;
}
.compare-matrix__grade--aplus,
.compare-matrix__grade--a    { background: #10b981; }
.compare-matrix__grade--bplus,
.compare-matrix__grade--b    { background: #3b82f6; }
.compare-matrix__grade--bminus { background: #6366f1; }
.compare-matrix__grade--c    { background: #f59e0b; }
.compare-matrix__grade--d    { background: #ef4444; }
.compare-matrix__grade--f    { background: #991b1b; }

.compare-matrix__tp {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #1a1a2e;
}
.compare-matrix__tp-star {
    color: #00b67a;
    font-size: 14px;
}
.compare-matrix__tp small {
    color: #888;
    font-size: 11px;
}
.compare-matrix__tp-suspended {
    display: inline-block;
    padding: 3px 8px;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 5px;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
}

.compare-matrix__discount {
    display: inline-block;
    padding: 3px 8px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border-radius: 5px;
    font-weight: 700;
    font-size: 12px;
}
.compare-matrix__code {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 6px;
    background: #fff;
    border: 1px dashed #c7cae0;
    border-radius: 4px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 11px;
    color: #4f46e5;
}

.compare-matrix__cell--cta {
    padding: 16px 8px;
}
.compare-matrix__visit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    padding: 9px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
    line-height: 1.1;
    white-space: nowrap;
}
.compare-matrix__visit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(16, 185, 129, 0.35);
    color: #fff;
}
.compare-matrix__details-link {
    display: block;
    margin-top: 6px;
    color: #6366f1;
    font-size: 12px;
    text-decoration: none;
}
.compare-matrix__details-link:hover {
    text-decoration: underline;
    color: #4f46e5;
}

.compare-matrix__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f0f1f5;
    flex-wrap: wrap;
    gap: 8px;
}
.compare-matrix__add-link {
    color: #4f46e5;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.compare-matrix__add-link:hover {
    text-decoration: underline;
    color: #4338ca;
}
.compare-matrix__clear {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #666;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.compare-matrix__clear:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

@media (max-width: 768px) {
    .compare-matrix {
        padding: 16px 14px;
    }
    .compare-matrix__scroll {
        margin: 0 -14px;
        padding: 0 14px;
    }
    .compare-matrix__row-label {
        width: 110px;
        font-size: 11px;
    }
    .compare-matrix__firm-col {
        min-width: 130px;
    }
    .compare-matrix__firm-logo {
        width: 44px;
        height: 44px;
    }
    .compare-matrix__firm-name {
        font-size: 13px;
    }
}
