/**
 * JerryTrades — Trading Setup Modal Styles
 *
 * Namespace: .tsm-   (Trading Setup Modal)
 * z-index: 10500 (above strategy wizard at 10000, below any system alerts)
 * Theme: matches app dark palette (#1e293b body, #0f172a inputs, #3b82f6 accent)
 *
 * @version 1.0
 */

/* ── Overlay ─────────────────────────────────────────────────────────────── */

.tsm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10500;
    padding: 1rem;
    animation: tsmFadeIn 0.2s ease-out;
}

@keyframes tsmFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal container ─────────────────────────────────────────────────────── */

.tsm-modal {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.55);
    animation: tsmSlideUp 0.25s ease-out;
    overflow: hidden;
}

@keyframes tsmSlideUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.tsm-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.tsm-header-text h3 {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
}

.tsm-header-text p {
    margin: 0;
    font-size: 0.82rem;
    color: #94a3b8;
    line-height: 1.4;
}

.tsm-close-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    line-height: 1;
    margin-left: 1rem;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.tsm-close-btn:hover {
    color: #f1f5f9;
    background: #334155;
}

/* ── Body ────────────────────────────────────────────────────────────────── */

.tsm-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── Section ─────────────────────────────────────────────────────────────── */

.tsm-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tsm-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

.tsm-section-desc {
    font-size: 0.82rem;
    color: #94a3b8;
    margin: -0.35rem 0 0;
    line-height: 1.4;
}

/* ── Year rows (Yahoo/ESPN prior years) ──────────────────────────────────── */

.tsm-year-row {
    display: grid;
    grid-template-columns: 3.5rem 1fr;
    align-items: center;
    gap: 0.75rem;
}

.tsm-year-label {
    font-size: 0.82rem;
    color: #cbd5e1;
    font-weight: 600;
    text-align: right;
}

.tsm-input {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 7px;
    color: #f1f5f9;
    font-size: 0.85rem;
    padding: 0.45rem 0.7rem;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
    font-family: inherit;
}

.tsm-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.tsm-input::placeholder {
    color: #475569;
}

/* ── Owner correction table ──────────────────────────────────────────────── */

.tsm-owner-table {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tsm-owner-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    transition: border-color 0.15s;
}

.tsm-owner-row:hover {
    border-color: #334155;
}

.tsm-owner-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.tsm-owner-team {
    font-size: 0.83rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tsm-owner-name {
    font-size: 0.75rem;
    color: #64748b;
}

.tsm-owner-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.tsm-owner-toggle label {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    cursor: pointer;
}

/* Custom checkbox */
.tsm-check {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid #475569;
    border-radius: 4px;
    background: #0f172a;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
}

.tsm-check:checked {
    background: #3b82f6;
    border-color: #3b82f6;
}

.tsm-check:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* ── General settings ────────────────────────────────────────────────────── */

.tsm-setting-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
}

.tsm-setting-label {
    font-size: 0.85rem;
    color: #cbd5e1;
}

.tsm-setting-sublabel {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.tsm-input-sm {
    width: 5rem;
    text-align: center;
}

/* ── Notice badge (auto-open prompt) ─────────────────────────────────────── */

.tsm-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    font-size: 0.82rem;
    color: #93c5fd;
    line-height: 1.4;
}

.tsm-notice-icon {
    flex-shrink: 0;
    font-size: 0.9rem;
    margin-top: 0.05rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.tsm-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #334155;
    flex-shrink: 0;
}

.tsm-btn {
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.2rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
}

.tsm-btn:active {
    transform: scale(0.97);
}

.tsm-btn-secondary {
    background: #334155;
    color: #cbd5e1;
}

.tsm-btn-secondary:hover {
    background: #475569;
}

.tsm-btn-primary {
    background: #3b82f6;
    color: #fff;
}

.tsm-btn-primary:hover {
    opacity: 0.88;
}

/* ── Gear button in Trade Finder header ──────────────────────────────────── */

.tf-setup-btn {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 7px;
    color: #94a3b8;
    font-size: 0.85rem;
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.tf-setup-btn:hover {
    color: #f1f5f9;
    border-color: #64748b;
    background: #334155;
}

.tf-setup-btn.has-data {
    border-color: #3b82f6;
    color: #60a5fa;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .tsm-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
    }

    .tsm-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .tsm-year-row {
        grid-template-columns: 3rem 1fr;
    }
}


