/*
 * DEEPCHAT Full-Bleed Admin Canvas (10px Inset), 2-Layer WP Notice Suppression,
 * 3-Zone Popup Shell, Domain Lock & Zero-CLS 1:1 Structural Skeletons.
 * Contains zero hard-coded colors or fixed font-pixel skeleton heights.
 */

/* ==========================================================================
   1. Full-Bleed WP Admin Canvas + Outer Viewport Inset = 10px
   ========================================================================== */

/* Full-bleed themed WP canvas matching DEEPTASK ambient gradient in Light & Dark */
html:has(body:is(.dc-admin-screen, .dc-page)),
body:is(.dc-admin-screen, .dc-page) {
    background-color: var(--deepchat-color-bg) !important;
    background-image: none !important;
    color-scheme: var(--deepchat-color-scheme);
}

html:has(body:is(.dc-admin-screen, .dc-page)) {
    scrollbar-gutter: stable;
}

body:is(.dc-admin-screen, .dc-page) #wpwrap,
body:is(.dc-admin-screen, .dc-page) #wpbody,
body:is(.dc-admin-screen, .dc-page) #wpbody-content {
    background-color: var(--deepchat-color-transparent) !important;
    background-image: none !important;
}

body:is(.dc-admin-screen, .dc-page) #wpcontent {
    min-height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
    min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px));
    background-color: var(--deepchat-color-bg) !important;
    background-image: var(--deepchat-color-gradient-app) !important;
    background-repeat: no-repeat !important;
    background-size: 100% 100vh !important;
    background-attachment: fixed !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

body.dc-admin-screen #wpbody-content,
body.dc-page #wpbody-content {
    padding-bottom: 0 !important;
}

body.dc-admin-screen #wpfooter,
body.dc-page #wpfooter {
    display: none !important;
}

/* 2-Layer WP Notice Suppression (Layer 2 — CSS Backup covering notices moved inside .wrap by WP common.js) */
body:is(.dc-admin-screen, .dc-page, [class*="deepchat"]) #wpbody-content :is(.notice,
    .updated,
    .update-nag,
    .update-message,
    .elementor-message,
    .e-notice,
    .woodmart-notice,
    #setting-error-tgmpa,
    #message):not(.dc-notice),
body:is(.dc-admin-screen, .dc-page, [class*="deepchat"]) #wpbody-content > .error:not(.dc-notice),
body:is(.dc-admin-screen, .dc-page, [class*="deepchat"]) #wpbody-content > .wrap > .error:not(.dc-notice),
body:is(.dc-admin-screen, .dc-page, [class*="deepchat"]) :is(.wrap, .dc-admin) :is(.notice,
    .updated,
    .update-nag,
    .error,
    .update-message,
    .elementor-message,
    .e-notice,
    .woodmart-notice,
    #setting-error-tgmpa,
    #message):not(.dc-notice) {
    display: none !important;
}

body:is(.dc-admin-screen, .dc-page) .wrap.dc-admin {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: var(--deepchat-viewport-inset) !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--deepchat-color-transparent) !important;
    background-image: none !important;
    color: var(--deepchat-color-text);
    color-scheme: var(--deepchat-color-scheme);
    min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px));
    position: relative;
    isolation: isolate;
}

body.dc-chat-inbox-screen .wrap.dc-admin.dc-chat-inbox-page {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px)) !important;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 782px) {
    body:is(.dc-admin-screen, .dc-page) .wrap.dc-admin {
        min-height: calc(100dvh - 46px);
    }
    body.dc-chat-inbox-screen .wrap.dc-admin.dc-chat-inbox-page {
        height: calc(100dvh - 46px) !important;
    }
}

/* ==========================================================================
   2. 3-Zone Popup Shell & Mobile 10px Inset Contract
   ========================================================================== */

.dc-popup {
    display: flex;
    flex-direction: column;
    overflow: clip;
    border-radius: calc(var(--deepchat-radius) + var(--deepchat-dropdown-panel-padding));
    background: var(--deepchat-color-popup-bg);
    border: 1px solid var(--deepchat-color-border);
    box-shadow: var(--deepchat-shadow-lg);
    max-width: calc(100vw - 2 * var(--deepchat-viewport-inset));
    max-height: calc(100dvh - 2 * var(--deepchat-viewport-inset));
}

