/* ===== Medusa Japan Design System ===== */
/* Monochromatic palette with gold accent (#C9A84C) */
/* Typography: Inter + system fallbacks, medium weight headings */

/* ===== CSS Variables (Light Theme) ===== */
:root {
    --bg-body: #FAFAFA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1B1B1B;
    --bg-header: #FFFFFF;
    --bg-table-header: #F5F5F5;
    --bg-hover: #F5F5F5;
    --bg-input: #F3F3F5;
    --bg-modal: #FFFFFF;
    --text-primary: #1B1B1B;
    --text-muted: #5C5C5C;
    --text-label: #2C2C2C;
    --text-empty: #4A4A4A;
    --link-color: #C9A84C;
    --border-color: #D4D4D4;
    --border-input: #D4D4D4;
    --btn-primary-bg: #1B1B1B;
    --btn-primary-hover: #333333;
    --btn-primary-color: #FFFFFF;
    --btn-secondary-bg: #F3F3F5;
    --btn-secondary-color: #1B1B1B;
    --btn-secondary-hover: #E5E5E7;
    --btn-outline-border: #D4D4D4;
    --btn-outline-color: #5C5C5C;
    --badge-draft-bg: #ECECF0;
    --badge-draft-color: #717182;
    --tag-bg: #ECECF0;
    --tag-color: #4A4A4A;
    --sidebar-border: rgba(255,255,255,0.08);
    --sidebar-link: rgba(255,255,255,0.6);
    --sidebar-link-hover-bg: rgba(255,255,255,0.05);
    --sidebar-active-bg: rgba(201,168,76,0.15);
    --sidebar-active-border: #C9A84C;
    --logo-color: #C9A84C;
    --logo-sub: rgba(255,255,255,0.4);
    --modal-overlay: rgba(0,0,0,0.4);
    --focus-shadow: rgba(201,168,76,0.2);
    --stat-value: #1B1B1B;
    --progress-bg: #E5E5E7;
    --tab-border: #D4D4D4;
    --gold: #C9A84C;
    --gold-hover: #B8963F;
    --gold-subtle: rgba(201,168,76,0.1);
    --text-gold: #8A6D2A;          /* accessible gold for FOREGROUND text on light bg (>=4.5:1 WCAG AA) */
    --text-gold-hover: #6E561F;
    color-scheme: light dark;
}

/* ===== Dark Theme ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #0C0C0C;
        --bg-card: #1A1A1A;
        --bg-sidebar: #0C0C0C;
        --bg-header: #1A1A1A;
        --bg-table-header: #1A1A1A;
        --bg-hover: #252525;
        --bg-input: #1A1A1A;
        --bg-modal: #1A1A1A;
        --text-primary: #F2F2F2;
        --text-muted: #8C8C8C;
        --text-label: #BEBEBE;
        --text-empty: #8C8C8C;
        --link-color: #C9A84C;
        --border-color: #333333;
        --border-input: #333333;
        --btn-primary-bg: #C9A84C;
        --btn-primary-hover: #B8963F;
        --btn-primary-color: #0C0C0C;
        --btn-secondary-bg: #252525;
        --btn-secondary-color: #F2F2F2;
        --btn-secondary-hover: #333333;
        --btn-outline-border: #333333;
        --btn-outline-color: #8C8C8C;
        --badge-draft-bg: #252525;
        --badge-draft-color: #8C8C8C;
        --tag-bg: #252525;
        --tag-color: #BEBEBE;
        --sidebar-border: rgba(255,255,255,0.05);
        --sidebar-link: rgba(255,255,255,0.5);
        --sidebar-link-hover-bg: rgba(255,255,255,0.06);
        --sidebar-active-bg: rgba(201,168,76,0.12);
        --sidebar-active-border: #C9A84C;
        --logo-color: #C9A84C;
        --logo-sub: rgba(255,255,255,0.35);
        --modal-overlay: rgba(0,0,0,0.6);
        --focus-shadow: rgba(201,168,76,0.15);
        --stat-value: #F2F2F2;
        --progress-bg: #252525;
        --tab-border: #333333;
        --gold: #C9A84C;
        --gold-hover: #D4B65E;
        --gold-subtle: rgba(201,168,76,0.08);
        --text-gold: #C9A84C;
        --text-gold-hover: #D4B65E;
    }
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text-gold); text-decoration: none; transition: color 0.3s ease; }
a:hover { color: var(--text-gold-hover); text-decoration: none; }

/* Scoped transitions — avoid global * rule for HTMX compatibility */

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--bg-sidebar); color: #fff; padding: 1.5rem 0; position: fixed; height: 100vh; overflow-y: auto; border-right: 1px solid var(--sidebar-border); }
/* min-width: 0 — flex items refuse to shrink below their content's intrinsic width,
   which lets wide tables blow out the viewport instead of scrolling inside .table-container */
