/*
 * Ads Insight Pro design layer, matching AutoContent Pro: grouped sidebar,
 * flat bordered cards and soft tables. Plain CSS on top of the compiled
 * Tailwind build, so no rebuild is needed. Works in light and dark mode.
 */

:root {
    --ch-radius: 14px;
    --ch-radius-sm: 10px;
    --ch-accent: #4820a0;
    --ch-accent-soft: rgba(72, 32, 160, .08);
    --ch-border: #e7e3de;
    --ch-soft: #f8f7f5;
    --ch-text: #1c1917;
    --ch-muted: #78716c;
    --ch-surface: #ffffff;
    --ch-sidebar: #fbfaf9;
}
html.dark {
    --ch-accent: #a48af7;
    --ch-accent-soft: rgba(164, 138, 247, .16);
    --ch-border: rgba(255, 255, 255, .09);
    --ch-soft: #211e1b;
    --ch-text: #f5f3f0;
    --ch-muted: #a8a29e;
    --ch-surface: #1c1917;
    --ch-sidebar: #171412;
}
/* No saved preference: follow the system, like the Tailwind build does. */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --ch-accent: #a48af7;
        --ch-accent-soft: rgba(164, 138, 247, .16);
        --ch-border: rgba(255, 255, 255, .09);
        --ch-soft: #211e1b;
        --ch-text: #f5f3f0;
        --ch-muted: #a8a29e;
        --ch-surface: #1c1917;
        --ch-sidebar: #171412;
    }
}

body { color: var(--ch-text); }

/* ---------- Sidebar ---------- */
#mobile-sidebar { border-right: 1px solid var(--ch-border) !important; }
.ch-brand { gap: 10px; padding: 0 20px; text-decoration: none; }
.ch-brand img { height: 32px; width: auto; background: #fff; border-radius: 8px; padding: 2px 4px; }
.ch-brand span { font-weight: 700; font-size: 15px; color: var(--ch-text); line-height: 1.15; border-left: 1px solid var(--ch-border); padding-left: 10px; }
.ch-nav-title {
    font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ch-muted); padding: 16px 12px 6px;
}
.ch-nav-title:first-child { padding-top: 4px; }
.ch-nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin: 1px 0; border-radius: var(--ch-radius-sm);
    font-size: 14px; font-weight: 500; color: var(--ch-text); text-decoration: none;
    transition: background .15s, color .15s;
}
.ch-nav-link:hover { background: var(--ch-soft); }
.ch-nav-link.is-active { background: var(--ch-accent-soft); color: var(--ch-accent); }
.ch-nav-icon { width: 20px; height: 20px; flex: 0 0 20px; color: var(--ch-muted); }
.ch-nav-link.is-active .ch-nav-icon { color: var(--ch-accent); }
.ch-nav-sub { margin: 2px 0 6px 22px; padding-left: 12px; border-left: 1px solid var(--ch-border); }
.ch-nav-sub a { display: block; padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--ch-muted); text-decoration: none; }
.ch-nav-sub a:hover { color: var(--ch-text); background: var(--ch-soft); }
.ch-nav-sub a.is-active { color: var(--ch-accent); font-weight: 600; }

/* ---------- Top bar ---------- */
header.sticky { border-bottom: 1px solid var(--ch-border) !important; }

/* ---------- Cards: flat with a hairline border ---------- */
#app-main-shell main .shadow-md,
#app-main-shell main .shadow-lg,
#app-main-shell main .shadow {
    box-shadow: none !important;
    border: 1px solid var(--ch-border);
}
#app-main-shell main .rounded-xl,
#app-main-shell main .rounded-lg.shadow-md { border-radius: var(--ch-radius) !important; }

/* ---------- Tables ---------- */
#app-main-shell main table thead th {
    font-size: 12px; font-weight: 600; letter-spacing: .04em;
    color: var(--ch-muted) !important; background: var(--ch-soft) !important;
}
#app-main-shell main table tbody tr:hover > td { background: var(--ch-soft); }

/* ---------- PostPro look: warm neutrals, white background ----------
 * The Tailwind build reads its colours from CSS variables, so re-pointing them re-colours every
 * gray utility at once, without a rebuild. Blue is intentionally NOT re-pointed here: it's used
 * both for the brand's primary buttons and for real semantic blue (info boxes, links, the active
 * tab underline). Re-pointing --color-blue-* globally made all of those indistinguishable shades
 * of purple. Buttons get purple back below, scoped to the literal bg-blue-600 class only. */
:root {
    --color-gray-50: #ffffff;
    --color-gray-100: #f5f3f0;
    --color-gray-200: #e7e3de;
    --color-gray-300: #ddd8d1;
    --color-gray-400: #a8a29e;
    --color-gray-500: #78716c;
    --color-gray-600: #57534e;
    --color-gray-700: #3a3532;
    --color-gray-800: #1c1917;
    --color-gray-900: #131110;
}
/* ---------- Primary buttons use the shared accent, not raw Tailwind blue ----------
 * #mobile-sidebar (the "Apply" filter button) and #app-main-shell (header/content, e.g. "Add
 * Card", "See plans") are siblings, not nested, so both need listing here. */
