/* CofrePsico v1.4.0 — modo claro/escuro global e moldura do chat SophIA */
:root {
    --cp-theme-bg: #f4f7fb;
    --cp-theme-surface: #ffffff;
    --cp-theme-surface-2: #f8fafc;
    --cp-theme-text: #172b3a;
    --cp-theme-muted: #687c90;
    --cp-theme-line: #dce5ee;
    --cp-theme-accent: #536ee8;
    --cp-theme-accent-2: #21b7a8;
    --cp-theme-shadow: 0 18px 46px rgba(24, 45, 72, .12);
}

html[data-color-theme="light"] {
    color-scheme: light;
}

html[data-color-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1421;
    --surface: #141f31;
    --ink: #e8eef7;
    --muted: #9cacbf;
    --brand: #708bff;
    --brand2: #8fa5ff;
    --line: #2a3950;
    --danger: #ff8585;
    --warn: #f1c86c;
    --ok: #58d2a4;
    --shadow: 0 16px 42px rgba(0, 0, 0, .34);
    --admin-bg: #0b1220;
    --admin-card: #141f31;
    --admin-text: #e8eef7;
    --admin-muted: #9cacbf;
    --admin-line: #2a3950;
    --admin-shadow: 0 18px 46px rgba(0, 0, 0, .34);
    --cp-theme-bg: #0d1421;
    --cp-theme-surface: #141f31;
    --cp-theme-surface-2: #18253a;
    --cp-theme-text: #e8eef7;
    --cp-theme-muted: #9cacbf;
    --cp-theme-line: #2a3950;
    --cp-theme-accent: #7b91ff;
    --cp-theme-accent-2: #43d2c1;
    --cp-theme-shadow: 0 20px 54px rgba(0, 0, 0, .38);
}

.cp-theme-toggle {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 10000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 13px;
    border: 1px solid rgba(72, 94, 126, .24);
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    color: #20364d;
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    box-shadow: 0 12px 35px rgba(22, 42, 70, .18);
    backdrop-filter: blur(14px);
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}

.cp-theme-toggle:hover {
    transform: translateY(-2px);
    text-decoration: none;
}

.cp-theme-toggle:focus-visible {
    outline: 3px solid rgba(83, 110, 232, .32);
    outline-offset: 3px;
}