.content { margin-left: 240px; flex: 1; padding: 0; min-height: 100vh; min-width: 0; }

/* ===== Sidebar ===== */
.sidebar-header { padding: 0 1.5rem 1.5rem; border-bottom: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: 0.75rem; }
.sidebar-logo-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; transition: transform 0.3s ease; }
.sidebar-logo-img:hover { transform: rotate(12deg); }
.logo { font-size: 1.25rem; font-weight: 600; color: var(--logo-color); letter-spacing: -0.01em; }
.logo-sub { font-size: 0.65rem; color: var(--logo-sub); display: block; letter-spacing: 0.05em; text-transform: uppercase; }
.nav-links { list-style: none; padding: 1rem 0; }
.nav-link { display: block; padding: 0.75rem 1.5rem; color: var(--sidebar-link); transition: all 0.3s ease; font-size: 0.875rem; font-weight: 400; letter-spacing: 0.01em; }
.nav-link:hover { color: #fff; background: var(--sidebar-link-hover-bg); text-decoration: none; transform: translateX(2px); }
.nav-link.active { color: #fff; background: var(--sidebar-active-bg); border-left: 2px solid var(--sidebar-active-border); font-weight: 500; }

/* ===== Page Header ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 2rem; background: var(--bg-header); border-bottom: 1px solid var(--border-color); }
.page-header h2 { font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; }
.header-actions { display: flex; gap: 0.5rem; }
.page-body { padding: 2rem; }

/* ===== Cards ===== */
.card { background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border-color); padding: 1.5rem; margin-bottom: 1rem; transition: border-color 0.3s ease; }
.card:hover { border-color: var(--gold); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-title { font-size: 0.9375rem; font-weight: 500; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border-color); padding: 1.25rem; transition: border-color 0.3s ease; }
.stat-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.25rem; font-weight: 500; }
.stat-value { font-size: 1.75rem; font-weight: 600; color: var(--stat-value); letter-spacing: -0.02em; }
.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
th { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 500; background: var(--bg-table-header); }
tr:hover { background: var(--bg-hover); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.875rem; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: all 0.3s ease; font-family: inherit; }
.btn:hover { transform: scale(1.02); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-color); border-color: var(--btn-primary-bg); }
.btn-primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-color); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--btn-secondary-hover); }
.btn-danger { background: #D4183D; color: #fff; border-color: #D4183D; }
.btn-danger:hover { background: #B81535; border-color: #B81535; }
.btn-success { background: #2D8A4E; color: #fff; border-color: #2D8A4E; }
.btn-success:hover { background: #267A43; border-color: #267A43; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-outline { background: transparent; border: 1px solid var(--btn-outline-border); color: var(--btn-outline-color); }
.btn-outline:hover { border-color: var(--text-gold); color: var(--text-gold); }
.btn-gold { background: var(--gold); color: #0C0C0C; border-color: var(--gold); font-weight: 600; }
.btn-gold:hover { background: var(--gold-hover); border-color: var(--gold-hover); }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 500; margin-bottom: 0.25rem; color: var(--text-label); letter-spacing: 0.01em; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border-input); border-radius: 8px; font-size: 0.875rem; transition: all 0.3s ease; background: var(--bg-input); color: var(--text-primary); font-family: inherit; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus-shadow); }
.form-textarea { min-height: 120px; resize: vertical; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-draft { background: var(--badge-draft-bg); color: var(--badge-draft-color); }
.badge-active { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.badge-paused { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.badge-completed { background: rgba(100,100,140,0.12); color: #8C8C8C; }
.badge-valid { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.badge-invalid { background: rgba(212,24,61,0.12); color: #D4183D; }
.badge-warning { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.badge-muted { background: var(--badge-draft-bg); color: var(--badge-draft-color); }
.badge-ok { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.badge-test_failed { background: rgba(212,24,61,0.12); color: #D4183D; }
.badge-sender_missing { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.badge-disabled { background: var(--badge-draft-bg); color: var(--badge-draft-color); }

/* ===== Score Badges ===== */
.score-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; }
.score-1 { background: rgba(212,24,61,0.12); color: #D4183D; }
.score-2 { background: rgba(200,120,50,0.12); color: #C87832; }
.score-3 { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.score-4 { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.score-5 { background: rgba(45,138,78,0.15); color: #267A43; }

/* ===== Lead Type Badges ===== */
.lead-type-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.lead-type-prospect { background: rgba(100,100,180,0.1); color: #6464B4; }
.lead-type-agency { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.lead-type-mixed { background: rgba(120,100,180,0.1); color: #7864B4; }
.lead-type-unclassified { background: var(--badge-draft-bg); color: var(--badge-draft-color); }
.lead-type-unknown { background: var(--badge-draft-bg); color: var(--badge-draft-color); }

/* ===== Detail Score Row ===== */
.detail-score-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.detail-score { display: flex; gap: 0.5rem; align-items: center; }

/* ===== Filter Bar ===== */
.filter-bar { margin-bottom: 1rem; }
.filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.filter-row .form-input { flex: 1; min-width: 200px; }
.filter-row .form-select { width: auto; min-width: 130px; }

/* ===== Toast ===== */
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.75rem 1.25rem; border-radius: 8px; color: #fff; font-size: 0.875rem; animation: toast-in 0.3s ease; backdrop-filter: blur(8px); }
.toast-success { background: rgba(45,138,78,0.9); }
.toast-error { background: rgba(212,24,61,0.9); }
.toast-info { background: rgba(201,168,76,0.9); color: #0C0C0C; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Tabs ===== */
.tabs { display: flex; border-bottom: 2px solid var(--tab-border); margin-bottom: 1.5rem; }
.tab { padding: 0.75rem 1.25rem; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.3s ease; }
.tab.active { color: var(--text-gold); border-bottom-color: var(--gold); }
.tab:hover { color: var(--text-primary); }

/* ===== Progress bar ===== */
.progress-bar { height: 6px; background: var(--progress-bg); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 3px; transition: width 0.3s; }

/* ===== Search ===== */
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-bar .form-input { flex: 1; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: var(--modal-overlay); z-index: 100; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal { background: var(--bg-modal); border-radius: 12px; border: 1px solid var(--border-color); padding: 1.5rem; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-title { font-size: 1.0625rem; font-weight: 500; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); transition: color 0.3s ease; }
.modal-close:hover { color: var(--text-primary); }

/* ===== Grid ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
/* min-width: 0 — grid items default to min-width: auto and won't shrink below a wide
   table's intrinsic width; without this, .table-container inside a grid cell can't scroll */
.grid-2 > *, .grid-2-wrap > *, .grid-3 > * { min-width: 0; }

/* ===== Checkbox ===== */
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--gold); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state h3 { font-size: 1.0625rem; margin-bottom: 0.5rem; color: var(--text-empty); font-weight: 500; }

/* ===== Inline form row ===== */
.form-row { display: flex; gap: 1rem; align-items: end; }
.form-row .form-group { flex: 1; }

/* ===== Tag ===== */
.tag { display: inline-block; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.75rem; background: var(--tag-bg); color: var(--tag-color); margin-right: 0.25rem; }
/* LJ-1: inside data tables, chips stay single-line (ellipsized) so rows never balloon */
td .tag { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
/* LJ-1: clamp long free-text cells (title) to two lines; full text via title attr */
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* LJ-1: single-line ellipsized cell content (lead name/email) */
.cell-ellipsis { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Utility ===== */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-gold { color: var(--text-gold); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ===== Scrollbar Styling ===== */
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }
/* WebKit (Chrome, Safari) */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Selection ===== */
::selection { background: var(--gold-subtle); color: var(--text-primary); }

/* ===== Phase 13: AI-Status Badge Classes ===== */
/* Values from src/constants.py AIStatus enum (personalized/cached/cap_skipped/failed_fallback) */
.badge-personalized { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.badge-cached { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.badge-cap_skipped { background: rgba(100,100,140,0.12); color: #8C8C8C; }
.badge-failed_fallback { background: rgba(212,24,61,0.12); color: #D4183D; }

/* ===== Phase 13: Email-Log Status Badge Classes ===== */
/* Values from src/constants.py EmailLogStatus enum (sent/failed/bounced/replied/opened) */
.badge-sent { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.badge-bounced { background: rgba(212,24,61,0.12); color: #D4183D; }
.badge-failed { background: rgba(212,24,61,0.12); color: #D4183D; }
.badge-replied { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.badge-opened { background: rgba(201,168,76,0.12); color: var(--text-gold); }

/* ===== Phase 15: Missing status badges (UIPOL-01) ===== */
/* Values from src/constants.py CampaignLeadStatus enum (pending/suppressed/skipped) */
.badge-pending { background: var(--badge-draft-bg); color: var(--badge-draft-color); }
.badge-suppressed { background: rgba(212,24,61,0.12); color: #D4183D; }
.badge-skipped { background: rgba(100,100,140,0.12); color: #8C8C8C; }

/* ===== Phase 15: Accessible btn-outline hover (UIPOL-04 / UX-15) ===== */
/* Already fixed in-place above: .btn-outline:hover uses var(--text-gold) */

/* ===== Phase 15: Keyboard focus ring (UIPOL-02) ===== */
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-shadow);
}
/* role=tab buttons reuse .tab — neutralize default button chrome so a <button class="tab">
   renders identically to the old <div class="tab">, and give it a keyboard focus ring. */
button.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    line-height: 1.5;
}
.tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-shadow);
    border-radius: 4px;
}

/* ===== Phase 13: Stat Card Warning Modifier ===== */
/* Non-color-only: gold border + background + "!" text marker via ::before on .stat-label */
.stat-card--warning { border-color: var(--gold); background: var(--gold-subtle); }
.stat-card--warning .stat-label::before { content: "! "; color: var(--text-gold); }

/* ===== Phase 13: Alert Banner (Auto-Pause) ===== */
.alert-banner {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 4px solid;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}
.alert-banner--warning {
    border-left-color: var(--gold);
    background: var(--gold-subtle);
    color: var(--text-gold);
}
.alert-banner--danger {
    border-left-color: #D4183D;
    background: rgba(212,24,61,0.08);
    color: #D4183D;
}

/* ===== x-cloak: Prevent Alpine.js expandable rows from flashing on load ===== */
[x-cloak] { display: none !important; }

/* ===== Phase 14: Toast Rework ===== */
/* Position: bottom-right, clear of header (D-05) */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    top: auto;          /* override existing top: 1rem */
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse; /* newest at bottom, oldest evicted off top */
    gap: 0.5rem;
    max-width: 360px;
}

/* Dismiss button inside every toast (D-07) */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    /* existing: border-radius, font-size, animation, backdrop-filter preserved */
}
.toast-message {
    flex: 1;
}
.toast-dismiss {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.2s ease;
}
.toast-dismiss:hover {
    color: #fff;
}
/* toast-info dismiss uses dark color since background is gold */
.toast-info .toast-dismiss {
    color: rgba(12,12,12,0.5);
}
.toast-info .toast-dismiss:hover {
    color: #0C0C0C;
}

/* Eviction animation: oldest toast slides out upward before being removed (D-08) */
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); max-height: 80px; }
    to   { opacity: 0; transform: translateX(16px); max-height: 0; padding: 0; margin: 0; }
}
.toast-exiting {
    animation: toast-out 0.25s ease forwards;
}

/* ===== Phase 14: Button Spinner ===== */
/* Spinner element injected by JS alongside the working label */
.btn-spinner {
    width: 0.875rem;          /* 14px — matches btn font-size */
    height: 0.875rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    flex-shrink: 0;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}
/* When button is in-flight, pointer-events already blocked by [disabled] */
.btn[disabled] {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important; /* cancel hover scale */
}

/* ===== Phase 14: Skeleton Loader ===== */
.skeleton {
    background: var(--bg-table-header);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--bg-hover) 50%,
        transparent 100%
    );
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
/* Preset skeleton shapes for the AI output panel */
.skeleton-line {
    height: 0.875rem;   /* 14px — body font size */
    margin-bottom: 0.5rem;
    border-radius: 4px;
}
.skeleton-line-short {
    width: 60%;
}
.skeleton-line-medium {
    width: 85%;
}
.skeleton-line-full {
    width: 100%;
}
.skeleton-block {
    height: 6rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

/* ===== Phase 14: Confirm Strip ===== */
.confirm-strip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    animation: confirm-strip-in 0.15s ease;
}
@keyframes confirm-strip-in {
    from { opacity: 0; transform: scaleX(0.92); }
    to   { opacity: 1; transform: scaleX(1); }
}
.confirm-strip-message {
    color: var(--text-primary);
    white-space: nowrap;
}
/* Muted secondary detail line within the strip (e.g. "Enrolled leads keep their history.") */
.confirm-strip-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* ===== Phase 15: Responsive drawer (UIPOL-05 / D-01,D-02) ===== */
.nav-hamburger { display: none; }   /* hidden on desktop; shown at <=900px */
.nav-scrim { display: none; }       /* shown only when the drawer is open below breakpoint */

@media (max-width: 900px) {
    /* Sidebar becomes a slide-over drawer; default off-canvas. */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1100;
    }
    .sidebar.sidebar-open { transform: translateX(0); }
    .content { margin-left: 0; }
    .nav-hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        font-size: 1.5rem;
        line-height: 1;
        color: var(--text-primary);
        padding: 0.25rem 0.5rem;
        margin-right: 0.5rem;
    }
    .nav-hamburger:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-shadow); border-radius: 4px; }
    /* Header action buttons wrap instead of overflowing the viewport on phones */
    .page-header { flex-wrap: wrap; row-gap: 0.5rem; }
    .header-actions { flex-wrap: wrap; justify-content: flex-end; }
    .nav-scrim.scrim-open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1050;
    }
}

@media (max-width: 640px) {
    /* Multi-column grids stack on phones so tables get the full viewport width */
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== Phase 15: Email preview pane (UIPOL-03 / D-06,D-07) ===== */
.email-preview-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.email-preview-pane {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 600px;
}
.email-preview-subject {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1B1B1B;
    background: #f7f7f7;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 8px 8px 0 0;
}
.email-preview-pane iframe { width: 100%; border: none; min-height: 150px; display: block; border-radius: 0 0 8px 8px; }

/* ===== Phase 14: Inline Expansion ===== */
/* Full-width expansion row below a table row */
.expansion-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
}
/* Expansion panel inside a table td (colspan row) */
td > .expansion-panel {
    margin: 0.5rem;
}
/* Compact title row within the panel */
.expansion-panel-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-label);
    margin-bottom: 0.75rem;
}

/* ===== Phase 17 — Discovery Scan ===== */
/* DiscoveryScanRunStatus enum values */
.badge-running { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.badge-cancelled { background: rgba(100,100,140,0.12); color: #8C8C8C; }
/* Noise badge: noreply-pattern contacts visible in staging list (D-07) */
.badge-noise { background: rgba(100,100,140,0.12); color: #8C8C8C; }
/* Engagement class badges for discovered contacts (Phase 18 review table) */
.badge-engaged { background: rgba(45,138,78,0.12); color: #2D8A4E; }
.badge-went_quiet { background: rgba(201,168,76,0.12); color: var(--text-gold); }
.badge-one_way { background: rgba(100,100,140,0.12); color: #8C8C8C; }
