/*
 * The Campaign Guru: client portal styles (phone first, then wider screens).
 * Used through the Blade building blocks in resources/views/components/portal/.
 * Colours: only var(--cg-...) from config/design.php. Never type a colour here.
 */

/* ---- Page ---- */
.cg-portal { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--cg-background);
    color: var(--cg-text); font-family: var(--cg-font-text); font-size: 1rem; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.cg-portal *, .cg-portal *::before, .cg-portal *::after { box-sizing: border-box; }
.cg-portal a { color: var(--cg-link); }
.cg-portal :focus-visible { outline: 3px solid var(--cg-focus); outline-offset: 2px; }
.cg-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cg-skip { position: absolute; left: -999px; top: 0.5rem; z-index: 50; padding: 0.5rem 1rem; border-radius: var(--cg-radius-medium);
    background: var(--cg-surface); color: var(--cg-text); }
.cg-skip:focus { left: 0.5rem; }

/* ---- Top bar (navy, both modes) ---- */
.cg-topbar { position: sticky; top: 0; z-index: 20; background: var(--cg-structure); color: var(--cg-structure-text); }
.cg-topbar-inner { max-width: var(--cg-space-content-width); margin: 0 auto; padding: 0.5rem var(--cg-space-page-gutter);
    display: flex; align-items: center; gap: 0.75rem; min-height: 3.5rem; }
.cg-topbar-logo { display: inline-flex; height: 2.25rem; flex-shrink: 0; }
.cg-topbar-place { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    padding-left: 0.75rem; border-left: 1px solid var(--cg-navy-700); }
.cg-topbar-place small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--cg-slate-400); }
.cg-topbar-actions { display: flex; align-items: center; gap: 0.25rem; }
.cg-icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; min-width: 2.5rem; height: 2.5rem;
    padding: 0 0.625rem; border: 0; border-radius: var(--cg-radius-medium); background: transparent; color: var(--cg-structure-text);
    font: inherit; font-size: 0.875rem; cursor: pointer; }
.cg-icon-btn:hover { background: var(--cg-navy-800); }
.cg-icon-btn svg { width: 1.25rem; height: 1.25rem; }
.cg-theme-label { display: none; }

/* Account menu (no script needed) */
.cg-menu { position: relative; }
.cg-menu > summary { list-style: none; }
.cg-menu > summary::-webkit-details-marker { display: none; }
.cg-avatar { width: 2rem; height: 2rem; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--cg-navy-700); color: var(--cg-white); font-size: 0.8125rem; font-weight: 600; }
.cg-menu-panel { position: absolute; right: 0; top: calc(100% + 0.5rem); min-width: 15rem; padding: 0.5rem; border-radius: var(--cg-radius-large);
    background: var(--cg-surface); color: var(--cg-text); border: 1px solid var(--cg-border);
    box-shadow: 0 10px 30px -10px var(--cg-navy-950); }
