/* ==========================================================================
   ToolCMB — Cookie consent (banner + preferences dialog)
   Uses the site design tokens when present (style.css), with fallbacks so it
   also looks right on any tool page. Light + dark ([data-theme="dark"]).
   ========================================================================== */

.cmb-banner, .cmb-modal {
    --cmb-bg: var(--surface, #FFFFFF);
    --cmb-bg-2: var(--surface-2, #F1F5F9);
    --cmb-text: var(--text, #0F172A);
    --cmb-muted: var(--muted, #64748B);
    --cmb-border: var(--border, #E2E8F0);
    --cmb-primary: var(--primary, #06B6D4);
    --cmb-primary-dark: var(--primary-dark, #0891B2);
    --cmb-link: var(--link, #0891B2);
    --cmb-navy: var(--navy, #0F172A);
    font-family: var(--font, "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
    color: var(--cmb-text);
    line-height: 1.55;
    box-sizing: border-box;
}
[data-theme="dark"] .cmb-banner, [data-theme="dark"] .cmb-modal {
    --cmb-bg: var(--surface, #111A2E);
    --cmb-bg-2: var(--surface-2, #16213A);
    --cmb-text: var(--text, #E2E8F0);
    --cmb-muted: var(--muted, #94A3B8);
    --cmb-border: var(--border, #1E293B);
    --cmb-link: var(--link, #22D3EE);
}
.cmb-banner *, .cmb-modal * { box-sizing: border-box; }

/* ---------- Banner ------------------------------------------------------ */
.cmb-banner {
    position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 2147483000;
    max-width: 1080px; margin: 0 auto; padding: 20px 22px;
    display: flex; align-items: center; gap: 20px 28px;
    background: var(--cmb-bg); border: 1px solid var(--cmb-border); border-radius: 18px;
    box-shadow: 0 24px 60px -16px rgba(15, 23, 42, .35), 0 2px 6px rgba(15, 23, 42, .06);
    opacity: 0; transform: translateY(24px); transition: opacity .25s ease, transform .25s ease;
}
.cmb-banner.is-in { opacity: 1; transform: none; }
.cmb-banner-body { display: flex; gap: 14px; flex: 1; min-width: 0; }
.cmb-icon { font-size: 28px; line-height: 1; flex: none; }
.cmb-title { margin: 0 0 4px; font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; color: var(--cmb-text); }
.cmb-text { margin: 0; font-size: .9rem; color: var(--cmb-muted); }
.cmb-links { font-size: .85rem; white-space: nowrap; }
.cmb-banner a, .cmb-modal a { color: var(--cmb-link); text-decoration: underline; text-underline-offset: 2px; }
.cmb-gpc { display: block; margin-top: 4px; font-size: .82rem; color: var(--cmb-text); }
.cmb-actions { display: flex; gap: 10px; flex: none; }

.cmb-btn {
    display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 18px;
    border-radius: 999px; border: 1px solid transparent; font: inherit; font-size: .9rem; font-weight: 650;
    cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s;
}
.cmb-btn:focus-visible, .cmb-close:focus-visible, .cmb-footer-link:focus-visible { outline: 3px solid rgba(6, 182, 212, .45); outline-offset: 2px; }
/* Accept and Reject have equal weight (EDPB guidance: no dark patterns) */
.cmb-btn-primary { background: var(--cmb-navy); color: #fff; }
.cmb-btn-primary:hover { background: #1E293B; }
[data-theme="dark"] .cmb-btn-primary { background: var(--cmb-primary); color: #0F172A; }
[data-theme="dark"] .cmb-btn-primary:hover { background: #22D3EE; }
.cmb-btn-outline { background: transparent; color: var(--cmb-text); border-color: var(--cmb-text); }
.cmb-btn-outline:hover { background: var(--cmb-bg-2); }
.cmb-btn-ghost { background: transparent; color: var(--cmb-link); border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.cmb-btn-ghost:hover { background: var(--cmb-bg-2); }

/* ---------- Dialog ------------------------------------------------------ */
.cmb-lock, .cmb-lock body { overflow: hidden; }
.cmb-modal { position: fixed; inset: 0; z-index: 2147483001; display: flex; align-items: center; justify-content: center; padding: 16px; }
.cmb-modal[hidden] { display: none; }
.cmb-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .6); backdrop-filter: blur(3px); }
.cmb-dialog {
    position: relative; display: flex; flex-direction: column; width: 100%; max-width: 620px; max-height: calc(100vh - 32px);
    background: var(--cmb-bg); border: 1px solid var(--cmb-border); border-radius: 20px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); animation: cmb-pop .22s ease;
}
.cmb-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--cmb-border); }
.cmb-modal-head h2 { margin: 0; font-size: 1.15rem; font-weight: 750; color: var(--cmb-text); }
.cmb-close { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--cmb-border); background: transparent; color: var(--cmb-text); font-size: 22px; line-height: 1; cursor: pointer; }
.cmb-close:hover { background: var(--cmb-bg-2); }
.cmb-modal-body { padding: 18px 22px; overflow-y: auto; display: grid; gap: 12px; }
.cmb-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(6, 182, 212, .1); font-size: .85rem; color: var(--cmb-text); }
.cmb-cat { padding: 14px 16px; border: 1px solid var(--cmb-border); border-radius: 14px; background: var(--cmb-bg-2); }
.cmb-cat.is-disabled { opacity: .6; }
.cmb-cat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cmb-cat-title { font-weight: 650; cursor: pointer; }
.cmb-cat.is-locked .cmb-cat-title::after { content: "Always on"; margin-left: 8px; padding: 2px 8px; border-radius: 99px; background: rgba(5, 150, 105, .12); color: #059669; font-size: .72rem; font-weight: 700; }
.cmb-cat-desc { margin: 6px 0 0; font-size: .86rem; color: var(--cmb-muted); }
.cmb-modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--cmb-border); }

.cmb-switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.cmb-switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.cmb-switch input:disabled { cursor: not-allowed; }
.cmb-switch-ui { width: 44px; height: 26px; border-radius: 99px; background: #CBD5E1; position: relative; transition: background .2s; }
.cmb-switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.cmb-switch input:checked + .cmb-switch-ui { background: var(--cmb-primary); }
.cmb-switch input:checked + .cmb-switch-ui::after { transform: translateX(18px); }
.cmb-switch input:focus-visible + .cmb-switch-ui { box-shadow: 0 0 0 3px rgba(6, 182, 212, .45); }
.cmb-cat.is-locked .cmb-switch-ui { background: #10B981; opacity: .7; }
.cmb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Footer link ------------------------------------------------- */
.cmb-footer-link {
    padding: 0; border: 0; background: none; font: inherit; font-size: inherit; color: inherit;
    text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.cmb-footer-link:hover { color: var(--link, #0891B2); }
.cmb-footer-links { margin: 0; }

@keyframes cmb-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

@media (max-width: 860px) {
    .cmb-banner { flex-direction: column; align-items: stretch; left: 10px; right: 10px; bottom: 10px; padding: 18px; }
    .cmb-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .cmb-actions .cmb-btn-ghost { grid-column: 1 / -1; order: 3; }
    .cmb-links { white-space: normal; }
}
@media (max-width: 480px) {
    .cmb-icon { display: none; }
    .cmb-modal { padding: 0; align-items: flex-end; }
    .cmb-dialog { max-height: 92vh; border-radius: 20px 20px 0 0; }
    .cmb-modal-foot .cmb-btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .cmb-banner, .cmb-dialog { transition: none; animation: none; }
}
@media print { .cmb-banner, .cmb-modal { display: none !important; } }
