/* ─────────────────────────────────────────────────────────────────
   Wicte Compare — sticky pill bar, "+ compare" inline button, modal
   All classes prefixed with `wc-` to avoid collisions with notes (wn-).
   ───────────────────────────────────────────────────────────────── */

:root {
    --wc-radius: 12px;
    --wc-shadow: 0 12px 28px rgba(13,148,136,.18), 0 2px 8px rgba(0,0,0,.06);
    --wc-shadow-soft: 0 4px 12px rgba(0,0,0,.06);
    --wc-border: rgba(0,0,0,.08);
    --wc-bg: #ffffff;
    --wc-bg-elev: #ffffff;
    --wc-text: #1F2937;
    --wc-text-muted: #6B7280;
    --wc-primary: #0D9488;
    --wc-primary-soft: rgba(13,148,136,.08);
    --wc-primary-strong: #0F766E;
    --wc-danger: #EF4444;
    --wc-success: #10B981;
    --wc-warn: #F59E0B;
    /* Position offsets so notes FAB (right:20) and compare bar coexist */
    --wc-bar-right: 96px;
    --wc-bar-bottom: 24px;
}

body.dark-mode-variables {
    --wc-bg: #064E3B;
    --wc-bg-elev: #065F46;
    --wc-text: #ECFDF5;
    --wc-text-muted: #6EE7B7;
    --wc-border: rgba(255,255,255,.08);
    --wc-shadow: 0 12px 28px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.3);
    --wc-shadow-soft: 0 4px 12px rgba(0,0,0,.3);
}

/* ── Sticky pill bar ─────────────────────────────────────── */
.wc-bar {
    position: fixed;
    right: var(--wc-bar-right);
    bottom: var(--wc-bar-bottom);
    z-index: 49;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 8px;
    background: var(--wc-bg-elev);
    color: var(--wc-text);
    border: 1px solid var(--wc-border);
    border-radius: 999px;
    box-shadow: var(--wc-shadow);
    cursor: pointer;
    font: inherit;
    transform: translateY(0);
    opacity: 1;
    transition: transform .22s ease, opacity .22s ease, box-shadow .18s ease;
}
.wc-bar[hidden] { display: none; }
.wc-bar.is-hiding { transform: translateY(8px); opacity: 0; }
.wc-bar:hover { box-shadow: 0 14px 32px rgba(13,148,136,.25), 0 4px 10px rgba(0,0,0,.08); }
.wc-bar:active { transform: scale(.98); }

.wc-bar__thumbs {
    display: inline-flex;
    align-items: center;
}
.wc-bar__thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--wc-bg-elev);
    background: var(--wc-primary-soft) center/cover no-repeat;
    margin-left: -8px;
    cursor: pointer;
    padding: 0;
    transition: transform .12s ease, z-index .12s step-end;
    position: relative;
    overflow: hidden;
}
.wc-bar__thumb:first-child { margin-left: 0; }
.wc-bar__thumb:hover {
    transform: translateY(-2px) scale(1.06);
    z-index: 2;
    border-color: var(--wc-primary);
}
.wc-bar__thumb-ph {
    width: 100%; height: 100%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--wc-primary);
    background: var(--wc-primary-soft);
}
.wc-bar__thumb-ph .material-icons-sharp { font-size: 1rem; }
.wc-bar__thumb-x {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(15,23,42,.6);
    color: #fff;
    font-size: .7rem;
}
.wc-bar__thumb:hover .wc-bar__thumb-x { display: inline-flex; }

.wc-bar__label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--wc-text);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.wc-bar__label .material-icons-sharp {
    font-size: 1.05rem;
    color: var(--wc-primary);
}
.wc-bar__label-count {
    background: var(--wc-primary-soft);
    color: var(--wc-primary);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: .72rem;
    font-weight: 700;
}

/* Mobile bar shifts to bottom-center, compact */
@media (max-width: 768px) {
    .wc-bar {
        right: 50%;
        transform: translateX(50%);
        bottom: 76px;
        padding: 6px 12px 6px 6px;
    }
    .wc-bar.is-hiding { transform: translateX(50%) translateY(8px); }
    .wc-bar__thumb { width: 28px; height: 28px; }
}