/* ═══════════════════════════════════════════════════════════════════════════
   WHAT-IF SCENARIO MODAL  (wim-*)
   ═══════════════════════════════════════════════════════════════════════════ */

.wim-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10600;
    padding: 1rem;
    animation: tsmFadeIn 0.2s ease-out; /* reuse existing keyframe */
}

.wim-modal {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 80px rgba(0,0,0,0.55);
    animation: tsmSlideUp 0.25s ease-out;
    overflow: hidden;
}

/* ── Header ── */
.wim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem 0.9rem;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
    gap: 0.75rem;
}
.wim-header-left  { display: flex; align-items: center; gap: 0.75rem; }
.wim-header-icon  { font-size: 1.3rem; flex-shrink: 0; }
.wim-title        { font-size: 1rem; font-weight: 600; color: #f1f5f9; }
.wim-subtitle     { font-size: 0.75rem; color: #94a3b8; margin-top: 1px; }
.wim-close-btn {
    background: transparent; border: none; color: #64748b;
    font-size: 1rem; cursor: pointer; padding: 4px 6px;
    border-radius: 4px; line-height: 1; font-family: inherit;
    transition: color 0.15s;
}
.wim-close-btn:hover { color: #cbd5e1; }

/* ── Body ── */
.wim-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Section ── */
.wim-section { display: flex; flex-direction: column; gap: 0.5rem; }
.wim-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.wim-count {
    background: #312e81;
    color: #c7d2fe;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
}
.wim-hint {
    font-size: 0.68rem;
    font-weight: 400;
    color: #64748b;
    text-transform: none;
    letter-spacing: 0;
}
.wim-suggest-desc {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: -0.2rem;
}

/* ── Scenario chips ── */
.wim-scenarios-list,
.wim-suggest-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.wim-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid;
}
.wim-chip-saved   { background: #1a2234; border-color: #312e81; }
.wim-chip-suggest { background: #0f2018; border-color: #14532d; }

.wim-chip-pos {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    flex-shrink: 0;
    min-width: 24px;
    text-align: center;
}
.wim-pos-qb { background: #7f1d1d; color: #fca5a5; }
.wim-pos-rb { background: #14532d; color: #86efac; }
.wim-pos-wr { background: #1e3a8a; color: #93c5fd; }
.wim-pos-te { background: #7c2d12; color: #fdba74; }
.wim-pos-k, .wim-pos-def, .wim-pos-xx { background: #374151; color: #9ca3af; }

.wim-chip-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.wim-chip-name   { font-size: 0.82rem; font-weight: 600; color: #e2e8f0; }
.wim-chip-reason { font-size: 0.7rem; color: #94a3b8; }
.wim-chip-note   { font-size: 0.68rem; color: #64748b; font-style: italic; }

.wim-chip-remove, .wim-chip-add {
    background: transparent;
    border: 1px solid;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 6px;
    flex-shrink: 0;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.wim-chip-remove { border-color: #ef4444; color: #f87171; }
.wim-chip-remove:hover { background: #7f1d1d; color: #fca5a5; }
.wim-chip-add { border-color: #22c55e; color: #4ade80; }
.wim-chip-add:hover { background: #14532d; color: #86efac; }

/* ── Add form ── */
.wim-add-section { margin-top: 0.25rem; }
.wim-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.wim-select, .wim-input {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 7px;
    color: #e2e8f0;
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}
.wim-select:focus, .wim-input:focus { border-color: #7c3aed; }
.wim-input::placeholder { color: #475569; }
.wim-add-btn {
    align-self: flex-start;
    background: #1e3a8a;
    border: 1px solid #3b82f6;
    border-radius: 7px;
    color: #93c5fd;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
.wim-add-btn:hover { background: #1d4ed8; color: #bfdbfe; }

/* ── Empty state ── */
.wim-empty-state {
    text-align: center;
    padding: 1.5rem 1rem;
    color: #64748b;
}
.wim-empty-icon  { font-size: 2rem; margin-bottom: 0.5rem; }
.wim-empty-title { font-size: 0.9rem; font-weight: 600; color: #94a3b8; margin-bottom: 0.3rem; }
.wim-empty-desc  { font-size: 0.75rem; }

/* ── Footer ── */
.wim-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.4rem;
    border-top: 1px solid #334155;
    flex-shrink: 0;
}
.wim-footer-hint {
    font-size: 0.72rem;
    color: #64748b;
    flex: 1;
    line-height: 1.4;
}
.wim-done-btn {
    background: #7c3aed;
    border: none;
    border-radius: 7px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.45rem 1.2rem;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
    transition: opacity 0.15s;
}
.wim-done-btn:hover { opacity: 0.85; }

/* ── Context bar button states ── */
.whatif-btn.has-scenarios {
    border-color: rgba(167, 139, 250, 0.5);
    color: #a78bfa;
}
.whatif-btn.has-scenarios:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: #7c3aed;
    color: #c4b5fd;
}
.badge-whatif {
    background: #7c3aed;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

/* ── Mobile adjustments ── */
@media (max-width: 500px) {
    .wim-modal { max-height: 95vh; border-radius: 10px; }
    .wim-header { padding: 0.9rem 1rem 0.75rem; }
    .wim-body   { padding: 0.75rem 1rem; }
    .wim-footer { padding: 0.75rem 1rem; flex-direction: column; align-items: stretch; }
    .wim-done-btn { text-align: center; }
}

/* Chip actions group (edit + remove) */
.wim-chip-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-items: center;
}
/* Edit button — purple accent */
.wim-chip-edit {
    background: transparent;
    border: 1px solid #7c3aed;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 5px;
    color: #a78bfa;
    flex-shrink: 0;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}
.wim-chip-edit:hover { background: #3b0764; color: #c4b5fd; }

/* "Add all" button in suggestions section header */
.wim-add-all-btn {
    margin-left: auto;
    background: transparent;
    border: 1px solid #22c55e;
    border-radius: 5px;
    color: #4ade80;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    white-space: nowrap;
}
.wim-add-all-btn:hover { background: #14532d; color: #86efac; }

/* ── Email-identity flag rows ─────────────────────────────────────────────── */
/* Shown when the engine detects a possible email-only identity change         */
/* (same owner name, different email address across years)                     */

/* Flagged row — amber left border to draw attention */
.tsm-owner-row--flagged {
    border-color: #d97706;
    background: #0f1e0a;
    grid-template-columns: 1fr auto;
    align-items: flex-start;
    padding: 0.75rem;
}

.tsm-owner-row--flagged:hover {
    border-color: #f59e0b;
}

/* Team name + badge on one line */
.tsm-owner-team-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* ⚠ Email changed badge */
.tsm-email-flag-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}

/* Email address detail lines */
.tsm-email-flag-detail {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-top: 0.2rem;
    flex-wrap: wrap;
}

.tsm-email-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tsm-email-value {
    font-size: 0.7rem;
    color: #93c5fd;   /* current emails — blue */
    font-family: 'SF Mono', 'Fira Code', monospace;
    word-break: break-all;
}

.tsm-email-prior {
    color: #94a3b8;   /* prior emails — muted grey */
}

/* "Same person or new owner?" prompt */
.tsm-email-flag-question {
    font-size: 0.72rem;
    color: #fbbf24;
    margin: 0.5rem 0 0;
    font-weight: 500;
}

/* Action buttons column */
.tsm-email-flag-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-shrink: 0;
    padding-top: 0.1rem;
}

/* Base button style for both choices */
.tsm-email-btn {
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1.5px solid transparent;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    background: transparent;
}

/* "Same Person" — green tint */
.tsm-email-btn--same {
    border-color: #16a34a;
    color: #4ade80;
}
.tsm-email-btn--same:hover {
    background: rgba(22, 163, 74, 0.18);
    border-color: #4ade80;
}

/* "New Owner" — red-muted tint */
.tsm-email-btn--diff {
    border-color: #475569;
    color: #94a3b8;
}
.tsm-email-btn--diff:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: #f87171;
    color: #fca5a5;
}

/* ── Confirmed state (compressed) ────────────────────────────────────────── */

.tsm-owner-row--confirmed {
    grid-template-columns: 1fr auto;
    align-items: center;
    opacity: 0.85;
}

.tsm-email-confirmed {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.tsm-email-confirmed-label {
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Same person confirmed — green text */
.tsm-email-confirmed--same .tsm-email-confirmed-label {
    color: #4ade80;
}

/* Different owner confirmed — muted */
.tsm-email-confirmed--diff .tsm-email-confirmed-label {
    color: #94a3b8;
}

/* "Edit" link to change the decision */
.tsm-email-edit-btn {
    font-size: 0.65rem;
    color: #60a5fa;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    flex-shrink: 0;
}
.tsm-email-edit-btn:hover {
    color: #93c5fd;
}