#mobile-sidebar .bg-blue-600, #app-main-shell .bg-blue-600 { background-color: var(--ch-accent) !important; }
#mobile-sidebar .hover\:bg-blue-700:hover, #app-main-shell .hover\:bg-blue-700:hover { background-color: #3d1a88 !important; }
html.dark #mobile-sidebar .hover\:bg-blue-700:hover, html.dark #app-main-shell .hover\:bg-blue-700:hover { background-color: #8f72e8 !important; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) #mobile-sidebar .hover\:bg-blue-700:hover,
    html:not([data-theme="light"]) #app-main-shell .hover\:bg-blue-700:hover { background-color: #8f72e8 !important; }
}
/* The build hard-codes the light-mode look of its dark: utilities; keep them white and warm too. */
html[data-theme=light] .dark\:bg-gray-900 { background-color: #fff !important; }
html[data-theme=light] .dark\:bg-gray-800 { background-color: #fff !important; }
html[data-theme=light] .dark\:bg-gray-700 { background-color: #f5f3f0 !important; }
html[data-theme=light] .dark\:text-gray-300, html[data-theme=light] .dark\:text-gray-400 { color: #57534e !important; }

body { background-color: var(--ch-surface); -webkit-font-smoothing: antialiased; }
#mobile-sidebar { background-color: var(--ch-sidebar) !important; width: 15.5rem; }
header.sticky { height: 3.5rem !important; }
#app-main-shell main .rounded-lg, #app-main-shell main .rounded-md { border-radius: 8px; }
#app-main-shell main input:focus, #app-main-shell main select:focus, #app-main-shell main textarea:focus { --tw-ring-color: rgba(72, 32, 160, .26); border-color: var(--ch-accent); }

/* ---------- Connections page (settings/api) ----------
 * One list row per connected account, quiet bordered buttons, and tabs that keep ad accounts,
 * CRM keys and admin tools apart. Tone colours are variables so pills read in both themes. */
:root { --cx-ok: #067647; --cx-warn: #b54708; --cx-bad: #b42318; --cx-info: #175cd3; }
html.dark { --cx-ok: #4ade80; --cx-warn: #fbbf24; --cx-bad: #f87171; --cx-info: #7cb4ff; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) { --cx-ok: #4ade80; --cx-warn: #fbbf24; --cx-bad: #f87171; --cx-info: #7cb4ff; }
}
.cx-root, .cx-stack { display: grid; gap: 20px; min-width: 0; }
.cx-root [hidden] { display: none !important; }
.cx-root h1 { font-size: 24px; font-weight: 700; color: var(--ch-text); }
.cx-sub { font-size: 13px; color: var(--ch-muted); }

.cx-tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; justify-self: start; background: var(--ch-soft); border: 1px solid var(--ch-border); border-radius: 12px; }
.cx-tab { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 500; color: var(--ch-muted); cursor: pointer; }
.cx-tab:hover { color: var(--ch-text); }
.cx-tab.is-active { background: var(--ch-surface); color: var(--ch-text); box-shadow: 0 0 0 1px var(--ch-border), 0 1px 2px rgba(0, 0, 0, .06); }
.cx-tab-count { font-size: 12px; padding: 0 7px; border-radius: 999px; background: var(--ch-accent-soft); color: var(--ch-accent); }

.cx-card { background: var(--ch-surface); border: 1px solid var(--ch-border); border-radius: var(--ch-radius); min-width: 0; }
.cx-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 14px 18px; }
.cx-card-head > .cx-grow { flex: 1 1 200px; min-width: 0; }
.cx-card-body { padding: 16px 18px; border-top: 1px solid var(--ch-border); }
.cx-logo { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px; display: grid; place-items: center; border: 1px solid var(--ch-border); background: var(--ch-soft); color: var(--ch-text); }
.cx-logo svg { width: 22px; height: 22px; }
.cx-logo-sm { width: 24px; height: 24px; flex-basis: 24px; border-radius: 6px; }
.cx-logo-sm svg { width: 14px; height: 14px; }
.cx-title { font-size: 15px; font-weight: 600; color: var(--ch-text); }

.cx-row { padding: 14px 18px; border-top: 1px solid var(--ch-border); }
.cx-row-main { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.cx-row-info { flex: 1 1 280px; min-width: 0; }
.cx-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--ch-text); }
.cx-icon-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--ch-muted); cursor: pointer; }
.cx-icon-btn:hover { background: var(--ch-soft); color: var(--ch-accent); }
.cx-meta { display: flex; flex-wrap: wrap; gap: 2px 16px; margin-top: 3px; font-size: 13px; color: var(--ch-muted); }
.cx-meta b { font-weight: 500; color: var(--ch-text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cx-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cx-actions form { display: inline-flex; }

.cx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--ch-border); border-radius: 8px; background: var(--ch-surface); color: var(--ch-text); font-size: 13px; font-weight: 500; line-height: 1.35; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
.cx-btn:hover { background: var(--ch-soft); }
.cx-btn:disabled { opacity: .55; cursor: default; }
.cx-btn svg { width: 15px; height: 15px; flex: 0 0 15px; }
.cx-btn-primary { background: var(--ch-accent); border-color: var(--ch-accent); color: var(--ch-surface); }
.cx-btn-primary:hover { background: var(--ch-accent); filter: brightness(.9); }
.cx-btn-danger { border-color: transparent; background: transparent; color: var(--cx-bad); }
.cx-btn-danger:hover { background: color-mix(in srgb, var(--cx-bad) 10%, transparent); }
.cx-link { padding: 0; border: 0; background: none; color: var(--ch-accent); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.cx-link:hover { text-decoration: underline; }

.cx-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--cx-tone, var(--ch-muted)); background: color-mix(in srgb, var(--cx-tone, var(--ch-muted)) 12%, transparent); }
.cx-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cx-ok { --cx-tone: var(--cx-ok); } .cx-warn { --cx-tone: var(--cx-warn); } .cx-bad { --cx-tone: var(--cx-bad); } .cx-info { --cx-tone: var(--cx-info); }