.cg-menu-panel .cg-menu-who { padding: 0.5rem 0.75rem; font-size: 0.875rem; color: var(--cg-text-muted); border-bottom: 1px solid var(--cg-border); margin-bottom: 0.25rem; }
.cg-menu-panel .cg-menu-who strong { display: block; color: var(--cg-text); }
.cg-menu-item { display: block; width: 100%; padding: 0.625rem 0.75rem; border: 0; border-radius: var(--cg-radius-medium); background: transparent;
    color: var(--cg-text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.cg-portal .cg-menu-item { color: var(--cg-text); }
.cg-menu-item:hover { background: var(--cg-surface-muted); }

/* Portal sections (Home, Messages...) under the top bar */
.cg-tabs { border-top: 1px solid var(--cg-navy-800); }
.cg-tabs-inner { max-width: var(--cg-space-content-width); margin: 0 auto; padding: 0 var(--cg-space-page-gutter); display: flex; gap: 0.25rem; overflow-x: auto; }
.cg-portal a.cg-tab { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.625rem 0.75rem; color: var(--cg-structure-text);
    text-decoration: none; font-size: 0.9375rem; border-bottom: 3px solid transparent; white-space: nowrap; }
.cg-portal a.cg-tab:hover { color: var(--cg-white); }
.cg-portal a.cg-tab-active { color: var(--cg-white); font-weight: 600; border-bottom-color: var(--cg-structure-active); }
.cg-tab-count { min-width: 1.25rem; padding: 0 0.375rem; border-radius: 999px; background: var(--cg-attention); color: var(--cg-on-attention);
    font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 1.25rem; }

/* ---- Messages ---- */
.cg-messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.cg-message { padding: 0.75rem 0.875rem; border-radius: var(--cg-radius-large); background: var(--cg-surface-muted); margin-right: 1.5rem; }
.cg-message-mine { background: var(--cg-surface); border: 1px solid var(--cg-border); margin-right: 0; margin-left: 1.5rem; }
.cg-message-event { background: transparent; border: 1px dashed var(--cg-border); margin: 0; color: var(--cg-text-muted); }
.cg-message-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.375rem; font-size: 0.8125rem; color: var(--cg-text-muted); margin-bottom: 0.25rem; }
.cg-message-meta strong { color: var(--cg-text); }
.cg-message-body { white-space: normal; }
.cg-message-foot { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.375rem; font-size: 0.8125rem; color: var(--cg-text-muted); }

/* ---- Main ---- */
.cg-main { flex: 1; width: 100%; max-width: var(--cg-space-content-width); margin: 0 auto; padding: 1.25rem var(--cg-space-page-gutter) 2.5rem; }
.cg-breadcrumb { display: flex; flex-wrap: wrap; gap: 0.375rem; margin: 0 0 0.25rem; padding: 0; list-style: none; font-size: 0.875rem; color: var(--cg-text-muted); }
.cg-breadcrumb li + li::before { content: "›"; margin-right: 0.375rem; }
.cg-page-title { margin: 0 0 1.25rem; font-size: 1.5rem; line-height: 1.25; }
/* minmax(0, 1fr): columns never grow wider than the screen, however long the text inside */
.cg-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.cg-stack { display: grid; gap: 1rem; align-content: start; grid-template-columns: minmax(0, 1fr); }
.cg-card, .cg-alert, .cg-attention-item { overflow-wrap: anywhere; }
.cg-footer { border-top: 1px solid var(--cg-border); color: var(--cg-text-muted); font-size: 0.875rem; }
.cg-footer-inner { max-width: var(--cg-space-content-width); margin: 0 auto; padding: 1rem var(--cg-space-page-gutter); }

/* ---- Card ---- */
.cg-card { background: var(--cg-surface); border: 1px solid var(--cg-border); border-radius: var(--cg-radius-large); padding: 1.125rem; }
.cg-card-title { margin: 0; font-size: 1.0625rem; line-height: 1.35; }
.cg-card-description { margin: 0.25rem 0 0; color: var(--cg-text-muted); font-size: 0.9375rem; }
.cg-card-body { margin-top: 0.875rem; }
.cg-card-body > :first-child { margin-top: 0; }
.cg-card-body > :last-child { margin-bottom: 0; }

/* ---- "Your next step" ---- */
.cg-next-step { border-left: 4px solid var(--cg-primary); }
.cg-eyebrow { display: block; margin-bottom: 0.25rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cg-text-muted); }
.cg-next-step .cg-btn { margin-top: 1rem; }

/* ---- "Needs your attention" ---- */
.cg-attention-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.cg-attention-item { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem; border-radius: var(--cg-radius-medium);
    background: var(--cg-attention-soft); color: var(--cg-attention-text); }
.cg-attention-item a { color: inherit; font-weight: 600; }
.cg-dot { flex-shrink: 0; width: 0.625rem; height: 0.625rem; margin-top: 0.45rem; border-radius: 999px; background: var(--cg-attention); }
.cg-attention-item p { margin: 0.125rem 0 0; font-size: 0.875rem; }

/* ---- Buttons ---- */
.cg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.625rem 1.125rem;
    border: 1px solid transparent; border-radius: var(--cg-radius-medium); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.cg-portal a.cg-btn { text-decoration: none; }
.cg-btn-primary, .cg-portal a.cg-btn-primary { background: var(--cg-primary); color: var(--cg-on-primary); }
.cg-btn-primary:hover { background: var(--cg-primary-hover); }
.cg-btn-secondary, .cg-portal a.cg-btn-secondary { background: var(--cg-surface); color: var(--cg-text); border-color: var(--cg-border); }
.cg-btn-secondary:hover { background: var(--cg-surface-muted); }
.cg-btn-danger, .cg-portal a.cg-btn-danger { background: var(--cg-danger); color: var(--cg-white); }
.cg-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.cg-btn-block { width: 100%; }

/* ---- Badges ---- */
.cg-badge { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.125rem 0.625rem; border-radius: 999px;
    font-size: 0.8125rem; font-weight: 600; line-height: 1.5; border: 1px solid var(--cg-border); color: var(--cg-text-muted); }
