/**
 * 247ChatMate — Admin Page Gap Ownership
 * Phase: 5-A-20H-3A
 * Checkpoint: ADMINPAGEGAPVALUECORRECTION5A20H3ALOCK
 *
 * Purpose:
 * - Own the final topbar-to-first-visible-card vertical gap for split admin pages.
 * - Use the Setup page rhythm as the master reference.
 * - Apply the same OUTER page gap to Dashboard, Setup, Appearance & pages,
 *   and Visitor Buttons without touching internal card layouts.
 *
 * Guardrails:
 * - Do not target Visitor Buttons internals.
 * - Do not alter chip grids, chip dimensions, chip helper/action boxes,
 *   frontend widget CSS, dashboard circles, lead routing, weekly summary,
 *   licence/trial logic, vertical JSON or the custom save handler.
 */

@media (min-width: 1181px) {
    .matewa-dashboard-page {
        /* Setup is the approved visual reference: 14px base + 4px seating compensation. */
        --matewa-admin-page-card-gap: calc(var(--matewa-admin-visual-top-gap, 14px) + 4px);
    }

    /* Reset page wrappers so only the first visible rear surface owns the vertical gap. */
    .matewa-dashboard-page[data-matewa-active-panel="dashboard"] #matewa-admin-panel-dashboard,
    .matewa-dashboard-page[data-matewa-active-panel="setup"] #matewa-settings-form,
    .matewa-dashboard-page[data-matewa-active-panel="display"] #matewa-settings-form,
    .matewa-dashboard-page[data-matewa-active-panel="buttons"] #matewa-settings-form,
    .matewa-dashboard-page #matewa-admin-panel-setup,
    .matewa-dashboard-page #matewa-chip-labels-section {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* One shared outer gap contract. Do not style anything inside these cards here. */
    .matewa-dashboard-page[data-matewa-active-panel="dashboard"] #matewa-admin-panel-dashboard > .matewa-dashboard-value-card,
    .matewa-dashboard-page[data-matewa-active-panel="setup"] #matewa-admin-panel-setup > .matewa-core-settings-shell,
    .matewa-dashboard-page[data-matewa-active-panel="display"] #matewa-admin-panel-setup > .matewa-core-settings-shell,
    .matewa-dashboard-page[data-matewa-active-panel="buttons"] #matewa-chip-labels-section > .matewa-chip-studio-card {
        margin-top: var(--matewa-admin-page-card-gap) !important;
    }
}

/* ======================================================================
   247ChatMate — AGENCYDARKMODEPOLISH1
   Scope: dark-mode visual polish only for Agency Hub, Dashboard agency
   card, agency licence controls and Appearance & pages targeting list.
   No licence, seat, widget, chip, WhatsApp, lead or summary logic changes.
====================================================================== */