.cx-setting { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 12px; padding: 8px 12px; border-radius: 8px; background: var(--ch-soft); font-size: 13px; color: var(--ch-muted); }
.cx-setting b { font-weight: 500; color: var(--ch-text); }
.cx-panel { margin-top: 10px; padding: 14px; border: 1px solid var(--ch-border); border-radius: 10px; }
.cx-note { margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; color: var(--cx-tone, var(--ch-muted)); background: color-mix(in srgb, var(--cx-tone, var(--ch-muted)) 9%, transparent); border: 1px solid color-mix(in srgb, var(--cx-tone, var(--ch-muted)) 25%, transparent); }
.cx-note strong { font-weight: 600; }
.cx-progress { height: 6px; margin: 8px 0 6px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--cx-info) 20%, transparent); }
.cx-progress > div { height: 100%; border-radius: 999px; background: var(--cx-info); transition: width .3s; }

.cx-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--ch-muted); }
.cx-input { width: 100%; padding: 7px 10px; border: 1px solid var(--ch-border); border-radius: 8px; background: var(--ch-surface); color: var(--ch-text); font-size: 14px; }
.cx-help { margin-top: 4px; font-size: 12px; color: var(--ch-muted); }
.cx-fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cx-code { display: block; padding: 8px 12px; border-radius: 8px; background: var(--ch-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--ch-text); overflow-wrap: anywhere; }
.cx-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--ch-muted); }
.cx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cx-chips .cx-btn { padding: 3px 10px; font-size: 12px; }

/* ---------- API documentation ---------- */
.cx-doc-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.cx-toc { display: none; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; font-size: 13px; }
.cx-toc a { display: block; padding: 4px 12px; border-left: 2px solid var(--ch-border); color: var(--ch-muted); text-decoration: none; }
.cx-toc a.is-sub { padding-left: 24px; }
.cx-toc a:hover { color: var(--ch-text); }
.cx-toc a.is-active { border-left-color: var(--ch-accent); color: var(--ch-accent); font-weight: 600; }
@media (min-width: 1100px) {
    .cx-doc-layout { grid-template-columns: minmax(0, 1fr) 230px; }
    .cx-toc { display: block; }
}
.cx-doc { padding: 4px 28px 24px; font-size: 15px; line-height: 1.65; color: var(--ch-text); }
.cx-doc h2 { margin: 28px 0 10px; padding-top: 24px; border-top: 1px solid var(--ch-border); font-size: 20px; font-weight: 700; scroll-margin-top: 64px; }
.cx-doc h2:first-of-type { border-top: 0; padding-top: 0; }
.cx-doc h3 { margin: 26px 0 8px; font-size: 16px; font-weight: 600; scroll-margin-top: 76px; }
.cx-doc p { margin: 12px 0; }
.cx-doc ul, .cx-doc ol { margin: 12px 0; padding-left: 22px; }
.cx-doc ul { list-style: disc; } .cx-doc ol { list-style: decimal; }
.cx-doc li { margin: 5px 0; }
.cx-doc strong { font-weight: 600; }
.cx-doc code { padding: 1px 6px; border: 1px solid var(--ch-border); border-radius: 6px; background: var(--ch-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
.cx-doc-code { position: relative; margin: 12px 0 16px; }
.cx-doc-code pre { margin: 0; padding: 14px 16px; border: 1px solid var(--ch-border); border-radius: 10px; background: var(--ch-soft); overflow-x: auto; font-size: 13px; line-height: 1.55; }
.cx-doc-code pre code { padding: 0; border: 0; background: none; overflow-wrap: normal; white-space: pre; }
.cx-doc-code .cx-btn { position: absolute; top: 8px; right: 8px; padding: 3px 10px; font-size: 12px; }
@media (max-width: 640px) { .cx-doc { padding: 0 16px 18px; } }
