/* LK-SUPPORT-01 (.codex/tasks/lk-operator-chat) — P-04 interactive mockup on synthetic data. */

.pc-support {
    position: relative;
    z-index: 46;
}

.pc-support-launcher {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--pc-line);
    border-radius: 12px;
    color: #345269;
    background: #fff;
    box-shadow: 0 6px 18px rgba(16, 42, 67, .06);
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease, transform .16s ease;
}

.pc-support-launcher:hover,
.pc-support-launcher:focus-visible {
    border-color: #ffc79f;
    color: #b74d03;
    background: var(--pc-orange-soft);
    transform: translateY(-1px);
}

.pc-support-launcher:focus-visible {
    outline: 3px solid var(--pc-focus-ring);
    outline-offset: 2px;
}

.pc-support-launcher.has-unread {
    color: var(--pc-orange);
}

.pc-support-badge {
    position: absolute;
    top: -6px;
    right: -7px;
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    color: #fff;
    background: #d94b2b;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

/* Backdrop + sliding side panel (desktop) / fullscreen (mobile), per SPEC.md SUP-01. */

.pc-support-backdrop {
    position: fixed;
    /* Portaled to <body> (see pcSupportChat.portalToBody) — top matches #app's
       own padding-top so the fixed sandbox banner (z-index 9000) never
       overlaps the panel below. --pc-support-safe-top is set inline by JS. */
    top: var(--pc-support-safe-top, 0);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1300;
    background: rgba(10, 25, 39, .32);
    animation: pc-support-fade .16s ease;
}

.pc-support-panel {
    position: fixed;
    z-index: 1301;
    top: var(--pc-support-safe-top, 0);
    right: 0;
    bottom: 0;
    left: auto;
    display: flex;
    width: min(420px, 100vw);
    flex-direction: column;
    background: var(--pc-surface, #fff);
    box-shadow: -24px 0 60px rgba(16, 42, 67, .22);
    animation: pc-support-slide-in .18s ease;
}

@keyframes pc-support-fade {
    from { opacity: 0; }
}

@keyframes pc-support-slide-in {
    from { transform: translateX(24px); opacity: 0; }
}

.pc-support-header {
    display: flex;
    flex-shrink: 0;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--pc-line);
}

.pc-support-header > div {
    display: grid;
    gap: 3px;
}

.pc-support-header strong {
    color: var(--pc-navy);
    font-size: 16px;
}

.pc-support-header span {
    /* var(--pc-muted) is 4.3:1 on white at this size — short of WCAG AA 4.5:1 for small text. */
    color: #546575;
    font-size: 12px;
}

.pc-support-header > .pc-dialog-close {
    margin: -6px -8px 0 0;
}

.pc-support-context {
    flex-shrink: 0;
    margin: 12px 20px 0;
    padding: 10px 12px;
    border: 1px solid var(--pc-line);
    border-radius: 12px;
    background: var(--pc-surface-soft, #f8fafc);
    /* var(--pc-text-muted) is 4.18:1 on this background at 12px — short of WCAG AA 4.5:1. */
    color: #546575;
    font-size: 12px;
}

.pc-support-context strong {
    color: var(--pc-navy);
    font-weight: 700;
}

.pc-support-status {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
    margin: 12px 20px 0;
    padding: 10px 12px;
    border-radius: 12px;
    color: #9a5a12;
    background: #fff6df;
    font-size: 12.5px;
    line-height: 1.4;
}

.pc-support-status.is-operator {
    color: #217a49;
    background: #e9f7ef;
}

.pc-support-status.is-closed {
    color: var(--pc-text-muted, #687b8d);
    background: var(--pc-surface-soft, #f2f6f9);
}

.pc-support-status.is-failed {
    color: var(--pc-error-text, #a53b28);
    background: var(--pc-error-surface, #fff5f2);
}

.pc-support-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 16px 20px;
    overflow-y: auto;
    scrollbar-color: #b8c7d2 #eef3f6;
    scrollbar-width: thin;
}

/* Older-history control at the top of the list (QA-CLAUDE-005): a button
   while more pages exist, an error with retry, or the beginning marker. */
.pc-support-history {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 2px 0 6px;
    text-align: center;
}

.pc-support-history.is-end {
    /* Same darkened muted tone as the rest of the panel's small text (AA on white). */
    color: #546575;
    font-size: 11.5px;
}

.pc-support-history-load {
    padding: 7px 12px;
    border: 1px solid var(--pc-line);
    border-radius: 999px;
    color: var(--pc-text, #172b3a);
    background: var(--pc-surface, #fff);
    font: 600 12px/1 inherit;
    cursor: pointer;
}

.pc-support-history-load:hover:not(:disabled) {
    border-color: #ffc79f;
    color: #b74d03;
    background: var(--pc-orange-soft);
}

.pc-support-history-load:focus-visible {
    outline: 3px solid var(--pc-focus-ring);
    outline-offset: 2px;
}

.pc-support-history-load:disabled {
    color: var(--pc-text-muted, #687b8d);
    background: var(--pc-surface-soft, #f2f6f9);
    cursor: progress;
}

.pc-support-history-error {
    color: var(--pc-error-text, #a53b28);
    font-size: 12px;
    line-height: 1.4;
}

html[data-pc-theme="dark"] .pc-support-history.is-end {
    color: var(--pc-text-muted, #93a7b8);
}

html[data-pc-theme="dark"] .pc-support-history-load {
    border-color: var(--pc-line, #23425c);
    background: var(--pc-surface, #16324a);
    color: var(--pc-text, #e7eef5);
}

html[data-pc-theme="dark"] .pc-support-history-load:disabled {
    background: var(--pc-surface-soft, #1c3041);
    color: var(--pc-text-muted, #93a7b8);
}

.pc-support-message {
    display: flex;
    max-width: 82%;
    flex-direction: column;
    gap: 4px;
}

.pc-support-message.is-client {
    align-self: flex-end;
    align-items: flex-end;
}

.pc-support-message.is-ai,
.pc-support-message.is-operator,
.pc-support-message.is-system {
    align-self: flex-start;
    align-items: flex-start;
}

.pc-support-message-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.pc-support-message.is-client .pc-support-message-bubble {
    border-bottom-right-radius: 4px;
    color: #fff;
    background: var(--pc-orange);
}

.pc-support-message.is-ai .pc-support-message-bubble {
    border-bottom-left-radius: 4px;
    color: var(--pc-text, #172b3a);
    background: var(--pc-surface-soft, #f2f6f9);
}

.pc-support-message.is-operator .pc-support-message-bubble {
    border-bottom-left-radius: 4px;
    color: #12432a;
    background: #e9f7ef;
}

.pc-support-message.is-system .pc-support-message-bubble {
    color: var(--pc-text-muted, #687b8d);
    background: transparent;
    font-size: 12px;
    font-style: italic;
}

.pc-support-message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 3px;
    /* var(--pc-text-muted) is 4.37:1 on white at this size — short of WCAG AA 4.5:1. */
    color: #546575;
    font-size: 10.5px;
}

.pc-support-message-meta .is-failed {
    color: var(--pc-error-text, #a53b28);
    font-weight: 700;
}

.pc-support-handoff {
    flex-shrink: 0;
    margin: 0 20px 12px;
    padding: 12px 14px;
    border: 1px dashed #ffb583;
    border-radius: 12px;
    background: #fff8f2;
    color: #7a3c07;
    font-size: 12.5px;
    line-height: 1.45;
}

.pc-support-composer {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 6px;
    padding: 14px 20px;
    border-top: 1px solid var(--pc-line);
}

.pc-support-composer-actions {
    display: flex;
    justify-content: flex-end;
}

.pc-support-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.pc-support-composer textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 13px;
    border: 1px solid var(--pc-line);
    border-radius: 12px;
    resize: none;
    color: var(--pc-text, #172b3a);
    background: var(--pc-surface, #fff);
    font: inherit;
    font-size: 13.5px;
}

.pc-support-composer textarea:focus-visible {
    outline: none;
    border-color: #ffad72;
    box-shadow: var(--pc-focus-shadow);
}

.pc-support-composer textarea:disabled {
    color: var(--pc-text-muted, #687b8d);
    background: var(--pc-surface-soft, #f2f6f9);
    cursor: not-allowed;
}

.pc-support-send {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: var(--pc-orange);
    cursor: pointer;
    transition: background .16s ease, transform .16s ease;
}

.pc-support-attach {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    height: 44px;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--pc-line);
    border-radius: 12px;
    color: var(--pc-text);
    background: var(--pc-surface);
    cursor: pointer;
}

.pc-support-attach input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.pc-support-attach:focus-within {
    outline: 3px solid var(--pc-focus-ring);
    outline-offset: 2px;
}

.pc-support-attach:hover:not(.is-disabled) {
    border-color: var(--pc-orange);
}

.pc-support-attach.is-disabled {
    opacity: .55;
    cursor: not-allowed;
}

.pc-support-screenshot-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 190px;
    overflow-y: auto;
    padding: 4px;
}

.pc-support-screenshot-preview {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 104px;
    padding: 4px;
    border: 1px solid var(--pc-line);
    border-radius: 10px;
    color: var(--pc-text);
    background: var(--pc-surface);
}

.pc-support-screenshot-preview img {
    display: block;
    width: 94px;
    height: 72px;
    object-fit: contain;
    border-radius: 6px;
}

.pc-support-screenshot-placeholder {
    display: grid;
    place-items: center;
    min-height: 72px;
    padding-top: 26px;
    font-size: 11px;
}

.pc-support-screenshot-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--pc-line);
    border-radius: 8px;
    color: var(--pc-text);
    background: var(--pc-surface);
    cursor: pointer;
}

.pc-support-screenshot-remove:disabled,
.pc-support-screenshot-retry:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.pc-support-screenshot-error {
    margin: 0;
    color: var(--pc-error-text);
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.pc-support-screenshot-retry {
    min-height: 32px;
    border: 1px solid var(--pc-line);
    border-radius: 8px;
    color: var(--pc-text);
    background: var(--pc-surface);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.pc-support-screenshot-remove:focus-visible,
.pc-support-screenshot-retry:focus-visible,
.pc-support-screenshot-preview a:focus-visible,
.pc-support-message-images a:focus-visible {
    outline: 3px solid var(--pc-focus-ring);
    outline-offset: 2px;
}

.pc-support-message-images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
}

.pc-support-message-images a {
    display: block;
    max-width: 100%;
    border: 1px solid var(--pc-line);
    border-radius: 10px;
    background: var(--pc-surface);
}

.pc-support-message-images img {
    display: block;
    width: 128px;
    max-width: 100%;
    height: 96px;
    object-fit: contain;
    border-radius: 10px;
}

.pc-support-send:hover:not(:disabled) {
    background: var(--pc-brand-orange-strong, #d95600);
    transform: translateY(-1px);
}

.pc-support-send:focus-visible {
    outline: 3px solid var(--pc-focus-ring);
    outline-offset: 2px;
}

.pc-support-send:disabled {
    color: var(--pc-text-muted, #687b8d);
    background: var(--pc-surface-soft, #f2f6f9);
    cursor: not-allowed;
}

.pc-support-transfer {
    min-width: 44px;
    min-height: 44px;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--pc-text, #172b3a);
    background: transparent;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    white-space: normal;
    overflow-wrap: anywhere;
}

.pc-support-transfer:hover:not(:disabled) {
    border-color: #ffc79f;
    color: #b74d03;
    background: var(--pc-orange-soft);
}

.pc-support-transfer:focus-visible {
    outline: 3px solid var(--pc-focus-ring);
    outline-offset: 2px;
}

.pc-support-transfer:disabled {
    color: var(--pc-text-muted, #687b8d);
    cursor: not-allowed;
}

@media (max-width: 720px) {
    .pc-support-panel {
        width: 100vw;
    }
}

html[data-pc-theme="dark"] .pc-support-launcher {
    border-color: var(--pc-control-border, #2b4a63);
    color: #b9c9d6;
    background: var(--pc-surface, #16324a);
}

html[data-pc-theme="dark"] .pc-support-launcher:hover,
html[data-pc-theme="dark"] .pc-support-launcher:focus-visible {
    border-color: #8a4e29;
    color: #ffb583;
    background: var(--pc-control-hover, #2a2015);
}

html[data-pc-theme="dark"] .pc-support-panel {
    background: var(--pc-surface, #142f46);
    box-shadow: -24px 0 60px rgba(0, 0, 0, .45);
}

html[data-pc-theme="dark"] .pc-support-header,
html[data-pc-theme="dark"] .pc-support-composer {
    border-color: var(--pc-line, #23425c);
}

html[data-pc-theme="dark"] .pc-support-header strong {
    color: var(--pc-text, #e7eef5);
}

html[data-pc-theme="dark"] .pc-support-header span,
html[data-pc-theme="dark"] .pc-support-message-meta {
    /* Light-theme base rule hardcodes a darkened muted color for AA contrast on white;
       restore a light muted shade here so it stays readable on the dark panel background. */
    color: var(--pc-text-muted, #93a7b8);
}

html[data-pc-theme="dark"] .pc-support-context,
html[data-pc-theme="dark"] .pc-support-message.is-ai .pc-support-message-bubble {
    background: var(--pc-surface-soft, #1c3041);
    color: var(--pc-text, #e7eef5);
    border-color: var(--pc-line, #23425c);
}

html[data-pc-theme="dark"] .pc-support-message.is-operator .pc-support-message-bubble {
    background: #163a27;
    color: #b7ecc9;
}

html[data-pc-theme="dark"] .pc-support-status {
    color: #ffd699;
    background: #3a2c10;
}

html[data-pc-theme="dark"] .pc-support-status.is-operator {
    color: #b7ecc9;
    background: #163a27;
}

html[data-pc-theme="dark"] .pc-support-status.is-closed {
    color: var(--pc-text-muted, #93a7b8);
    background: var(--pc-surface-soft, #1c3041);
}

html[data-pc-theme="dark"] .pc-support-handoff {
    border-color: #8a4e29;
    background: #2a2015;
    color: #ffd699;
}

html[data-pc-theme="dark"] .pc-support-composer textarea {
    border-color: var(--pc-line, #23425c);
    background: var(--pc-surface, #16324a);
    color: var(--pc-text, #e7eef5);
}

html[data-pc-theme="dark"] .pc-support-composer textarea:disabled,
html[data-pc-theme="dark"] .pc-support-send:disabled,
html[data-pc-theme="dark"] .pc-support-transfer:disabled {
    background: var(--pc-surface-soft, #1c3041);
    color: var(--pc-text-muted, #93a7b8);
}

html[data-pc-theme="dark"] .pc-support-transfer {
    border-color: transparent;
    background: transparent;
    color: var(--pc-text-muted, #93a7b8);
}

html[data-pc-theme="dark"] .pc-support-transfer:hover:not(:disabled) {
    border-color: #8a4e29;
    background: var(--pc-orange-soft, #2a2015);
    color: #ffb583;
}

/* Transient notice from the host (delivery problem, or the AI not yet
   connected). Sits between the status banner and the history. */
.pc-support-notice {
    flex-shrink: 0;
    margin: 10px 20px 0;
    padding: 9px 12px;
    border: 1px dashed var(--pc-line);
    border-radius: 12px;
    /* Same darkened muted tone as the rest of this panel's small text, so it
       clears WCAG AA on white. */
    color: #546575;
    background: var(--pc-surface-soft, #f8fafc);
    font-size: 12px;
    line-height: 1.45;
}

html[data-pc-theme="dark"] .pc-support-notice {
    border-color: var(--pc-line, #23425c);
    background: var(--pc-surface-soft, #1c3041);
    color: var(--pc-text-muted, #93a7b8);
}
