/* Coinbase Watcher lab — whale-alert notification feed.
   Mobile-first; uses global tokens from css/styles.css with a teal
   "whale" accent that is intentionally module-local. */

.coinbase-watcher {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
}

/* ── Banner zone (JS-populated) ────────────────────────────── */

.coinbase-watcher-banner-zone:empty {
    display: none;
}

.coinbase-watcher-banner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #e3f4fa, #ffffff);
    border: 1px solid #36a7c9;
    border-radius: 12px;
    padding: 12px 40px 12px 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(54, 167, 201, 0.2);
    animation: coinbase-watcher-slide-in 220ms ease-out;
}

@keyframes coinbase-watcher-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.coinbase-watcher-banner-body {
    flex: 1;
    min-width: 0;
}

.coinbase-watcher-banner-title {
    font-weight: 700;
    color: #0a6e8c;
    margin: 0 0 2px;
    font-size: 0.95rem;
}

.coinbase-watcher-banner-value {
    color: var(--text-primary, #2a2d30);
    margin: 0;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.coinbase-watcher-banner-dismiss {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    color: #0a6e8c;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    border-radius: 6px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coinbase-watcher-banner-dismiss:hover,
.coinbase-watcher-banner-dismiss:focus {
    background: rgba(54, 167, 201, 0.2);
}

/* ── Intro ─────────────────────────────────────────────────── */

.coinbase-watcher-intro {
    max-width: 820px;
    margin: 0 0 1.25rem;
    line-height: 1.6;
}

/* ── Control chips ─────────────────────────────────────────── */

.coinbase-watcher-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.coinbase-watcher-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 38px;
    padding: 0 14px;
    box-sizing: border-box;
    width: auto;                            /* defeat global form 300px */
    background: #ffffff;
    color: var(--text-primary, #2a2d30);
    border: 1px solid var(--border-soft, #dcdfe6);
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    transition: background 0.12s ease, color 0.12s ease,
                border-color 0.12s ease, box-shadow 0.12s ease;
}

.coinbase-watcher-chip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
}

.coinbase-watcher-chip-link {
    color: #0a7ea4;
    border-color: #0a7ea4;
}

.coinbase-watcher-chip-link:hover,
.coinbase-watcher-chip-link:focus {
    background: #0a7ea4;
    color: #ffffff;
}

.coinbase-watcher-chip-hint {
    color: var(--text-secondary, #555);
    font-weight: 500;
    cursor: default;
    font-style: italic;
}

.coinbase-watcher-chip-toggle {
    user-select: none;
}

.coinbase-watcher-chip-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #0a7ea4;
}

.coinbase-watcher-chip-toggle:has(input:checked) {
    background: #e3f4fa;
    border-color: #0a7ea4;
    color: #0a6e8c;
}

.coinbase-watcher-chip-action {
    background: #0a7ea4;
    color: #ffffff;
    border-color: #0a7ea4;
    box-shadow: 0 1px 2px rgba(10, 126, 164, 0.2);
}

.coinbase-watcher-chip-action:hover,
.coinbase-watcher-chip-action:focus {
    background: #086580;
    border-color: #086580;
}

.coinbase-watcher-chip-action:active {
    transform: translateY(1px);
}

/* ── Summary bar ───────────────────────────────────────────── */

.coinbase-watcher-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: #e3f4fa;
    border-radius: 10px;
}

.coinbase-watcher-summary-stat {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.coinbase-watcher-summary-num {
    font-size: 1.6rem;
    font-weight: 700;
    color: #0a7ea4;
    line-height: 1;
}

.coinbase-watcher-summary-num.coinbase-watcher-last {
    font-size: 1.15rem;
}

.coinbase-watcher-summary-label {
    color: var(--text-secondary, #555);
    font-size: 0.9rem;
}

.coinbase-watcher-summary-status {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    white-space: nowrap;
}

.coinbase-watcher-summary-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.coinbase-watcher-summary-status-age {
    font-weight: 500;
    opacity: 0.85;
}

.coinbase-watcher-summary-status.is-fresh {
    color: #2a7a3a;
    background: #e2faea;
    border-color: #9be0b0;
}

.coinbase-watcher-summary-status.is-slow {
    color: #8a6500;
    background: #fff7d6;
    border-color: #ead27a;
}

.coinbase-watcher-summary-status.is-delayed {
    color: #9a4400;
    background: #fff0dc;
    border-color: #ffc88a;
}

.coinbase-watcher-summary-status.is-offline {
    color: #a02323;
    background: #fde5e5;
    border-color: #f0a8a8;
}

/* ── Empty state ───────────────────────────────────────────── */

.coinbase-watcher-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary, #555);
}

.coinbase-watcher-empty h2 {
    margin: 0 0 0.5rem;
    color: var(--text-primary, #2a2d30);
}

.coinbase-watcher-empty p {
    margin: 0 auto;
    max-width: 480px;
    line-height: 1.5;
}

/* ── Whale feed ────────────────────────────────────────────── */

.coinbase-watcher-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.coinbase-watcher-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #ffffff;
    border: 1px solid var(--border-soft, #dcdfe6);
    border-left: 4px solid #0a7ea4;
    border-radius: 10px;
    padding: 12px 14px;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.coinbase-watcher-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(10, 126, 164, 0.16);
}

.coinbase-watcher-card-head {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.coinbase-watcher-card-age {
    color: var(--text-secondary, #777);
    font-size: 0.78rem;
}

.coinbase-watcher-card-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary, #2a2d30);
}

.coinbase-watcher-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

/* Exact UTC 5-minute candle the detection referenced — lines up with the
   UTC Coinbase chart the card links to. */
.coinbase-watcher-card-candle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #0a6e8c;
    background: #e3f4fa;
    border-radius: 6px;
    padding: 2px 8px;
    font-variant-numeric: tabular-nums;
}

.coinbase-watcher-card-notify {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary, #777);
    white-space: nowrap;
}

.coinbase-watcher-card-notify.is-emailed  { color: #2a7a3a; }
.coinbase-watcher-card-notify.is-cooldown { color: #8a6500; }

.coinbase-watcher-card-detail {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-secondary, #555);
}

/* ── Modal overlay (used for the thresholds reference) ────── */

.coinbase-watcher-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 30, 45, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    z-index: 9000;
    overflow-y: auto;
}

.coinbase-watcher-modal-overlay[hidden] {
    display: none;
}

.coinbase-watcher-modal {
    position: relative;
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
    /* Focused on open; the outline is suppressed below since the modal is
       not a typical interactive control and the dim overlay already signals
       "you are in a dialog". */
    outline: none;
}

.coinbase-watcher-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary, #555);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coinbase-watcher-modal-close:hover,
.coinbase-watcher-modal-close:focus-visible {
    background: var(--bg-surface-alt, #f5f7fa);
    color: var(--text-primary, #2a2d30);
}

/* Leave room on the right of the title so it doesn't crowd the × button. */
.coinbase-watcher-modal .coinbase-watcher-thresholds-title {
    margin: 0 2.25rem 0.35rem 0;
}

/* "View older" modal title -- same right gutter as the thresholds title. */
.coinbase-watcher-modal .coinbase-watcher-older-title {
    margin: 0 2.25rem 1rem 0;
}

/* ── Thresholds reference (rendered inside the modal) ───── */

.coinbase-watcher-thresholds {
    margin-top: 0;
    border-top: none;
}

.coinbase-watcher-thresholds-title {
    margin: 0 0 0.35rem;
}

.coinbase-watcher-thresholds-intro {
    margin: 0 0 1.25rem;
    color: var(--text-secondary, #555);
    line-height: 1.5;
}

.coinbase-watcher-group {
    margin-bottom: 1.5rem;
}

.coinbase-watcher-group-title {
    margin-bottom: 0.5rem;
}

.coinbase-watcher-table {
    width: 100%;
    border-collapse: collapse;
}

.coinbase-watcher-table th,
.coinbase-watcher-table td {
    padding: 8px 10px;
    border: 1px solid var(--border, #dcdfe6);
    text-align: left;
    vertical-align: top;
}

.coinbase-watcher-table th {
    background: var(--bg-surface-alt, #f5f7fa);
    color: var(--text-primary, #2a2d30);
}

.coinbase-watcher-table td:first-child {
    white-space: nowrap;
    width: 1%;
}

.coinbase-watcher-table code {
    font-size: 0.85rem;
}

/* ── Mobile (≤720px) ───────────────────────────────────────── */

@media (max-width: 720px) {
    .coinbase-watcher {
        padding: 0.75rem 0.75rem 2rem;
    }

    .coinbase-watcher-controls {
        gap: 0.45rem;
        margin-bottom: 1rem;
    }

    .coinbase-watcher-chip {
        height: 34px;
        padding: 0 11px;
        font-size: 0.82rem;
        gap: 0.4rem;
    }

    .coinbase-watcher-summary {
        gap: 0.75rem;
        padding: 0.5rem 0.7rem;
        margin-bottom: 0.85rem;
    }

    .coinbase-watcher-summary-num {
        font-size: 1.2rem;
    }

    .coinbase-watcher-summary-num.coinbase-watcher-last {
        font-size: 0.95rem;
    }

    .coinbase-watcher-summary-status {
        font-size: 0.72rem;
        padding: 3px 8px;
    }

    .coinbase-watcher-feed {
        grid-template-columns: 1fr;
    }

    /* Threshold table → labelled cards. box-sizing before width+padding so
       padding doesn't overflow the viewport. */
    .coinbase-watcher-table,
    .coinbase-watcher-table thead,
    .coinbase-watcher-table tbody,
    .coinbase-watcher-table tr,
    .coinbase-watcher-table td {
        box-sizing: border-box;
        display: block;
        width: 100%;
    }

    .coinbase-watcher-table thead {
        display: none;
    }

    .coinbase-watcher-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--border, #dcdfe6);
    }

    .coinbase-watcher-table td {
        border: none;
        border-bottom: 1px solid var(--border, #dcdfe6);
        white-space: normal;
    }

    .coinbase-watcher-table td:last-child {
        border-bottom: none;
    }

    .coinbase-watcher-table td::before {
        content: attr(data-label) ": ";
        font-weight: 700;
        display: block;
    }

    .coinbase-watcher-my-alerts {
        padding: 0.85rem;
    }

    .coinbase-watcher-rules,
    .coinbase-watcher-my-matches {
        grid-template-columns: 1fr;
    }

    .coinbase-watcher-modal-overlay {
        padding: 0.5rem;
        align-items: flex-start;
    }

    .coinbase-watcher-modal {
        padding: 1rem 0.85rem 1.25rem;
        max-height: 95vh;
        border-radius: 10px;
    }
}

/* ── My Custom Alerts panel (logged-in only) ───────────────── */

.coinbase-watcher-my-alerts {
    margin-top: 2rem;
    padding: 1.25rem;
    background: #f5fbfd;
    border: 1px solid var(--border-soft, #dcdfe6);
    border-radius: 12px;
}

.coinbase-watcher-my-alerts-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.coinbase-watcher-my-alerts-title {
    margin: 0;
    color: #0a6e8c;
}

.coinbase-watcher-my-alerts-intro {
    margin: 0 0 1rem;
    color: var(--text-secondary, #555);
    line-height: 1.5;
}

.coinbase-watcher-rule-form {
    background: #ffffff;
    border: 1px solid var(--border-soft, #dcdfe6);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 1rem;
    width: auto;                       /* defeat global form 300px */
}

.coinbase-watcher-rule-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 14px;
    margin-bottom: 12px;
}

.coinbase-watcher-rule-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--text-secondary, #555);
}

.coinbase-watcher-rule-form input[type="text"],
.coinbase-watcher-rule-form input[type="number"],
.coinbase-watcher-rule-form select {
    box-sizing: border-box;
    width: 100%;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--border, #dcdfe6);
    border-radius: 6px;
    background: #ffffff;
    font-family: inherit;
    font-size: 0.9rem;
}

/* Both checkbox toggles live in one grid cell side-by-side so "Enabled"
   and "Email me" never wrap apart at any container width. */
.coinbase-watcher-rule-form-checks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.coinbase-watcher-rule-form-check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-primary, #2a2d30);
    cursor: pointer;
}

.coinbase-watcher-rule-form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #0a7ea4;
}

.coinbase-watcher-rule-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.coinbase-watcher-rule-form-actions .coinbase-watcher-chip {
    height: 32px;
    padding: 0 14px;
    font-size: 0.85rem;
}

.coinbase-watcher-rule-form-error {
    color: #a02323;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
}

.coinbase-watcher-rule-form-error:empty {
    display: none;
}

.coinbase-watcher-rules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
}

.coinbase-watcher-rule {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #ffffff;
    border: 1px solid var(--border-soft, #dcdfe6);
    border-left: 4px solid #0a7ea4;
    border-radius: 10px;
    padding: 10px 12px;
}

.coinbase-watcher-rule.is-disabled {
    border-left-color: #b0b8c1;
    opacity: 0.72;
}

.coinbase-watcher-rule-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.coinbase-watcher-rule-label {
    font-weight: 700;
    color: var(--text-primary, #2a2d30);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.coinbase-watcher-rule-range {
    background: #0a7ea4;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.coinbase-watcher-rule-meta {
    font-size: 0.82rem;
    color: var(--text-secondary, #555);
}

.coinbase-watcher-rule-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.coinbase-watcher-rule-actions button {
    width: auto;
    height: 26px;
    padding: 0 12px;
    border: 1px solid var(--border, #dcdfe6);
    background: #ffffff;
    color: var(--text-primary, #2a2d30);   /* defeat global button {color: #fff} */
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.coinbase-watcher-rule-actions button:hover {
    background: #f0f4f7;
}

.coinbase-watcher-rule-actions button.is-danger {
    color: #a02323;
    border-color: #f0a8a8;
}

.coinbase-watcher-rule-actions button.is-danger:hover {
    background: #fde5e5;
}

.coinbase-watcher-rules-empty,
.coinbase-watcher-my-matches-empty {
    grid-column: 1 / -1;
    padding: 0.9rem;
    text-align: center;
    color: var(--text-secondary, #777);
    font-style: italic;
}

.coinbase-watcher-my-matches-title {
    margin: 0 0 0.5rem;
    color: var(--text-primary, #2a2d30);
}

.coinbase-watcher-my-matches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.coinbase-watcher-my-match {
    position: relative;                 /* anchors the top-right × remove btn */
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #ffffff;
    border: 1px solid var(--border-soft, #dcdfe6);
    border-left: 4px solid #0a7ea4;
    border-radius: 10px;
    padding: 10px 38px 10px 12px;       /* right gutter clears the × */
    font-size: 0.86rem;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Per-card remove (×), top-right absolute. Group card clears the whole
   rule+coin cluster; modal card removes the single match. stopPropagation in
   JS keeps it from triggering the card's link. */
.coinbase-watcher-my-match-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary, #777);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
}

.coinbase-watcher-my-match-remove:hover,
.coinbase-watcher-my-match-remove:focus-visible {
    background: #fde5e5;
    color: #a02323;
}

/* "View N older" chip -- opens the group-history modal. width:auto defeats
   the global form/button 300px trap. */
.coinbase-watcher-my-match-more {
    align-self: flex-start;
    width: auto;
    margin: 2px 0 0;
    padding: 3px 10px;
    background: #e3f4fa;
    color: #0a6e8c;
    border: 1px solid #b6e1ee;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.coinbase-watcher-my-match-more:hover,
.coinbase-watcher-my-match-more:focus-visible {
    background: #d2ecf5;
}

.coinbase-watcher-my-match:hover,
.coinbase-watcher-my-match:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(10, 126, 164, 0.16);
}

.coinbase-watcher-my-pagination {
    margin-top: 12px;
}

.coinbase-watcher-my-match-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.coinbase-watcher-my-match-rule {
    font-weight: 700;
    color: #0a6e8c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.coinbase-watcher-my-match-age {
    color: var(--text-secondary, #777);
    font-size: 0.78rem;
    flex-shrink: 0;
}

.coinbase-watcher-my-match-value {
    font-weight: 600;
    color: var(--text-primary, #2a2d30);
}

.coinbase-watcher-my-match-detail {
    color: var(--text-secondary, #555);
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
}