.cp-theme-toggle-icon {
    display: grid;
    place-items: center;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: linear-gradient(135deg, #536ee8, #21b7a8);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
}

html[data-color-theme="dark"] .cp-theme-toggle {
    border-color: #34455e;
    background: rgba(20, 31, 49, .94);
    color: #edf3fb;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .42);
}

/* Moldura mais evidente e elegante ao redor do chat. */
.sophia-choice-grid .sophia-chat-card {
    border: 2px solid #6279ea !important;
    border-radius: 26px !important;
    box-shadow:
        0 0 0 5px rgba(98, 121, 234, .11),
        0 24px 65px rgba(34, 54, 99, .17) !important;
}

.sophia-choice-grid .sophia-chat-card .sophia-chat-shell {
    border-radius: 23px;
    overflow: hidden;
}

html[data-color-theme="dark"] .sophia-choice-grid .sophia-chat-card {
    border-color: #7f94ff !important;
    background: #111b2b !important;
    box-shadow:
        0 0 0 5px rgba(127, 148, 255, .14),
        0 26px 70px rgba(0, 0, 0, .48) !important;
}

/* Superfícies gerais. */
html[data-color-theme="dark"],
html[data-color-theme="dark"] body {
    background: var(--bg);
    color: var(--ink);
}

html[data-color-theme="dark"] body,
html[data-color-theme="dark"] .main,
html[data-color-theme="dark"] .content,
html[data-color-theme="dark"] .employee-main,
html[data-color-theme="dark"] .admin-main,
html[data-color-theme="dark"] .admin-content {
    background-color: var(--bg);
    color: var(--ink);
}

html[data-color-theme="dark"] h1,
html[data-color-theme="dark"] h2,
html[data-color-theme="dark"] h3,
html[data-color-theme="dark"] h4,
html[data-color-theme="dark"] strong,
html[data-color-theme="dark"] label {
    color: var(--ink);
}

html[data-color-theme="dark"] .muted,
html[data-color-theme="dark"] .help,
html[data-color-theme="dark"] .small,
html[data-color-theme="dark"] .footer-note,
html[data-color-theme="dark"] .empty {
    color: var(--muted);
}

html[data-color-theme="dark"] a:not(.btn) {
    color: #8fa5ff;
}

html[data-color-theme="dark"] .card,
html[data-color-theme="dark"] .auth-card,
html[data-color-theme="dark"] .survey-card,
html[data-color-theme="dark"] .install-card,
html[data-color-theme="dark"] .signup-card,
html[data-color-theme="dark"] .success-card,
html[data-color-theme="dark"] .dossier,
html[data-color-theme="dark"] .company-code,
html[data-color-theme="dark"] .usage-pill,
html[data-color-theme="dark"] .subscription-card {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

html[data-color-theme="dark"] input,
html[data-color-theme="dark"] select,
html[data-color-theme="dark"] textarea {
    border-color: #34455e;
    background: #101a2a;
    color: #edf3fb;
}

html[data-color-theme="dark"] input::placeholder,
html[data-color-theme="dark"] textarea::placeholder {
    color: #7f91a8;
    opacity: 1;
}

html[data-color-theme="dark"] input:focus,
html[data-color-theme="dark"] select:focus,
html[data-color-theme="dark"] textarea:focus {
    border-color: #7f94ff;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(127, 148, 255, .14);
}

html[data-color-theme="dark"] .btn.secondary,
html[data-color-theme="dark"] .btn.ghost,
html[data-color-theme="dark"] .file-picker {
    border-color: #34455e;
    background: #1b2940;
    color: #e6edf7;
}

html[data-color-theme="dark"] .btn.secondary:hover,
html[data-color-theme="dark"] .btn.ghost:hover,
html[data-color-theme="dark"] .file-picker:hover {
    background: #24344e;
}

html[data-color-theme="dark"] .table-wrap {
    border-color: var(--line);
}

html[data-color-theme="dark"] table {
    background: var(--surface);
    color: var(--ink);
}

html[data-color-theme="dark"] th {
    border-color: var(--line);
    background: #19263a;
    color: #aebed1;
}

html[data-color-theme="dark"] td,
html[data-color-theme="dark"] tr {
    border-color: var(--line);
}

html[data-color-theme="dark"] tbody tr:hover {
    background: rgba(127, 148, 255, .045);
}

html[data-color-theme="dark"] .badge,
html[data-color-theme="dark"] .status-pill {
    border-color: #34455e;
    background: #203047;
    color: #dbe6f4;
}

html[data-color-theme="dark"] .alert.success {
    border-color: #27644f;
    background: #15382e;
    color: #baf0dc;
}

html[data-color-theme="dark"] .alert.warning {
    border-color: #66572d;
    background: #3c3218;
    color: #f5dda0;
}

html[data-color-theme="dark"] .alert.danger {
    border-color: #6f383e;
    background: #3d2025;
    color: #ffc6ca;
}

html[data-color-theme="dark"] .notice {
    background: #17263a;
    color: #d5e0ed;
}

html[data-color-theme="dark"] .bar {
    background: #26364c;
}

/* Acesso, instalação e pesquisa. */
html[data-color-theme="dark"] .auth-shell,
html[data-color-theme="dark"] .survey-shell,
html[data-color-theme="dark"] .install-shell {
    background:
        radial-gradient(circle at 85% 10%, rgba(112, 139, 255, .16), transparent 30%),
        linear-gradient(145deg, #0b1220, #101b2b);
}

html[data-color-theme="dark"] .question,
html[data-color-theme="dark"] .option label {
    border-color: var(--line);
}

html[data-color-theme="dark"] .option label {
    background: #162236;
    color: var(--ink);
}

html[data-color-theme="dark"] .option input:checked + label {
    border-color: #7f94ff;
    background: #263966;
}

/* Área da empresa e colaborador. */
html[data-color-theme="dark"] .topbar,
html[data-color-theme="dark"] .employee-header {
    border-color: var(--line);
    background: rgba(20, 31, 49, .94);
    color: var(--ink);
}

html[data-color-theme="dark"] .employee-body {
    background: var(--bg);
}

html[data-color-theme="dark"] .campaign-list article,
html[data-color-theme="dark"] .privacy-card,
html[data-color-theme="dark"] .employee-sophia-card {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

html[data-color-theme="dark"] .campaign-list p,
html[data-color-theme="dark"] .employee-sophia-card p,
html[data-color-theme="dark"] .employee-sophia-tags span {
    color: var(--muted);
}

/* Administração Master. */
html[data-color-theme="dark"] .admin-body {
    background: var(--admin-bg);
    color: var(--admin-text);
}

html[data-color-theme="dark"] .admin-topbar {
    border-color: rgba(53, 72, 96, .9);
    background: rgba(14, 23, 37, .92);
}

html[data-color-theme="dark"] .admin-topbar h1,
html[data-color-theme="dark"] .admin-content,
html[data-color-theme="dark"] .admin-content .card {
    color: var(--admin-text);
}

html[data-color-theme="dark"] .admin-content .card,
html[data-color-theme="dark"] .admin-content .metric-card,
html[data-color-theme="dark"] .admin-content .stats .card,
html[data-color-theme="dark"] .theme-choice-card,
html[data-color-theme="dark"] .theme-save-bar,
html[data-color-theme="dark"] .landing-editor-section,
html[data-color-theme="dark"] .lead-card,
html[data-color-theme="dark"] .lead-summary-card {
    border-color: var(--admin-line);
    background: var(--admin-card);
    color: var(--admin-text);
    box-shadow: var(--admin-shadow);
}

html[data-color-theme="dark"] .admin-menu-open {
    border-color: var(--admin-line);
    background: #17243a;
}

html[data-color-theme="dark"] .admin-menu-open span {
    background: #d9e4f1;
}

html[data-color-theme="dark"] .admin-secure-badge {
    border-color: #2e5d50;
    background: #16362e;
    color: #a8ebd3;
}

html[data-color-theme="dark"] .landing-editor-section-head,
html[data-color-theme="dark"] .editor-divider {
    border-color: var(--line);
}

html[data-color-theme="dark"] .hero-upload-card,
html[data-color-theme="dark"] .stat-editor-grid article,
html[data-color-theme="dark"] .faq-editor-list details,
html[data-color-theme="dark"] .content-editor-card,
html[data-color-theme="dark"] .process-editor-list article,
html[data-color-theme="dark"] .checklist-editor-grid article,
html[data-color-theme="dark"] .section-image-editor,
html[data-color-theme="dark"] .sophia-avatar-upload-form,
html[data-color-theme="dark"] .knowledge-upload-form,
html[data-color-theme="dark"] .knowledge-document-row,
html[data-color-theme="dark"] .knowledge-result-limit,
html[data-color-theme="dark"] .toggle-panel,
html[data-color-theme="dark"] .ai-channel-row,
html[data-color-theme="dark"] .company-access-card,
html[data-color-theme="dark"] .company-password-grid,
html[data-color-theme="dark"] .company-access-summary {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

html[data-color-theme="dark"] .hero-upload-preview,
html[data-color-theme="dark"] .section-image-preview {
    border-color: var(--line);
    background: #19263a;
}

html[data-color-theme="dark"] .landing-editor-notice,
html[data-color-theme="dark"] .knowledge-privacy-note,
html[data-color-theme="dark"] .ai-warning-card,
html[data-color-theme="dark"] .company-password-warning,
html[data-color-theme="dark"] .company-current-password-note {
    border-color: #3b4e68;
    background: #18263a;
    color: #c7d5e5;
}

html[data-color-theme="dark"] .ai-admin-form h2,
html[data-color-theme="dark"] .ai-channel-admin h2,
html[data-color-theme="dark"] .ai-channel-company strong,
html[data-color-theme="dark"] .knowledge-document-info strong,
html[data-color-theme="dark"] .knowledge-upload-grid label,
html[data-color-theme="dark"] .knowledge-privacy-note strong {
    color: var(--ink);
}

html[data-color-theme="dark"] .ai-warning-card strong,
html[data-color-theme="dark"] .ai-warning-card p,
html[data-color-theme="dark"] .toggle-panel small,
html[data-color-theme="dark"] .ai-channel-company span,
html[data-color-theme="dark"] .knowledge-document-info span,
html[data-color-theme="dark"] .knowledge-document-info small,
html[data-color-theme="dark"] .knowledge-upload-grid small,
html[data-color-theme="dark"] .knowledge-result-limit small {
    color: var(--muted);
}

html[data-color-theme="dark"] .toggle-panel:has(input:checked) {
    border-color: #6f83e8;
    background: #202e53;
    box-shadow: 0 0 0 3px rgba(111, 131, 232, .12);
}

html[data-color-theme="dark"] .sophia-directives-textarea {
    background: #0f1929;
    color: #e6edf7;
}

/* Landing pública nos três temas. */
html[data-color-theme="dark"] .landing-theme-corporate,
html[data-color-theme="dark"] .landing-theme-modern,
html[data-color-theme="dark"] .landing-theme-premium {
    --ink: #edf3fb;
    --muted: #a3b3c7;
    --line: #2b3b52;
    --bg: #0d1421;
    --surface: #141f31;
    --landing-soft: #18263a;
    --landing-dark: #080d16;
    --landing-shadow: rgba(0, 0, 0, .42);
}

html[data-color-theme="dark"] .landing-theme-corporate {
    --brand: #7192ff;
    --brand2: #91a8ff;
    --landing-accent: #42d6a5;
}

html[data-color-theme="dark"] .landing-theme-modern {
    --brand: #9a83ff;
    --brand2: #b1a1ff;
    --landing-accent: #43d7c5;
}

html[data-color-theme="dark"] .landing-theme-premium {
    --brand: #d4a84f;
    --brand2: #e1c17d;
    --landing-accent: #e2bd72;
}

html[data-color-theme="dark"] .public-body {
    background: var(--bg);
    color: var(--ink);
}

html[data-color-theme="dark"] .public-header {
    border-color: var(--line);
    background: rgba(13, 20, 33, .92);
}

html[data-color-theme="dark"] .public-brand,
html[data-color-theme="dark"] .public-nav nav > a:not(.btn),
html[data-color-theme="dark"] .public-footer strong {
    color: var(--ink);
}

html[data-color-theme="dark"] .hero {
    border-color: var(--line);
    background:
        radial-gradient(circle at 84% 18%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 28%),
        linear-gradient(145deg, #0d1626, #111d30 58%, #0c1422);
}

html[data-color-theme="dark"] .hero h1,
html[data-color-theme="dark"] .hero-proof strong {
    color: #f4f7fb;
}

html[data-color-theme="dark"] .hero p,
html[data-color-theme="dark"] .trust-line,
html[data-color-theme="dark"] .hero-proof span,
html[data-color-theme="dark"] .section-heading p,
html[data-color-theme="dark"] .page-hero p,
html[data-color-theme="dark"] .signup-copy > p,
html[data-color-theme="dark"] .feature-card p,
html[data-color-theme="dark"] .steps p,
html[data-color-theme="dark"] .price span,
html[data-color-theme="dark"] .price small,
html[data-color-theme="dark"] .security-list span {
    color: var(--muted);
}

html[data-color-theme="dark"] .soft-section,
html[data-color-theme="dark"] .implementation-v120,
html[data-color-theme="dark"] .topics-v120,
html[data-color-theme="dark"] .errors-v120,
html[data-color-theme="dark"] .split-content-section:nth-of-type(even) {
    background: linear-gradient(180deg, #101a2a, #0d1421);
}

html[data-color-theme="dark"] .hero-panel,
html[data-color-theme="dark"] .feature-card,
html[data-color-theme="dark"] .steps > div,
html[data-color-theme="dark"] .price-card,
html[data-color-theme="dark"] .benefit-showcase,
html[data-color-theme="dark"] .benefit-node,
html[data-color-theme="dark"] .floating-card,
html[data-color-theme="dark"] .testimonial-card,
html[data-color-theme="dark"] .contact-panel,
html[data-color-theme="dark"] .faq-list details,
html[data-color-theme="dark"] .service-card-v120,
html[data-color-theme="dark"] .implementation-list li,
html[data-color-theme="dark"] .order-checklist-grid article,
html[data-color-theme="dark"] .topics-grid-v120 > div,
html[data-color-theme="dark"] .public-legal-disclaimer {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

html[data-color-theme="dark"] .service-card-v120,
html[data-color-theme="dark"] .order-checklist-grid article,
html[data-color-theme="dark"] .benefit-showcase {
    background: linear-gradient(150deg, #141f31, #18263a);
}

html[data-color-theme="dark"] .service-card-symbol,
html[data-color-theme="dark"] .split-content-visual,
html[data-color-theme="dark"] .implementation-visual,
html[data-color-theme="dark"] .order-service-image,
html[data-color-theme="dark"] .content-visual-fallback {
    background: linear-gradient(145deg, #18263a, #20304a);
}

html[data-color-theme="dark"] .service-card-body p,
html[data-color-theme="dark"] .implementation-list p,
html[data-color-theme="dark"] .order-service-copy p,
html[data-color-theme="dark"] .order-checklist-grid p,
html[data-color-theme="dark"] .split-content-copy > p,
html[data-color-theme="dark"] .order-service-head > p,
html[data-color-theme="dark"] .technical-note,
html[data-color-theme="dark"] .public-legal-disclaimer {
    color: var(--muted);
}

html[data-color-theme="dark"] .technical-note {
    background: #17263a;
}

html[data-color-theme="dark"] .service-tag,
html[data-color-theme="dark"] .feature-number,
html[data-color-theme="dark"] .large-check-list li span {
    background: #203653;
    color: #aebeff;
}

html[data-color-theme="dark"] .contact-form input,
html[data-color-theme="dark"] .contact-form textarea {
    background: #101a2a;
}

html[data-color-theme="dark"] .public-footer,
html[data-color-theme="dark"] .connectsystem-footer {
    border-color: var(--line);
    background: #0f1928;
    color: var(--muted);
}

html[data-color-theme="dark"] .connectsystem-footer a {
    color: #8fa5ff;
}

/* SophIA: canal, relatos e chat. */
html[data-color-theme="dark"] .sophia-channel-hero,
html[data-color-theme="dark"] .sophia-choice-card,
html[data-color-theme="dark"] .sophia-report-card,
html[data-color-theme="dark"] .sophia-status-card,
html[data-color-theme="dark"] .sophia-answer-box,
html[data-color-theme="dark"] .sophia-question-box,
html[data-color-theme="dark"] .status-result-card,
html[data-color-theme="dark"] .report-original-text,
html[data-color-theme="dark"] .report-summary-cell {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

html[data-color-theme="dark"] .sophia-chat-shell {
    background: linear-gradient(180deg, #111c2d, #0e1827);
}

html[data-color-theme="dark"] .sophia-chat-header,
html[data-color-theme="dark"] .sophia-chat-composer {
    border-color: var(--line);
    background: rgba(20, 31, 49, .97);
}

html[data-color-theme="dark"] .sophia-chat-title {
    color: #edf3fb;
}

html[data-color-theme="dark"] .sophia-chat-subtitle,
html[data-color-theme="dark"] .sophia-chat-meta,
html[data-color-theme="dark"] .sophia-chat-composer-meta {
    color: #91a3b9;
}

html[data-color-theme="dark"] .sophia-chat-privacy {
    border-color: #34455e;
    background: #19263a;
    color: #aebed1;
}

html[data-color-theme="dark"] .sophia-chat-bubble-assistant {
    border-color: #304059;
    background: #18253a;
    color: #e5edf7;
    box-shadow: 0 9px 26px rgba(0, 0, 0, .24);
}

html[data-color-theme="dark"] .sophia-chat-safety-note {
    border-color: #2c3b51;
    color: #9bacc0;
}

html[data-color-theme="dark"] .sophia-chat-suggestions button {
    border-color: #354762;
    background: #17243a;
    color: #bccbdb;
}

html[data-color-theme="dark"] .sophia-chat-suggestions button:hover {
    border-color: #7f94ff;
    background: #223253;
}

html[data-color-theme="dark"] .sophia-chat-input-wrap {
    border-color: #3a4c67;
    background: #101a2a;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .24);
}

html[data-color-theme="dark"] .sophia-chat-input-wrap textarea {
    background: transparent;
    color: #eef4fb;
}

html[data-color-theme="dark"] .sophia-chat-detail {
    background: #15362f;
    color: #b5f0dc;
}

html[data-color-theme="dark"] .sophia-chat-sources {
    border-color: #3a456c;
    background: #1b2340;
    color: #c0cbe0;
}

html[data-color-theme="dark"] .sophia-chat-alert {
    border-color: #704047;
    background: #3d2025;
    color: #ffc9cd;
}

html[data-color-theme="dark"] .sophia-boundary,
html[data-color-theme="dark"] .privacy-callout,
html[data-color-theme="dark"] .sophia-emergency-note {
    border-color: var(--line);
    background: #17263a;
    color: #c8d5e4;
}

@media (max-width: 620px) {
    .cp-theme-toggle {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        width: 44px;
        min-width: 44px;
        padding: 8px;
    }

    .cp-theme-toggle-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .sophia-choice-grid .sophia-chat-card {
        border-radius: 20px !important;
        box-shadow:
            0 0 0 3px rgba(98, 121, 234, .11),
            0 18px 42px rgba(34, 54, 99, .15) !important;
    }

    .sophia-choice-grid .sophia-chat-card .sophia-chat-shell {
        border-radius: 17px;
    }
}

@media (prefers-reduced-motion: no-preference) {
    body,
    .card,
    .topbar,
    .employee-header,
    .public-header,
    .admin-topbar,
    input,
    select,
    textarea {
        transition: background-color .2s ease, color .2s ease, border-color .2s ease;
    }
}

@media print {
    html,
    body {
        background: #fff !important;
        color: #000 !important;
        color-scheme: light !important;
    }

    .cp-theme-toggle {
        display: none !important;
    }
}