.dc-popup__head {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 18px;
    border-bottom: 1px solid var(--deepchat-color-border);
    font-family: var(--deepchat-font-emphasis);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dc-popup__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 18px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dc-popup__body::-webkit-scrollbar {
    display: none;
}

.dc-popup__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--deepchat-color-border);
}

html:has(dialog.dc-popup[open]) {
    overflow: hidden;
}

@media (max-width: 767px) {
    .dc-popup,
    .dc-modal-dialog,
    .dc-ai-chat__panel {
        width: calc(100vw - 2 * var(--deepchat-viewport-inset)) !important;
        max-width: calc(100vw - 2 * var(--deepchat-viewport-inset)) !important;
        max-height: calc(100dvh - 2 * var(--deepchat-viewport-inset)) !important;
    }
}

/* ==========================================================================
   3. Zero-CLS 1:1 Structural Skeletons & Async Pending States
   ========================================================================== */

.dc-skel {
    display: block;
    min-width: 0;
    max-width: 100%;
    height: 0.75em;
    border-radius: var(--deepchat-radius-sm);
    background: var(--deepchat-color-border);
    animation: dc-skeleton-pulse 1.5s ease-in-out infinite;
}

.dc-skel--title {
    height: 0.9em;
    width: min(36ch, 78%);
    margin-block: calc((1.5em - 0.9em) / 2);
}

.dc-skel--sub {
    height: 0.8em;
    width: min(24ch, 56%);
    margin-block: calc((1.6em - 0.8em) / 2);
}

.dc-skel--badge {
    height: var(--deepchat-badge-height);
    min-height: var(--deepchat-badge-height);
    width: min(15ch, 100%);
    border-radius: var(--deepchat-radius-pill);
}

.dc-skel--button {
    height: var(--deepchat-control-height);
    min-height: var(--deepchat-control-height);
    border-radius: var(--deepchat-radius);
    border: 1px solid var(--deepchat-color-border-strong);
    box-sizing: border-box;
}

.dc-skel--cta {
    background: var(--deepchat-color-primary-soft);
    border-color: var(--deepchat-color-border-strong);
}

.dc-skel--avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
}

.dc-skel--conv-name {
    height: 0.9em;
    width: min(14ch, 78%);
    margin-block: calc((1.4em - 0.9em) / 2);
}

.dc-skel--conv-time {
    height: 0.72em;
    width: 11ch;
    margin-block: calc((1.3em - 0.72em) / 2);
}

.dc-skel--conv-phone {
    height: 0.8em;
    width: min(13ch, 56%);
    margin-block: calc((1.4em - 0.8em) / 2);
}

.dc-skel--conv-preview {
    height: 0.8em;
    width: min(26ch, 94%);
    margin-block: calc((1.4em - 0.8em) / 2);
}

.dc-skel--toggle-pill {
    width: 44px;
    height: 24px;
    border-radius: var(--deepchat-radius-pill);
    background: var(--deepchat-color-primary-soft);
}

.dc-skel--toggle-label {
    height: 0.8em;
    width: min(10ch, 48%);
    margin-block: calc((1.4em - 0.8em) / 2);
}

.dc-chat-inbox__skel-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--deepchat-color-border);
    border-radius: var(--deepchat-radius);
    background: var(--deepchat-color-inset);
    box-sizing: border-box;
    pointer-events: none;
    user-select: none;
}

.dc-chat-inbox__skel-msg {
    display: grid;
    gap: 4px;
    max-width: min(78%, 720px);
    padding: 0;
    border: 0;
    background: var(--deepchat-color-transparent);
    pointer-events: none;
    user-select: none;
}

.dc-chat-inbox__skel-msg--in {
    align-self: flex-start;
    width: min(40ch, 66%);
}

.dc-chat-inbox__skel-msg--short {
    align-self: flex-start;
    width: min(24ch, 42%);
}

.dc-chat-inbox__skel-msg--out {
    align-self: flex-end;
    width: min(44ch, 68%);
    justify-items: end;
}

.dc-chat-inbox__skel-msg .dc-chat-inbox__bubble {
    width: 100%;
    box-sizing: border-box;
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 18px 18px 18px 4px;
    background: var(--deepchat-color-inset);
    border: 1px solid var(--deepchat-color-border);
}

.dc-chat-inbox__skel-msg--out .dc-chat-inbox__bubble {
    border-radius: 18px 18px 4px 18px;
    background: var(--deepchat-color-primary-soft);
    border-color: var(--deepchat-color-primary-line);
}