.cg-badge-attention { background: var(--cg-attention); border-color: var(--cg-attention); color: var(--cg-on-attention); }
.cg-badge-success { border-color: var(--cg-success); color: var(--cg-success); }
.cg-badge-danger { border-color: var(--cg-danger); color: var(--cg-danger); }
.cg-badge-info { border-color: var(--cg-link); color: var(--cg-link); }

/* ---- Alerts ---- */
.cg-alert { padding: 0.875rem 1rem; border-radius: var(--cg-radius-medium); border: 1px solid var(--cg-border); border-left-width: 4px; background: var(--cg-surface); }
.cg-alert-title { display: block; margin-bottom: 0.125rem; }
.cg-alert-info { border-left-color: var(--cg-link); }
.cg-alert-success { border-left-color: var(--cg-success); }
.cg-alert-attention { border-left-color: var(--cg-attention); background: var(--cg-attention-soft); color: var(--cg-attention-text); }
.cg-alert-danger { border-left-color: var(--cg-danger); }

/* ---- Empty state ---- */
.cg-empty { padding: 1rem; border: 1px dashed var(--cg-border); border-radius: var(--cg-radius-medium); color: var(--cg-text-muted); text-align: center; }
.cg-empty strong { display: block; color: var(--cg-text); }

/* ---- Journey steps ---- */
.cg-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; counter-reset: cg-step; }
.cg-step { position: relative; display: flex; gap: 0.75rem; padding: 0 0 1rem; color: var(--cg-text-muted); }
.cg-step:last-child { padding-bottom: 0; }
.cg-step::after { content: ""; position: absolute; left: 0.8125rem; top: 1.75rem; bottom: 0.125rem; width: 2px; background: var(--cg-border); }
.cg-step:last-child::after { display: none; }
.cg-step-marker { counter-increment: cg-step; flex-shrink: 0; width: 1.75rem; height: 1.75rem; border-radius: 999px; display: inline-flex;
    align-items: center; justify-content: center; font-size: 0.8125rem; font-weight: 700; border: 2px solid var(--cg-border); background: var(--cg-surface); }
.cg-step-marker::before { content: counter(cg-step); }
.cg-step-label { padding-top: 0.125rem; }
.cg-step-label small { display: block; font-size: 0.8125rem; }
.cg-step-done { color: var(--cg-text); }
.cg-step-done .cg-step-marker { border-color: var(--cg-success); background: var(--cg-success); color: var(--cg-white); }
.cg-step-done .cg-step-marker::before { content: "✓"; }
.cg-step-current { color: var(--cg-text); font-weight: 600; }
.cg-step-current .cg-step-marker { border-color: var(--cg-primary); color: var(--cg-primary); }

/* ---- Numbers ---- */
.cg-stat-label { font-size: 0.875rem; color: var(--cg-text-muted); }
.cg-stat-value { font-family: var(--cg-font-numbers); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 2rem; line-height: 1.1; }

/* ---- Forms ---- */
.cg-field { display: grid; gap: 0.375rem; }
.cg-label { font-weight: 600; font-size: 0.9375rem; }
.cg-hint { font-size: 0.8125rem; color: var(--cg-text-muted); }
.cg-error { font-size: 0.875rem; color: var(--cg-danger); }
.cg-input { width: 100%; min-height: 2.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--cg-border); border-radius: var(--cg-radius-medium);
    background: var(--cg-surface); color: var(--cg-text); font: inherit; }
.cg-input:focus { outline: 3px solid var(--cg-focus); outline-offset: 0; border-color: var(--cg-focus); }
.cg-field-invalid .cg-input { border-color: var(--cg-danger); }
textarea.cg-input { min-height: 6rem; resize: vertical; }

/* ---- Wider screens ---- */
@media (min-width: 48rem) {
    .cg-main { padding-top: 2rem; }
    .cg-page-title { font-size: 1.875rem; }
    .cg-grid-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
    .cg-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cg-card { padding: 1.5rem; }
    .cg-theme-label { display: inline; }
    .cg-topbar-logo { height: 2.5rem; }
}