/* Agency buttons should use the same green / outline language as the admin topbar. */
.matewa-dashboard-page .matewa-agency-hub-hero-actions .button.button-primary,
.matewa-dashboard-page .matewa-agency-bundle-entry-controls .button.button-primary,
.matewa-dashboard-page .matewa-agency-bundle-panel .button.button-primary,
.matewa-dashboard-page .matewa-license-save-refresh__actions .matewa-agency-buy-licences-button.button-primary {
    background: linear-gradient(135deg, var(--matewa-polish-green, #16a34a), var(--matewa-polish-green-deep, #15803d)) !important;
    border: 1px solid rgba(21, 128, 61, 0.48) !important;
    color: #ffffff !important;
    text-shadow: none !important;
    box-shadow: 0 14px 30px rgba(22, 163, 74, 0.22) !important;
}

.matewa-dashboard-page .matewa-agency-hub-hero-actions .button.button-primary:hover,
.matewa-dashboard-page .matewa-agency-bundle-entry-controls .button.button-primary:hover,
.matewa-dashboard-page .matewa-agency-bundle-panel .button.button-primary:hover,
.matewa-dashboard-page .matewa-license-save-refresh__actions .matewa-agency-buy-licences-button.button-primary:hover,
.matewa-dashboard-page .matewa-agency-hub-hero-actions .button.button-primary:focus-visible,
.matewa-dashboard-page .matewa-agency-bundle-entry-controls .button.button-primary:focus-visible,
.matewa-dashboard-page .matewa-agency-bundle-panel .button.button-primary:focus-visible,
.matewa-dashboard-page .matewa-license-save-refresh__actions .matewa-agency-buy-licences-button.button-primary:focus-visible {
    background: linear-gradient(135deg, var(--matewa-polish-green-deep, #15803d), var(--matewa-polish-green, #16a34a)) !important;
    border-color: rgba(34, 197, 94, 0.64) !important;
    color: #ffffff !important;
    box-shadow: 0 18px 38px rgba(22, 163, 74, 0.28), 0 0 0 3px rgba(34, 197, 94, 0.14) !important;
    outline: none !important;
}

.matewa-dashboard-page .matewa-agency-hub-hero-actions .button:not(.button-primary),
.matewa-dashboard-page .matewa-agency-bundle-panel .button:not(.button-primary) {
    background: rgba(255, 255, 255, 0.88) !important;
    border: 1px solid rgba(22, 163, 74, 0.34) !important;
    color: var(--matewa-polish-green-deep, #15803d) !important;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06) !important;
}

/* Dashboard agency plan card: stop light-card/dark-text conflicts in dark mode. */
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency {
    background:
        radial-gradient(circle at top right, rgba(74, 222, 128, 0.18), transparent 58%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.96)) !important;
    border-color: rgba(74, 222, 128, 0.30) !important;
    color: #f8fafc !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency span,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency strong,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency small,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency em {
    color: #f8fafc !important;
    opacity: 1 !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency span {
    color: #86efac !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency small {
    color: #d7e2ee !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-dashboard-plan-nudge.is-agency em {
    background: rgba(74, 222, 128, 0.16) !important;
    color: #86efac !important;
}

/* Agency Hub dark surfaces and table headers. */
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-hub-hero,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-hub-stat-card,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-client-board,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-bundle-panel,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-bundle-entry,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-client-table-wrap {
    background:
        radial-gradient(circle at 92% 0%, rgba(74, 222, 128, 0.07), transparent 42%),
        rgba(15, 23, 42, 0.94) !important;
    border-color: rgba(74, 222, 128, 0.22) !important;
    color: #f8fafc !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-client-table th {
    background: rgba(30, 41, 59, 0.96) !important;
    color: #f8fafc !important;
    border-bottom-color: rgba(148, 163, 184, 0.28) !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-client-table td {
    color: #d7e2ee !important;
    border-bottom-color: rgba(148, 163, 184, 0.18) !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-client-table td strong {
    color: #ffffff !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-client-table td > span:not(.matewa-agency-table-pill) {
    color: #b8c7d8 !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-table-pill.is-ready,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-bundle-notice.is-success {
    background: rgba(74, 222, 128, 0.14) !important;
    border-color: rgba(74, 222, 128, 0.28) !important;
    color: #86efac !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-table-pill.is-warning,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-bundle-notice.is-warning {
    background: rgba(245, 158, 11, 0.12) !important;
    border-color: rgba(251, 191, 36, 0.28) !important;
    color: #fcd34d !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-soft-pill,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-soft-pill.is-link {
    background: rgba(74, 222, 128, 0.13) !important;
    border-color: rgba(74, 222, 128, 0.28) !important;
    color: #bbf7d0 !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-hub-hero-actions .button:not(.button-primary),
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-agency-bundle-panel .button:not(.button-primary) {
    background: rgba(15, 23, 42, 0.92) !important;
    border-color: rgba(134, 239, 172, 0.34) !important;
    color: #bbf7d0 !important;
}

/* Appearance & pages dark-mode readability. */
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-targeting-box,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-checkbox-list,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-checkbox-row {
    background: rgba(15, 23, 42, 0.72) !important;
    border-color: rgba(148, 163, 184, 0.24) !important;
    color: #f8fafc !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-targeting-box > strong,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-checkbox-title {
    color: #f8fafc !important;
    opacity: 1 !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-targeting-box > p,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-checkbox-url {
    color: #93c5fd !important;
    opacity: 1 !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-page-checkbox-row input[type="checkbox"] {
    background-color: #f8fafc !important;
    border-color: rgba(203, 213, 225, 0.78) !important;
}

/* =========================================================
   247ChatMate — Dark Mode Business Selector + Chip Softening
   Checkpoint: AGENCYDARKMODEPOLISH1A
   Scope: visual-only correction for dark-mode select dropdowns and
   admin chip contrast. No widget, chip data, licence, lead, WhatsApp,
   summary, visitor-button logic or save handling changes.
   ========================================================= */

/* Native select menus need explicit dark colour-scheme/option colours,
   otherwise some browsers open the dropdown as white with low contrast. */
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-selector-grid select,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-card select,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-core-settings-shell select {
    color-scheme: dark !important;
    background-color: rgba(15, 23, 42, 0.96) !important;
    color: #e5edf7 !important;
    border-color: rgba(148, 163, 184, 0.32) !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select option,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select optgroup {
    background-color: #0f172a !important;
    color: #e5edf7 !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select option:checked,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select option:hover,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select option:focus {
    background-color: #1e293b !important;
    color: #ffffff !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select:disabled,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] select option:disabled {
    background-color: rgba(15, 23, 42, 0.62) !important;
    color: #94a3b8 !important;
}

/* Tone down admin chips in dark mode: keep them readable and calm, with
   green used as an accent rather than a heavy fill/border. */
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip.is-preview,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-box.is-live,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-editor-panel .matewa-chip-editor-chip,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-preview-panel .matewa-chip-editor-chip,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-default-preview .matewa-chip-editor-chip {
    background: rgba(15, 23, 42, 0.78) !important;
    border-color: rgba(148, 163, 184, 0.24) !important;
    color: #e2e8f0 !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.018), 0 8px 18px rgba(0, 0, 0, 0.16) !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip span,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-text,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip textarea,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip textarea:focus,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-editor-panel .matewa-chip-editor-chip textarea,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-preview-panel .matewa-chip-editor-chip span,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-default-preview .matewa-chip-editor-chip span {
    color: #e2e8f0 !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip:hover,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-editor-panel .matewa-chip-editor-chip:hover,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-preview-panel .matewa-chip-editor-chip:hover {
    border-color: rgba(134, 239, 172, 0.36) !important;
    background: rgba(18, 31, 45, 0.92) !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip.is-changed,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-editor-panel .matewa-chip-editor-chip.is-changed {
    border-color: rgba(134, 239, 172, 0.42) !important;
    box-shadow: inset 0 0 0 1px rgba(134, 239, 172, 0.14), 0 0 0 3px rgba(134, 239, 172, 0.055) !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-editor-chip:focus-within,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-editor-panel .matewa-chip-editor-chip:focus-within {
    border-color: rgba(134, 239, 172, 0.52) !important;
    box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.10) !important;
}

.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-default-preview,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-phone,
.matewa-dashboard-page[data-matewa-dashboard-theme="dark"] .matewa-chip-studio-chat-card {
    background: rgba(15, 23, 42, 0.62) !important;
    border-color: rgba(148, 163, 184, 0.20) !important;
}
