/**
 * livechat.css — kunde-side widget styling (editorial-paper match).
 *
 * Loades KUN når PHP-injection bekræfter livechat.enabled=true (+ optionally
 * admin_only_test passes). Hvis CSS er loadet uden widget i DOM, har den
 * ingen visuel effekt — pp-livechat-rod-elementet skal eksistere.
 *
 * Brand-tokens: champagne #876333, ink #0a0a0c, paper #FBF8F1, hairline #d8d2c2.
 * Bevidst inde i en SCSS-fri scope så vi ikke konflikter med eksisterende styles.css.
 */

/* ============ Bubble (always visible) ============ */
.pp-livechat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: #876333;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(135,99,51,0.30), 0 2px 6px rgba(0,0,0,0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: transform 160ms ease, background 160ms ease, box-shadow 200ms ease;
    font-family: Inter, system-ui, sans-serif;
}
.pp-livechat-bubble:hover {
    background: #5c4220;
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(135,99,51,0.40), 0 4px 10px rgba(0,0,0,0.12);
}
.pp-livechat-bubble:focus-visible {
    outline: 2px solid #876333;
    outline-offset: 3px;
}
.pp-livechat-bubble__icon {
    width: 24px;
    height: 24px;
    pointer-events: none;
}
.pp-livechat-bubble__unread {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FBF8F1;
}
.pp-livechat-bubble.is-open { display: none; }

/* ============ Panel ============ */
.pp-livechat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    height: 540px;
    max-height: calc(100vh - 48px);
    background: #FBF8F1;
    border: 1px solid #d8d2c2;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.20), 0 4px 12px rgba(0,0,0,0.08);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: Inter, system-ui, sans-serif;
    color: #0a0a0c;
}
.pp-livechat-panel.is-open { display: flex; }

.pp-livechat-panel__header {
    padding: 14px 18px;
    background: #fff;
    border-bottom: 1px solid #d8d2c2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.pp-livechat-panel__header h2 {
    margin: 0;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 16px;
    font-weight: 600;
    color: #0a0a0c;
    letter-spacing: -0.01em;
}
.pp-livechat-panel__sub {
    font-size: 11px;
    color: #6b6b6b;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pp-livechat-panel__sub::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #16a34a;
    display: inline-block;
}
/* Offline-state: prikken bliver grå + pulserer ikke */
.pp-livechat-panel.is-presence-offline .pp-livechat-panel__sub::before {
    background: #cbb89a;
}
/* Online-state: subtil puls på prikken */
.pp-livechat-panel.is-presence-online .pp-livechat-panel__sub::before {
    box-shadow: 0 0 0 2px rgba(22,163,74,0.18);
    animation: pp-presence-pulse 2.4s ease-in-out infinite;
}
@keyframes pp-presence-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(22,163,74,0.18); }
    50%      { box-shadow: 0 0 0 5px rgba(22,163,74,0.06); }
}
.pp-livechat-panel__close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b6b6b;
    padding: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 18px;
}
.pp-livechat-panel__close:hover { background: rgba(0,0,0,0.06); color: #0a0a0c; }

.pp-livechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #FBF8F1;
}
.pp-livechat-msg {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.pp-livechat-msg--visitor {
    background: #876333;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.pp-livechat-msg--agent {
    background: #fff;
    color: #0a0a0c;
    border: 1px solid #d8d2c2;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.pp-livechat-msg--ai {
    background: #ede9fe;
    color: #0a0a0c;
    border: 1px solid #c4b5fd;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.pp-livechat-msg--ai::before {
    content: '🤖 PhotoOpus AI';
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #5b21b6;
    margin-bottom: 4px;
}
.pp-livechat-msg--system {
    align-self: center;
    background: transparent;
    color: #6b6b6b;
    font-size: 11px;
    font-style: italic;
    padding: 4px 12px;
}
.pp-livechat-msg__time {
    display: block;
    font-size: 10px;
    opacity: 0.6;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
}

.pp-livechat-composer {
    padding: 12px 14px;
    border-top: 1px solid #d8d2c2;
    background: #fff;
}
.pp-livechat-composer textarea {
    width: 100%;
    min-height: 48px;
    max-height: 140px;
    padding: 9px 11px;
    border: 1px solid #d8d2c2;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.45;
    resize: none;
    box-sizing: border-box;
    color: #0a0a0c;
    background: #fff;
}
.pp-livechat-composer textarea:focus {
    outline: none;
    border-color: #876333;
    box-shadow: 0 0 0 3px rgba(135,99,51,0.15);
}
.pp-livechat-composer__row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}
.pp-livechat-composer__send {
    background: #0a0a0c;
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.pp-livechat-composer__send:hover { background: #2c2c2e; }
.pp-livechat-composer__send:disabled { opacity: 0.5; cursor: not-allowed; }
.pp-livechat-composer__hint {
    font-size: 10px;
    color: #6b6b6b;
    flex: 1;
}

.pp-livechat-closed {
    padding: 18px 20px;
    text-align: center;
    color: #6b6b6b;
    font-size: 13px;
    background: rgba(220,252,231,0.4);
    border-top: 1px solid #d8d2c2;
}

/* ============ Mobile ============ */
@media (max-width: 560px) {
    .pp-livechat-bubble {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
    .pp-livechat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
}

/* ==========================================================================
   Offline email-gate (vises når admin ikke er online)
   ========================================================================== */
.pp-livechat-offline {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 20px;
    background: #FBF8F1;
}
.pp-livechat-offline__intro {
    margin: 0 0 4px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #0a0a0c;
    font-family: Inter, system-ui, sans-serif;
}
.pp-livechat-offline__email,
.pp-livechat-offline__body {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid #d8cdb9;
    border-radius: 8px;
    background: #fff;
    color: #0a0a0c;
    font-size: 13px;
    font-family: Inter, system-ui, sans-serif;
    resize: vertical;
}
.pp-livechat-offline__body { min-height: 90px; }
.pp-livechat-offline__email:focus,
.pp-livechat-offline__body:focus {
    outline: none;
    border-color: #876333;
    box-shadow: 0 0 0 3px rgba(135,99,51,0.12);
}
.pp-livechat-offline__send {
    align-self: flex-end;
    padding: 9px 18px;
    border: none;
    border-radius: 999px;
    background: #0a0a0c;
    color: #fff;
    font-size: 13px;
    font-family: Inter, system-ui, sans-serif;
    cursor: pointer;
}
.pp-livechat-offline__send:disabled {
    background: #6b6b6b;
    cursor: wait;
}

.pp-livechat-offline-thanks {
    padding: 24px 20px;
    text-align: center;
    color: #0a0a0c;
    font-family: Inter, system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background: #FBF8F1;
}
.pp-livechat-offline-thanks p { margin: 0 0 8px 0; }
.pp-livechat-offline-thanks p:last-child {
    color: #6b6b6b;
    font-size: 13px;
}