/* ── Inline "+ compare" button on cards ──────────────────── */
.wc-attach {
    position: absolute;
    top: 50px;          /* sits right below the wn-attach (top:8) */
    right: 8px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    border: 1px solid var(--wc-border);
    box-shadow: var(--wc-shadow-soft);
    cursor: pointer;
    color: var(--wc-text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    z-index: 5;
    transition: transform .15s ease, color .15s ease, background .15s ease;
}
.wc-attach:hover {
    color: var(--wc-primary);
    transform: scale(1.06);
    background: #fff;
}
.wc-attach.is-active {
    color: var(--wc-primary);
    background: var(--wc-primary-soft);
    border-color: rgba(13,148,136,.3);
}
.wc-attach .material-icons-sharp { font-size: 1.15rem; }
body.dark-mode-variables .wc-attach { background: rgba(0,0,0,.4); }

/* Mobile attach button slightly smaller */
@media (max-width: 768px) {
    .wc-attach { top: 42px; right: 6px; width: 32px; height: 32px; }
    .wc-attach .material-icons-sharp { font-size: 1rem; }
}

/* ── Modal ────────────────────────────────────────────────── */
.wc-modal { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.wc-modal[hidden] { display: none; }
.wc-modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(15,23,42,.45);
    opacity: 0;
    pointer-events: auto;
    animation: wc-fade .18s ease forwards;
}
@keyframes wc-fade { to { opacity: 1; } }

.wc-modal__panel {
    position: absolute;
    top: 5vh; left: 50%;
    transform: translate(-50%, 0);
    width: min(96vw, 1180px);
    max-height: 90vh;
    background: var(--wc-bg);
    color: var(--wc-text);
    border: 1px solid var(--wc-border);
    border-radius: var(--wc-radius);
    box-shadow: var(--wc-shadow);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    animation: wc-pop-in .22s ease;
}
@keyframes wc-pop-in {
    from { opacity: 0; transform: translate(-50%, -8px) scale(.98); }
    to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

body.rd-has-topbar .wc-modal__panel { top: calc(56px + 24px); }

.wc-modal__header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--wc-border);
}
.wc-modal__header h2 {
    margin: 0; font-size: 1.05rem; font-weight: 600;
    color: var(--wc-primary);
    flex: 1;
    display: inline-flex; align-items: center; gap: 8px;
}
.wc-modal__header h2 .material-icons-sharp { font-size: 1.2rem; }
.wc-modal__count {
    background: var(--wc-primary-soft);
    color: var(--wc-primary);
    font-size: .75rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.wc-icon-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--wc-text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s ease, color .15s ease;
}
.wc-icon-btn:hover { background: var(--wc-primary-soft); color: var(--wc-primary); }
.wc-icon-btn--danger:hover { background: rgba(239,68,68,.1); color: var(--wc-danger); }
.wc-icon-btn .material-icons-sharp { font-size: 1.15rem; }

.wc-modal__body {
    flex: 1;
    overflow: auto;
    padding: 0;
}
.wc-modal__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--wc-border);
    align-items: center;
}
.wc-modal__footer__spacer { flex: 1; }

/* ── Compare table ───────────────────────────────────────── */
.wc-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}
.wc-table__row { display: contents; }
.wc-table thead th,
.wc-table tbody td,
.wc-table tbody th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--wc-border);
    vertical-align: top;
    font-size: .88rem;
    line-height: 1.35;
}
.wc-table thead th {
    position: sticky;
    top: 0;
    background: var(--wc-bg);
    z-index: 2;
    text-align: left;
    font-weight: 600;
    color: var(--wc-text);
}
.wc-table thead th.wc-th--label,
.wc-table tbody th.wc-th-row {
    position: sticky;
    left: 0;
    background: var(--wc-bg);
    z-index: 1;
    width: 160px;
    color: var(--wc-text-muted);
    font-weight: 500;
    text-align: left;
}
.wc-table thead th.wc-th--label { z-index: 3; }
.wc-table tbody td.wc-best {
    background: rgba(16,185,129,.08);
    color: var(--wc-success);
    font-weight: 600;
}
.wc-table tbody td.wc-best::before {
    content: '✓ ';
    font-weight: 700;
}