/* Files (portal Files page) */
.cg-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.cg-file { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding: 0.75rem 0.875rem; border: 1px solid var(--cg-border); border-radius: var(--cg-radius-large); background: var(--cg-surface); }
.cg-file-main { display: grid; gap: 0.25rem; min-width: 0; flex: 1 1 14rem; }
.cg-file-title { overflow-wrap: anywhere; }
/* MP3: budget options side by side on the plan approval; the chosen one is outlined. */
.cg-option { display: grid; align-content: start; gap: 0.25rem; padding: 0.875rem; border: 1px solid var(--cg-border); border-radius: var(--cg-radius-large); background: var(--cg-surface); }
.cg-option-chosen { border: 2px solid var(--cg-success); }
.cg-file-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; font-size: 0.8125rem; color: var(--cg-text-muted); }
.cg-file-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Approvals */
.cg-approval-text { padding: 0.875rem 1rem; border: 1px solid var(--cg-border); border-radius: var(--cg-radius-large); background: var(--cg-surface-muted); overflow-wrap: anywhere; }
.cg-check { display: flex; align-items: flex-start; gap: 0.5rem; cursor: pointer; }
.cg-check input { width: 1.125rem; height: 1.125rem; margin-top: 0.125rem; accent-color: var(--cg-primary); flex: none; }

/* Strategy (portal "Your strategy" page) */
.cg-strategy-text { overflow-wrap: anywhere; }
.cg-strategy-text p { margin: 0 0 0.75rem; }
.cg-strategy-text p:last-child, .cg-strategy-text ul:last-child { margin-bottom: 0; }
.cg-strategy-text ul { margin: 0 0 0.75rem; padding-left: 1.25rem; display: grid; gap: 0.25rem; }

/* Printing (e.g. "Print or save as PDF"): just the page content */
@media print {
    .cg-topbar, .cg-footer, .cg-skip, .cg-breadcrumb, .cg-no-print { display: none !important; }
    .cg-main { padding: 0; max-width: none; }
    .cg-card { break-inside: avoid; box-shadow: none; }
}

/* A document being signed (e.g. the contract): its exact wording, line breaks kept */
.cg-document-text { white-space: pre-wrap; line-height: 1.6; }

/* Creative (an ad's image or video, shown in full on any screen) */
.cg-creative-media { display: block; max-width: 100%; max-height: 32rem; height: auto; border-radius: var(--cg-radius-large); border: 1px solid var(--cg-border); }
/* SS2 R1: a social post shown as it will look on the feed */
.cg-social-preview { max-width: 32rem; border: 1px solid var(--cg-border); border-radius: var(--cg-radius-large); background: var(--cg-surface); overflow: hidden; }
.cg-social-preview-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 0.875rem 0.25rem; }
.cg-social-preview-text { padding: 0.25rem 0.875rem 0.75rem; }
.cg-social-preview-media { display: block; width: 100%; height: auto; max-height: 36rem; object-fit: cover; border-top: 1px solid var(--cg-border); }

/* Report bars: spend against budget, progress toward the target */
.cg-bar-label { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.875rem; margin-bottom: 0.375rem; }
.cg-bar { height: 0.75rem; border-radius: 999px; background: var(--cg-surface-muted); border: 1px solid var(--cg-border); overflow: hidden; }
.cg-bar > span { display: block; height: 100%; background: var(--cg-primary); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.cg-bar-success > span { background: var(--cg-success); }

/* Invoices */
.cg-invoice-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.cg-invoice-meta { text-align: right; display: grid; gap: 0.25rem; justify-items: end; }
.cg-invoice-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9375rem; }
.cg-invoice-table th, .cg-invoice-table td { text-align: left; padding: 0.5rem 0; border-bottom: 1px solid var(--cg-border); vertical-align: top; }
.cg-invoice-table .cg-num { text-align: right; white-space: nowrap; padding-left: 1rem; font-family: var(--cg-font-numbers); font-size: 1.0625rem; }
.cg-invoice-total td { font-weight: 700; border-bottom: 0; }

/* Public pages (privacy, terms, data deletion) */
.cg-legal { max-width: 46rem; }
.cg-legal h2 { font-size: 1.125rem; margin: 1.5rem 0 0.5rem; }
.cg-legal p, .cg-legal li { line-height: 1.6; }

/* Lead Generator: the public lead page (/l/{address}) and its website embed. */
.cg-lead-page { max-width: 40rem; }
.cg-lead-business { margin: 0 0 0.25rem; font-weight: 600; color: var(--cg-text-muted); }
.cg-lead-footer { margin-top: 1.25rem; text-align: center; }
.cg-embed { background: transparent; }
.cg-embed .cg-lead-page { padding-top: 0.5rem; }
/* A field people never see; simple spam bots fill it in. */
.cg-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
/* A small text button that looks like a link (e.g. "Copy link" next to a lead page). */
.cg-link-button { margin-left: 0.5rem; padding: 0; border: 0; background: none; color: var(--cg-link); font: inherit; font-size: 0.875rem; text-decoration: underline; cursor: pointer; }
