/* Jazz / Blu Campaign Studio — Cascade-inspired theme */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Montserrat:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --sidebar-width: 240px;
    --font: 'Montserrat', system-ui, -apple-system, sans-serif;
    --font-display: 'Bebas Neue', 'Montserrat', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --primary: #ba131a;
    --primary-dark: #8e0f14;
    --primary-light: #ff1b22;
    --brand-50: #fbf2ee;
    --brand-100: #f9e9e7;
    --brand-600: #ba131a;
    --brand-700: #8e0f14;
    --sidebar-bg: #2a0712;
    --sidebar-border: rgba(255,255,255,0.08);
    --surface: #ffffff;
    --surface-2: #f2efe8;
    --canvas: #f2efe8;
    --hairline: #eae6db;
    --ink: #0a0908;
    --text: #0a0908;
    --text-muted: #78716c;
    --border: #eae6db;
    --shadow-sm: 0 1px 2px rgba(10, 9, 8, 0.05);
    --shadow-card: 0 1px 2px rgba(10, 9, 8, 0.05), 0 6px 16px rgba(10, 9, 8, 0.09);
    --shadow-red: 0 6px 18px rgba(186, 19, 26, 0.28);
    --radius: 12px;
    --radius-lg: 16px;
    --gold: #a87500;
    --leaf: #12a150;
    --teal: #0e7c86;
    --azure: #35618e;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--surface-2);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

body.app-bg {
    background:
        radial-gradient(900px 480px at 100% -8%, rgba(186, 19, 26, 0.06), transparent 60%),
        radial-gradient(760px 460px at -8% 108%, rgba(103, 0, 0, 0.05), transparent 60%),
        var(--canvas);
    background-attachment: fixed;
}

.display {
    font-family: var(--font-display);
    letter-spacing: 0.02em;
}

.label-mono {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

/* ── Auth / guest layout ── */
body.guest-layout {
    min-height: 100vh;
    background: #f8fafc;
    overflow-x: hidden;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 4rem;
    color: #fff;
    background: #0f172a;
    border-right: 1px solid #1e293b;
}

.auth-hero-content { max-width: 420px; }

.auth-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: rgba(255,255,255,0.85);
}

.auth-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.auth-hero h1 span {
    color: #93c5fd;
}

.auth-hero p { color: rgba(255,255,255,0.65); font-size: 1rem; line-height: 1.6; }

.auth-features { list-style: none; padding: 0; margin: 2rem 0 0; }
.auth-features li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
}
.auth-features li i {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    color: #93c5fd;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #f8fafc;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    padding: 2.5rem;
}

.auth-card .brand-mark {
    width: 48px; height: 48px;
    border-radius: 8px;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.25rem;
    margin: 0 auto 1.25rem;
}

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-panel { min-height: 100vh; }
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(158deg, #2a0712, #670000 52%, #ba131a);
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
}

.sidebar-logo-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-logo-text h5 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.sidebar-logo-text small {
    color: rgba(255,255,255,0.45);
    font-size: 0.7rem;
    font-weight: 500;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.6);
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    margin: 0.1rem 0.65rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
}

.sidebar .nav-link i { font-size: 1rem; opacity: 0.9; }

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}

.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.12);
    border-left: 3px solid #ffdd00;
    padding-left: calc(0.85rem - 3px);
}

.sidebar-badge {
    float: right;
    min-width: 1.25rem;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    background: #ffdd00;
    color: #2a0712;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.sidebar .nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    padding: 0.75rem 1.25rem 0.25rem;
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--sidebar-border);
    margin-top: auto;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: #334155;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-cta {
    margin: 0.5rem 0.75rem 0;
}

.sidebar-cta .btn {
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--surface-2);
}

.page-header {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--hairline);
    padding: 0.875rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header h4 {
    font-weight: 600;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--text);
}

.page-content {
    padding: 1.5rem 1.75rem;
}

