/* ============================================
   MODULE SHARED — Reusable module components
   Period pills, KPIs, funnel, location cards,
   trend bars, ETL badges, sync button
   ============================================ */

/* ── Period Filter Pills ──────────────────── */
.mkt-period-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.mkt-period-bar .period-pills {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    padding: 3px;
    gap: 2px;
}

.mkt-period-bar .period-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.mkt-period-bar .period-pill:hover {
    color: var(--text-primary);
    background: var(--surface-3);
}

.mkt-period-bar .period-pill.active {
    color: var(--text-inverse);
    background: var(--accent);
    box-shadow: 0 1px 4px rgba(0, 166, 81, 0.25);
}

.mkt-period-bar .filter-select {
    padding: 0.35rem 2rem 0.35rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 100px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-weight: 500;
    margin-top: 0;
    width: auto;
}


/* ── Funnel Visualization ────────────────── */
.mkt-funnel {
    padding: 0.5rem 0;
}

.funnel-stage {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.35rem;
}

.funnel-label {
    flex: 0 0 140px;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: right;
}

.funnel-bar-wrap {
    flex: 1;
    position: relative;
}

.funnel-bar {
    height: 36px;
    border-radius: 4px 18px 18px 4px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 4px;
    position: relative;
    display: flex;
    align-items: center;
    padding-left: 0.75rem;
}

.funnel-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 100%);
    pointer-events: none;
}

.funnel-bar-count {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-inverse);
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Count outside bar for small bars */
.funnel-bar-count-outside {
    position: absolute;
    left: calc(100% + 0.6rem);
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.funnel-meta {
    flex: 0 0 60px;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: right;
}

/* Large funnel variant */
.mkt-funnel.funnel-lg .funnel-bar { height: 48px; border-radius: 6px 24px 24px 6px; }
.mkt-funnel.funnel-lg .funnel-label { flex: 0 0 170px; font-size: 0.88rem; }
.mkt-funnel.funnel-lg .funnel-bar-count { font-size: 0.95rem; }


/* ── ETL Status Badges ───────────────────── */
.etl-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.2em 0.6em;
    border-radius: 6px;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.etl-status-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--status-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.etl-status-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.etl-status-running {
    background: rgba(59, 130, 246, 0.1);
    color: var(--status-info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.etl-status-skipped, .etl-status-never_run {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(107, 114, 128, 0.2);
}

[data-theme="dark"] .etl-status-success {
    background: rgba(16, 185, 129, 0.18);
    color: #6ee7b7;
}
[data-theme="dark"] .etl-status-error {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}
[data-theme="dark"] .etl-status-running {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

.etl-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: etl-pulse-anim 1.5s ease-in-out infinite;
}

.etl-pulse.green { background: var(--status-success); }
.etl-pulse.red { background: var(--status-danger); }
.etl-pulse.blue { background: var(--status-info); }
.etl-pulse.gray { background: var(--text-muted); }

@keyframes etl-pulse-anim {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}


/* ── Location Cards ──────────────────────── */
.location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.location-card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.location-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-card);
}

.location-card-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.location-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
}

.location-card-stat {
    display: flex;
    flex-direction: column;
}

.location-card-stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-weight: 500;
}

.location-card-stat-value {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}


/* ── Sync Button ─────────────────────────── */
.sync-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.sync-btn:hover {
    background: var(--surface-4);
    border-color: var(--accent);
    color: var(--accent);
    transform: none;
    box-shadow: none;
}

.sync-btn svg {
    width: 14px;
    height: 14px;
}

.sync-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sync-btn:disabled:hover {
    background: var(--surface-3);
    color: var(--text-primary);
    border-color: var(--border-default);
}


/* ── KPI Row ─────────────────────────────── */
.mkt-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.mkt-kpi {
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    transition: border-color 0.2s;
}

.mkt-kpi:hover {
    border-color: var(--border-default);
}

.mkt-kpi.highlight {
    border-left: 3px solid var(--accent);
}

.mkt-kpi-label {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.mkt-kpi-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.mkt-kpi-value.accent { color: var(--accent); }

.mkt-kpi-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}


/* ── Section & Empty State ───────────────── */
.mkt-empty {
    text-align: center;
    padding: 3rem 1.5rem;
}

.mkt-empty svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.mkt-empty p {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.mkt-empty a {
    font-weight: 600;
}

.mkt-section {
    margin-bottom: 2rem;
}

.mkt-section-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}


/* ── Text Helpers ────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }


/* ── Trend Sparkline Bars ────────────────── */
.trend-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 80px;
}

.trend-bar {
    flex: 1;
    min-width: 4px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
    transition: height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.trend-bar:hover {
    background: var(--accent-bright);
}

.trend-bar.secondary {
    background: var(--secondary);
}

.trend-bar.secondary:hover {
    background: #338bd4;
}

.trend-bar-label {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    display: none;
}

.trend-bar:hover .trend-bar-label {
    display: block;
}


/* ── ETL Sync Running Banner ─────────────── */
.etl-sync-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    font-family: var(--font-display);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--status-info);
}

.etl-sync-banner .etl-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--status-info);
    border-radius: 50%;
    animation: etl-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes etl-spin {
    to { transform: rotate(360deg); }
}

[data-theme="dark"] .etl-sync-banner {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
}


/* ── Responsive ──────────────────────────── */
@media (max-width: 640px) {
    .mkt-period-bar { flex-direction: column; align-items: flex-start; }
    .mkt-kpi-row { grid-template-columns: repeat(2, 1fr); }
    .mkt-funnel.funnel-lg .funnel-label { flex: 0 0 100px; font-size: 0.75rem; }
    .mkt-funnel.funnel-lg .funnel-bar { height: 36px; }
    .location-grid { grid-template-columns: 1fr; }
}