.dc-skel--msg-line {
    width: 100%;
    height: 0.85em;
    margin-block: calc((1.5em - 0.85em) / 2);
}

.dc-skel--msg-line-mid {
    width: 78%;
    height: 0.85em;
    margin-block: calc((1.5em - 0.85em) / 2);
}

.dc-skel--msg-line-short {
    width: 56%;
    height: 0.85em;
    margin-block: calc((1.5em - 0.85em) / 2);
}

.dc-skel--msg-time {
    width: 5.5ch;
    height: 0.7em;
    margin-block: calc((1.3em - 0.7em) / 2);
}

.dc-chat-inbox__skel-msg--out .dc-skel--msg-time {
    justify-self: end;
}

.dc-chat-inbox__skel-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: var(--deepchat-radius);
    border: 1px solid var(--deepchat-color-border);
    background: var(--deepchat-color-inset);
}

.dc-row-placeholder td {
    padding: 12px 14px;
}

.dc-row-placeholder .dc-skel {
    width: min(18ch, 80%);
    height: 0.85em;
    margin-block: calc((1.5em - 0.85em) / 2);
}

/* Async REST Pending States (exact line-box match: 0px layout shift, hides stale text completely) */
.dc-badge[data-dc-pending="true"],
.dc-admin .dc-badge[data-dc-pending="true"] {
    min-width: min(16ch, 100%);
    height: var(--deepchat-badge-height);
    min-height: var(--deepchat-badge-height);
    background: var(--deepchat-color-border) !important;
    color: var(--deepchat-color-transparent) !important;
    -webkit-text-fill-color: var(--deepchat-color-transparent) !important;
    border: 0 !important;
    user-select: none;
    animation: dc-skeleton-pulse 1.5s ease-in-out infinite;
}

p[data-dc-pending="true"] {
    position: relative;
    display: block;
    min-height: 3.2em;
    color: var(--deepchat-color-transparent) !important;
    -webkit-text-fill-color: var(--deepchat-color-transparent) !important;
    user-select: none;
    overflow: hidden;
}

p[data-dc-pending="true"]::before,
p[data-dc-pending="true"]::after {
    content: "";
    position: absolute;
    left: 0;
    height: 0.85em;
    border-radius: var(--deepchat-radius-sm);
    background: var(--deepchat-color-border);
    animation: dc-skeleton-pulse 1.5s ease-in-out infinite;
}

p[data-dc-pending="true"]::before {
    top: calc((1.6em - 0.85em) / 2);
    width: min(56ch, 92%);
}

p[data-dc-pending="true"]::after {
    top: calc(1.6em + (1.6em - 0.85em) / 2);
    width: min(36ch, 62%);
}

:is(dd, strong, span):not(.dc-badge)[data-dc-pending="true"] {
    position: relative;
    display: inline-block;
    min-width: min(20ch, 100%);
    min-height: 1.6em;
    color: var(--deepchat-color-transparent) !important;
    -webkit-text-fill-color: var(--deepchat-color-transparent) !important;
    background: var(--deepchat-color-transparent) !important;
    vertical-align: middle;
    user-select: none;
}

:is(dd, strong, span):not(.dc-badge)[data-dc-pending="true"]::before {
    content: "";
    position: absolute;
    left: 0;
    top: calc((1.6em - 0.85em) / 2);
    width: min(22ch, 85%);
    height: 0.85em;
    border-radius: var(--deepchat-radius-sm);
    background: var(--deepchat-color-border);
    animation: dc-skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes dc-skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
    .dc-skel,
    [data-dc-pending="true"],
    [data-dc-pending="true"]::before,
    [data-dc-pending="true"]::after {
        animation: none;
    }
}

/* Authoritative hidden contract (prevents high-specificity display rules from reviving [hidden]) */
html body :is(.dc-admin, .dc-ai-chat, .dc-admin-toast-region, .dc-feature-unavailable) [hidden] {
    display: none !important;
}

/* ==========================================================================
   4. Domain Guard Locked Screen
   ========================================================================== */

.dc-domain-locked {
    padding: 20px;
    border-radius: var(--deepchat-radius);
    border: 1px solid var(--deepchat-color-danger);
    background: var(--deepchat-color-danger-surface);
    color: var(--deepchat-color-danger);
    font-family: var(--deepchat-font-emphasis);
    font-size: var(--deepchat-font-size);
    font-weight: 400;
    line-height: 1.6;
}