/* ── Buttons ── */
.btn {
    font-weight: 600;
    border-radius: 6px;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.btn-outline-primary {
    border-radius: 6px;
    font-weight: 600;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-success {
    border-radius: 6px;
    font-weight: 600;
}

.btn-warning {
    border-radius: 6px;
    font-weight: 600;
}

/* Legacy alias — same as primary, no glow */
.btn-glow {
    background: var(--primary);
    border: 1px solid var(--primary);
    color: #fff;
    font-weight: 600;
    border-radius: 6px;
    padding: 0.5rem 1rem;
}

.btn-glow:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

/* ── Cards ── */
.portal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.875rem 1.25rem;
}

/* ── Stat cards ── */
.stat-card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--stat-accent, var(--primary));
}

.stat-card.stat-indigo { --stat-accent: #1e40af; }
.stat-card.stat-rose { --stat-accent: #be123c; }
.stat-card.stat-amber { --stat-accent: #b45309; }
.stat-card.stat-emerald { --stat-accent: #047857; }
.stat-card.stat-violet { --stat-accent: #5b21b6; }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-icon.indigo { background: #eff6ff; color: #1e40af; }
.stat-icon.rose { background: #fff1f2; color: #be123c; }
.stat-icon.amber { background: #fffbeb; color: #b45309; }
.stat-icon.emerald { background: #ecfdf5; color: #047857; }
.stat-icon.violet { background: #f5f3ff; color: #5b21b6; }

.stat-card h3, .stat-card h4 {
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Hero banner (Jazz command deck) ── */
.portal-hero {
    background: linear-gradient(158deg, #2a0712, #670000 52%, #ba131a);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    color: #fff;
    border: none;
    box-shadow: var(--shadow-red);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.portal-hero::before {
    content: '';
    position: absolute;
    right: -4rem;
    top: -5rem;
    width: 16rem;
    height: 16rem;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    pointer-events: none;
}

.portal-hero-content { position: relative; z-index: 1; }

.portal-hero h2 {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.portal-hero p { color: rgba(255,255,255,0.65); margin-bottom: 0; font-size: 0.925rem; }

/* ── Tables ── */
.table { --bs-table-bg: transparent; }
.table thead th {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom-width: 1px;
    padding: 0.75rem 1rem;
    background: #fafbfc;
}

.table tbody td { padding: 0.85rem 1rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ── Badges ── */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.35em 0.65em;
    border-radius: 4px;
}

/* ── Alerts ── */
.alert {
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
}

.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-danger { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

#queueBanner {
    border-radius: var(--radius);
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
    font-weight: 600;
    font-size: 0.875rem;
}

/* ── Brand select cards ── */
.brand-select-card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
}

.brand-select-card:hover {
    box-shadow: var(--shadow-md) !important;
    border-color: #cbd5e1 !important;
}

.brand-logo-ring {
    width: 72px; height: 72px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state-icon {
    width: 64px; height: 64px;
    border-radius: 8px;
    background: #f1f5f9;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h5 { font-weight: 600; margin-bottom: 0.5rem; }

/* ── Page intro ── */
.page-intro {
    text-align: center;
    margin-bottom: 1.75rem;
}

.page-intro h5 {
    font-weight: 600;
    font-size: 1.2rem;
}

/* ── Form controls ── */
.form-control, .form-select {
    border-radius: 6px;
    border-color: var(--border);
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(186, 19, 26, 0.12);
}

/* ── Poster variation cards ── */
.poster-variation-card {
    border-radius: var(--radius) !important;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.poster-variation-card:hover {
    box-shadow: var(--shadow-md) !important;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .page-content { padding: 1rem; }
}

/* ── Cascade / dashboard components ── */
.cascade-card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.cascade-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--hairline);
}

.cascade-card-body { padding: 1.25rem; }

.cascade-metric-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

@media (min-width: 768px) {
    .cascade-metric-strip { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
    .cascade-metric-strip { grid-template-columns: repeat(6, 1fr); }
}

.cascade-metric-tile {
    padding: 1rem 1.1rem;
    border-right: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
}

.cascade-metric-value {
    font-family: var(--font-display);
    font-size: 1.85rem;
    line-height: 1;
    color: var(--ink);
}

.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 992px) {
    .dashboard-kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

.dashboard-kpi {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-sm);
}

.dashboard-kpi .kpi-value {
    font-family: var(--font-display);
    font-size: 2rem;
    line-height: 1;
    color: var(--ink);
}

.dashboard-chart-card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    height: 100%;
}

.dashboard-chart-card .chart-wrap {
    position: relative;
    height: 260px;
    padding: 0 1rem 1rem;
}

.dashboard-chart-card .chart-wrap.chart-sm { height: 220px; }

.pipeline-ribbon {
    display: flex;
    height: 0.65rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.12);
}

.flow-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.flow-column { flex: 0 0 17rem; min-width: 17rem; }
.flow-column-head { display: flex; justify-content: space-between; border-bottom: 2px solid; padding-bottom: .45rem; margin-bottom: .6rem; }
.flow-campaign-card {
    display: block; background: var(--surface); border: 1px solid var(--hairline);
    border-radius: 12px; padding: .8rem; margin-bottom: .55rem; text-decoration: none; color: inherit;
    box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s;
}
.flow-campaign-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); color: inherit; }

.dash-campaign-row {
    display: flex; align-items: center; gap: .75rem; padding: .75rem 0;
    border-bottom: 1px solid var(--hairline); text-decoration: none; color: inherit;
}
.dash-campaign-row:last-child { border-bottom: none; }
.dash-campaign-row:hover { color: inherit; opacity: .9; }
.dash-campaign-row .progress { width: 72px; height: 4px; flex-shrink: 0; }

/* Campaign workspace */
.campaign-alert {
    border-radius: 10px;
    padding: .65rem 1rem;
    font-size: .875rem;
}
.campaign-alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.campaign-alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.campaign-alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

.campaign-status-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.campaign-status-strip.processing { border-color: #93c5fd; background: #eff6ff; }
.campaign-status-strip.failed { border-color: #fecaca; background: #fef2f2; }

.campaign-progress-ring {
    position: relative;
    width: 140px;
    height: 140px;
}
.campaign-progress-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.campaign-phase-track {
    display: flex;
    align-items: center;
    padding: 0 .25rem;
}
.campaign-phase-step {
    display: flex;
    align-items: center;
    flex: 1;
    position: relative;
}
.campaign-phase-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #eae6db;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #eae6db;
    flex-shrink: 0;
    z-index: 1;
}
.campaign-phase-step.done .campaign-phase-dot,
.campaign-phase-step.active .campaign-phase-dot {
    background: var(--phase-color, #ba131a);
    box-shadow: 0 0 0 1px var(--phase-color, #ba131a);
}
.campaign-phase-step.active .campaign-phase-dot {
    animation: pulse-soft 2s ease-in-out infinite;
}
.campaign-phase-line {
    flex: 1;
    height: 2px;
    background: #eae6db;
    margin: 0 -1px;
}
.campaign-phase-line.done { background: #ba131a; }

.campaign-phase-pill {
    font-size: .62rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .2rem .45rem;
    border-radius: 999px;
    background: #f5f3ee;
    color: #6b6560;
}
.campaign-phase-pill.active {
    background: color-mix(in srgb, var(--c) 15%, white);
    color: var(--c);
    font-weight: 600;
}

.persona-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ba131a, #8b0e14);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}

#personasAccordion .accordion-button:not(.collapsed) {
    background: #faf9f7;
    box-shadow: none;
}
#personasAccordion .accordion-button:focus { box-shadow: none; }

#agentStepsChart { max-height: 120px; }

@keyframes pulse-soft { 0%,100%{opacity:1} 50%{opacity:.65} }

/* Global AJAX overlay */
.portal-ajax-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.portal-ajax-box {
    background: #fff;
    border-radius: 14px;
    padding: 1.35rem 1.75rem;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    min-width: 220px;
    max-width: 320px;
}
.portal-ajax-box .spinner-border {
    width: 2rem;
    height: 2rem;
    color: var(--primary);
}
.portal-ajax-message {
    font-size: 0.875rem;
    color: #495057;
    font-weight: 500;
}
button.is-ajax-loading,
.btn.is-ajax-loading {
    pointer-events: none;
    opacity: 0.85;
}