.wc-col-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 4px;
}
.wc-col-head__top {
    display: flex; align-items: center; gap: 8px;
}
.wc-col-head__thumb {
    width: 56px; height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--wc-primary-soft);
    flex: 0 0 auto;
}
.wc-col-head__name {
    font-weight: 600;
    color: var(--wc-text);
    font-size: .92rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    flex: 1;
}
.wc-col-head__producer {
    color: var(--wc-text-muted);
    font-size: .75rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wc-col-head__remove {
    border: 0; background: transparent;
    color: var(--wc-text-muted);
    cursor: pointer;
    width: 24px; height: 24px;
    border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    align-self: flex-start;
}
.wc-col-head__remove:hover { color: var(--wc-danger); background: rgba(239,68,68,.1); }
.wc-col-head__remove .material-icons-sharp { font-size: 1rem; }
.wc-col-head__winner {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    color: var(--wc-text-muted);
    cursor: pointer;
}
.wc-col-head__winner input { margin: 0; }

.wc-cell-empty { color: var(--wc-text-muted); opacity: .8; }

.wc-footnote {
    margin: 12px 0 0;
    padding: 8px 12px;
    font-size: 0.78rem;
    color: var(--wc-text-muted);
    background: var(--wc-surface-alt, rgba(0, 0, 0, 0.03));
    border-left: 3px solid var(--wc-border, rgba(0, 0, 0, 0.08));
    border-radius: 0 4px 4px 0;
    line-height: 1.4;
}

/* ── Save-as-note button states ─────────────────────────── */
.wc-modal__footer .wc-btn.is-loading,
.wc-modal__footer .wc-btn.is-success {
    pointer-events: none;
    cursor: default;
}
.wc-modal__footer .wc-btn.is-success {
    background: var(--wc-success);
    color: #ffffff;
    border-color: var(--wc-success);
}
.wc-modal__footer .wc-btn.is-success .material-icons-sharp { color: #ffffff; }

.wc-spin {
    display: inline-block;
    animation: wc-spin 0.85s linear infinite;
    transform-origin: 50% 50%;
}
@keyframes wc-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── "Saved as note" inline banner ──────────────────────── */
.wc-saved-banner {
    position: absolute;
    left: 50%;
    bottom: 80px; /* sits above the footer */
    transform: translate(-50%, 12px);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    max-width: min(560px, calc(100% - 32px));
    padding: 10px 14px;
    background: var(--wc-success);
    color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.28),
                0 2px 6px rgba(0, 0, 0, 0.12);
    font-size: 0.9rem;
    line-height: 1.25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.22s ease;
    z-index: 10;
}
.wc-saved-banner--visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}
.wc-saved-banner__icon { font-size: 1.25rem; flex-shrink: 0; }
.wc-saved-banner__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.wc-saved-banner__sub {
    font-size: 0.78rem;
    opacity: 0.86;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 380px;
}
.wc-saved-banner__cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 6px;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.wc-saved-banner__cta:hover,
.wc-saved-banner__cta:focus-visible {
    background: rgba(255, 255, 255, 0.32);
    outline: none;
}
.wc-saved-banner__cta .material-icons-sharp { font-size: 1rem; }

@media (max-width: 600px) {
    .wc-saved-banner {
        bottom: 96px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .wc-saved-banner__sub { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .wc-spin { animation: none; }
    .wc-saved-banner {
        transition: opacity 0.12s ease;
        transform: translate(-50%, 0);
    }
    .wc-saved-banner--visible { transform: translate(-50%, 0); }
}

/* ── Empty state inside modal ────────────────────────────── */
.wc-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--wc-text-muted);
}
.wc-empty .material-icons-sharp {
    font-size: 2.6rem;
    color: var(--wc-primary);
    opacity: .7;
}
.wc-empty h3 {
    margin: 10px 0 6px;
    color: var(--wc-text);
    font-size: 1.05rem;
}
.wc-empty p { font-size: .9rem; margin: 0 0 4px; }
.wc-empty kbd {
    background: var(--wc-primary-soft);
    color: var(--wc-primary);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .8em;
    font-family: inherit;
    font-weight: 600;
}

/* ── Footer buttons ──────────────────────────────────────── */
.wc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--wc-border);
    background: var(--wc-bg-elev);
    color: var(--wc-text);
    cursor: pointer;
    font: inherit;
    font-size: .85rem;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.wc-btn:hover { color: var(--wc-primary); border-color: rgba(13,148,136,.3); }
.wc-btn:disabled { opacity: .55; cursor: not-allowed; }
.wc-btn--primary {
    background: var(--wc-primary);
    border-color: var(--wc-primary);
    color: #fff;
}
.wc-btn--primary:hover { background: var(--wc-primary-strong); border-color: var(--wc-primary-strong); color: #fff; }
.wc-btn--danger {
    color: var(--wc-danger);
    border-color: rgba(239,68,68,.3);
}
.wc-btn--danger:hover { background: rgba(239,68,68,.08); }
.wc-btn .material-icons-sharp { font-size: 1.05rem; }

/* ── Body scroll lock when modal is open ─────────────────── */
body.wc-modal-open { overflow: hidden; }

/* ── Responsive (mobile) ─────────────────────────────────── */
@media (max-width: 768px) {
    .wc-modal__panel {
        top: 0;
        max-height: 100vh;
        height: 100vh;
        width: 100vw;
        border-radius: 0;
        border: 0;
    }
    body.rd-has-topbar .wc-modal__panel { top: 56px; height: calc(100vh - 56px); }
    .wc-table thead th.wc-th--label,
    .wc-table tbody th.wc-th-row {
        width: 120px;
        font-size: .8rem;
    }
    .wc-col-head__thumb { width: 44px; height: 44px; }
}

/* ── Print: keep page clean if user prints from compare modal ─ */
@media print {
    .wc-bar, .wc-attach { display: none !important; }
    .wc-modal__backdrop { display: none !important; }
    .wc-modal__panel {
        position: static !important;
        transform: none !important;
        box-shadow: none !important;
        max-height: none !important;
    }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .wc-bar,
    .wc-attach,
    .wc-modal,
    .wc-modal__panel,
    .wc-modal__backdrop,
    .wc-bar__thumb,
    .wc-btn {
        transition: none !important;
        animation: none !important;
    }
}
