/* ============================================
   Duplicate Warning Popup — Themed
   Matches the app's clean, modern design system.
   ============================================ */

.duplicate-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 16px;
}

.duplicate-overlay.show {
    opacity: 1;
}

.duplicate-popup {
    background: var(--bg-card, #ffffff);
    border-radius: 16px;
    max-width: 480px;
    width: 94%;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border, #e2e8f0);
    /* The card is a COLUMN that never grows past the viewport. Without this the
       bulk confirm (one warning block per repeated row + the destination ticks)
       grew taller than the screen, `overflow: hidden` clipped it, and the
        Confirm / Cancel buttons were unreachable — reported 2026-11-14 (“could
        not scroll up and down far enough to confirm or cancel”). */
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
}

.duplicate-overlay.show .duplicate-popup {
    transform: scale(1) translateY(0);
}

/* Header */
.dup-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 24px;
    background: var(--bg-warning, #fef3c7);
    border-bottom: 3px solid var(--warning, #f59e0b);
    /* The coloured band stays put while the body scrolls. */
    flex: 0 0 auto;
}

.dup-icon {
    font-size: 24px;
    line-height: 1;
}

.dup-title {
    flex: 1;
    font-size: 17px;
    line-height: 1.35;
    font-weight: 700;
    /* The heading is COLOURED: amber while the card carries a warning, green when
       it is only confirming a destination (`.dup-header.is-ok`, below). The BAND
       behind it is coloured to match — that is what makes the two cards read as
       one family (asked 2026-10-28). */
    color: #92400e;
}

/* The X: the same red circle as the app's own dialogs (`.modal-close` in
   design.css), so every popup closes with the same control (asked 2026-10-28). */
.dup-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, transform .15s;
}

.dup-close:hover {
    background: #dc2626;
    transform: scale(1.08);
}

.dup-close:active {
    transform: scale(.96);
}

/* Body */
.dup-body {
    padding: 24px;
    /* The ONE scrolling region of the card. `min-height: 0` is what lets a
       flex child actually shrink below its content and scroll. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.dup-message {
    font-size: 15px;
    color: var(--text-2, #334155);
    margin: 0 0 16px 0;
    line-height: 1.6;
}

.dup-message strong {
    color: var(--text, #0f172a);
}

.dup-timer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-accent-soft, #eef2ff);
    border-radius: 10px;
    margin-bottom: 16px;
}

.dup-timer .timer-icon {
    font-size: 18px;
}

.dup-timer .timer-text {
    font-size: 14px;
    color: var(--text, #0f172a);
}

.dup-timer .timer-text strong {
    color: var(--accent, #6366f1);
}

.dup-note {
    font-size: 13px;
    color: var(--text-3, #64748b);
    margin: 0 0 20px 0;
    line-height: 1.5;
    padding: 8px 12px;
    background: var(--bg-2, #f1f5f9);
    border-radius: 8px;
}

/* ---- The warning INSIDE the confirm dialog (window.buildDuplicateNotice) ----
   One dialog instead of two: the same card, the same yellow header, the same
   blue timer and grey note, with the destinations ticked underneath. */
.dup-notice { margin-bottom: 4px; }
.dup-notice .dup-message { margin: 0 0 12px 0; }
.dup-notice .dup-note { margin-bottom: 14px; }
.dup-notice + .dup-notice {
    border-top: 1px solid var(--border, #e2e8f0);
    padding-top: 14px;
}
.dup-row {
    margin: 0 0 6px 0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .02em;
    color: var(--text-3, #64748b);
    text-transform: uppercase;
}
/* The dialog's own parts, in the popup's palette. */
.dup-confirm-body { margin: 0; }
.dup-lead {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--text-2, #334155);
}
.dup-dests { margin: 0 0 14px 0; padding: 0; list-style: none; }
.dup-dests > li { margin: 0 0 8px 0; }
.dup-dests > li:last-child { margin-bottom: 0; }
.dup-dest {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; color: var(--text, #0f172a);
    cursor: pointer;
}
.dup-dest input[type="checkbox"] {
    flex: none; width: 18px; height: 18px; margin: 0;
    cursor: pointer; accent-color: #22c55e;
}
.dup-sub {
    margin: 0; font-size: 12.5px; line-height: 1.5;
    color: var(--text-3, #64748b);
}
/* Nothing to warn about (a plain confirm, or the repeated channel unticked): the
   header keeps its COLOURED BAND, in green instead of amber, so every confirm
   card looks like the same design (asked 2026-10-28). */
.dup-header.is-ok {
    background: #dcfce7;
    border-bottom: 3px solid #22c55e;
}
.dup-header.is-ok .dup-title {
    color: #15803d;
}

/* Actions */
.dup-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    /* Pinned to the bottom of the scrolling body, so Confirm / Cancel are
       reachable even when the warnings above them are long. */
    position: sticky;
    bottom: 0;
    margin-top: 12px;
    padding-top: 12px;
    background: var(--bg-card, #ffffff);
}

.dup-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dup-btn-primary {
    background: var(--accent, #6366f1);
    color: #fff;
}

.dup-btn-primary:hover {
    background: var(--accent-hover, #4f46e5);
    transform: translateY(-1px);
}

.dup-btn-secondary {
    background: var(--bg-2, #f1f5f9);
    color: var(--text-2, #334155);
}

.dup-btn-secondary:hover {
    background: var(--bg-3, #e2e8f0);
}

/* Dark theme support */
[data-theme="dark"] .duplicate-popup {
    background: var(--bg-card, #1a1a2e);
    border-color: var(--border, #2a2a3e);
}

[data-theme="dark"] .dup-header {
    background: var(--bg-warning-dark, #2d1f00);
    border-bottom-color: var(--warning, #f59e0b);
}

[data-theme="dark"] .dup-header.is-ok {
    background: #052e16;
    border-bottom-color: #22c55e;
}

[data-theme="dark"] .dup-title {
    color: var(--text, #f1f5f9);
}

[data-theme="dark"] .dup-header.is-ok .dup-title {
    color: #86efac;
}

[data-theme="dark"] .dup-message {
    color: var(--text-2, #cbd5e1);
}

[data-theme="dark"] .dup-message strong {
    color: var(--text, #f1f5f9);
}

[data-theme="dark"] .dup-timer {
    background: var(--bg-accent-soft-dark, #1e1e3a);
}

[data-theme="dark"] .dup-timer .timer-text {
    color: var(--text, #f1f5f9);
}

[data-theme="dark"] .dup-note {
    background: var(--bg-2-dark, #1e1e2e);
    color: var(--text-3, #94a3b8);
}

[data-theme="dark"] .dup-btn-secondary {
    background: var(--bg-2-dark, #1e1e2e);
    color: var(--text-2, #cbd5e1);
}

[data-theme="dark"] .dup-btn-secondary:hover {
    background: var(--bg-3-dark, #2a2a3e);
}

/* Mobile */
@media (max-width: 480px) {
    .duplicate-popup {
        width: 96%;
        margin: 8px;
        max-width: none;
    }

    .dup-header {
        padding: 14px 18px;
    }

    .dup-body {
        padding: 18px;
    }

    .dup-title {
        font-size: 15px;
    }

    .dup-btn {
        font-size: 13px;
        padding: 12px 16px;
    }

    .dup-actions {
        flex-direction: column;
    }
}
