/*
 * Dock flutuante + painel lateral do chat do site (visual KOCHAT).
 * Itens do dock: includes/site_dock.php · lógica do chat: assets/js/main.js ·
 * dock/persistência/composer: assets/js/site-dock.js.
 * Este arquivo vem DEPOIS do style.css e sobrepõe as regras antigas
 * .website-chat-* / .float-btn (que continuam lá, sem uso no dock novo).
 */
:root {
    --wc-brand: #0d6efd;
    --wc-brand-600: #0a58ca;
    --wc-brand-50: #eff6ff;
    --wc-slate-50: #f8fafc;
    --wc-slate-100: #f1f5f9;
    --wc-slate-200: #e2e8f0;
    --wc-slate-400: #94a3b8;
    --wc-slate-500: #64748b;
    --wc-slate-600: #475569;
    --wc-slate-800: #1e293b;
    --wc-sheet-width: 400px;
}

/* ===================== Dock ===================== */
.site-dock {
    position: fixed;
    right: 16px;
    bottom: calc(16px + var(--site-dock-offset, 0px) + env(safe-area-inset-bottom, 0px));
    z-index: 1950;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    transition: bottom 0.25s ease, right 0.28s ease, opacity 0.2s ease;
    font-family: inherit;
}

@media (min-width: 769px) {
    .site-dock {
        right: 24px;
        bottom: calc(24px + var(--site-dock-offset, 0px));
    }
}

.site-dock-mini {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 0;
    display: grid;
    place-items: center;
    background: #fff;
    color: var(--wc-slate-600);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.site-dock-mini:hover,
.site-dock-mini[aria-expanded="true"] {
    background: var(--wc-brand-50);
    color: var(--wc-brand);
}

.site-dock-mini:focus-visible,
.site-dock-main:focus-visible,
.site-dock-menu-item:focus-visible,
.site-dock-lang:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.35);
    outline-offset: 2px;
}

.site-dock-mini .material-icons {
    font-size: 21px;
}

.site-dock-mini.to-top {
    display: none;
}

.site-dock-mini.to-top.visible {
    display: grid;
}

.site-dock-more {
    position: relative;
}

.site-dock-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    min-width: 230px;
    padding: 6px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transform-origin: bottom right;
    animation: siteDockMenuIn 0.16s ease;
}

.site-dock-menu[hidden] {
    display: none;
}

@keyframes siteDockMenuIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

.site-dock-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 11px;
    color: var(--wc-slate-800);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.site-dock-menu-item:hover {
    background: var(--wc-slate-50);
    color: var(--wc-brand);
}

.site-dock-menu-icon.material-icons {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--wc-brand-50);
    color: var(--wc-brand);
    font-size: 18px;
    flex: 0 0 auto;
}

.site-dock-langs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding: 8px 10px 4px;
    border-top: 1px solid var(--wc-slate-100);
    color: var(--wc-slate-500);
}

.site-dock-langs .material-icons {
    font-size: 18px;
    margin-right: 4px;
}

.site-dock-lang {
    min-width: 36px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-align: center;
    color: var(--wc-slate-600);
    text-decoration: none;
    background: var(--wc-slate-100);
}

.site-dock-lang:hover {
    color: var(--wc-brand);
    background: var(--wc-brand-50);
}

.site-dock-lang.is-active {
    background: var(--wc-brand);
    color: #fff;
}

.site-dock-main {
    position: relative;
    height: 56px;
    min-width: 56px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--wc-brand);
    color: #fff;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 10px 26px rgba(13, 110, 253, 0.38);
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.site-dock-main:hover {
    background: var(--wc-brand-600);
    transform: translateY(-1px);
}

.site-dock-main.is-unavailable {
    background: var(--wc-slate-500);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.22);
}

.site-dock-main[hidden] {
    display: none;
}

.site-dock-main-icon {
    position: relative;
    width: 24px;
    height: 24px;
    display: inline-block;
}

.site-dock-main-icon .material-icons {
    position: absolute;
    inset: 0;
    font-size: 24px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-dock-main-icon .is-close {
    opacity: 0;
    transform: rotate(-90deg);
}

body.website-chat-open .site-dock-main-icon .is-chat {
    opacity: 0;
    transform: rotate(90deg);
}

body.website-chat-open .site-dock-main-icon .is-close {
    opacity: 1;
    transform: none;
}

.site-dock-main-label {
    display: none;
}

@media (min-width: 769px) {
    .site-dock-main {
        padding: 0 22px 0 18px;
    }

    .site-dock-main-label {
        display: inline;
    }

    body.website-chat-open .site-dock-main-label {
        display: none;
    }

    body.website-chat-open .site-dock-main {
        padding: 0 16px;
    }
}

.site-dock-main-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #ef4444;
    box-shadow: 0 0 0 2px #fff;
}

.site-dock-main-badge[hidden] {
    display: none;
}

/* Com o painel aberto no desktop o dock anda para a esquerda do painel. */
@media (min-width: 769px) {
    body.website-chat-open .site-dock {
        right: calc(min(var(--wc-sheet-width), 100vw) + 20px);
    }
}

/* No celular o painel é tela cheia: o dock some enquanto ele está aberto. */
@media (max-width: 768px) {
    body.website-chat-open .site-dock {
        opacity: 0;
        pointer-events: none;
    }
}

/* ===================== Painel lateral (side sheet) ===================== */
.website-chat-widget.wc-sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(var(--wc-sheet-width), 100vw);
    max-width: none;
    max-height: none;
    display: block;
    z-index: 2700;
    opacity: 1;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.28s;
}

.website-chat-widget.wc-sheet.is-open {
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
}

/* Reabertura ao trocar de página: sem animação de entrada. */
.website-chat-widget.wc-sheet.wc-no-anim,
.website-chat-widget.wc-sheet.wc-no-anim * {
    transition: none !important;
}

.wc-sheet .website-chat-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    border-left: 1px solid var(--wc-slate-200);
    background: #fff;
    box-shadow: -16px 0 44px rgba(15, 23, 42, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

@media (max-width: 768px) {
    .website-chat-widget.wc-sheet {
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        align-items: stretch;
    }

    .wc-sheet .website-chat-panel {
        border-left: 0;
        box-shadow: none;
    }

    body.website-chat-open {
        overflow: hidden;
    }
}

/* Desktop: painel não-modal, a página continua rolando. */
@media (min-width: 769px) {
    body.website-chat-open {
        overflow: visible;
        overflow-x: clip;
    }
}

/* ---------- Cabeçalho ---------- */
.wc-sheet .website-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: #fff;
    color: var(--wc-slate-800);
    border-bottom: 1px solid var(--wc-slate-200);
    flex-shrink: 0;
}

.wc-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0d6efd 0%, #22b8cf 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.28);
}

.wc-avatar-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--wc-slate-400);
    box-shadow: 0 0 0 2px #fff;
}

.website-chat-header:has(.website-chat-status.is-open) .wc-avatar-dot { background: #22c55e; }
.website-chat-header:has(.website-chat-status.is-offline-hours) .wc-avatar-dot { background: #f59e0b; }
.website-chat-header:has(.website-chat-status.is-unavailable) .wc-avatar-dot { background: #ef4444; }

.wc-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.wc-sheet .website-chat-header strong {
    display: block;
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--wc-slate-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wc-sheet .website-chat-header strong small {
    margin-left: 4px;
    font-size: 0.74rem;
    font-weight: 500;
    color: var(--wc-slate-500);
}

.wc-sheet .website-chat-status {
    margin: 1px 0 0;
    padding: 0;
    background: none;
    border-radius: 0;
    font-size: 0.76rem;
    line-height: 1.35;
    color: var(--wc-slate-500);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wc-sheet .website-chat-status.is-open { background: none; color: #15803d; }
.wc-sheet .website-chat-status.is-offline-hours { background: none; color: #b45309; }
.wc-sheet .website-chat-status.is-unavailable { background: none; color: #b91c1c; }

.wc-head-btn,
.wc-sheet .website-chat-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: transparent;
    color: var(--wc-slate-500);
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    transition: background 0.16s ease, color 0.16s ease;
}

.wc-head-btn:hover,
.wc-sheet .website-chat-close:hover {
    background: var(--wc-slate-100);
    color: var(--wc-slate-800);
}

.wc-head-btn[hidden] {
    display: none;
}

.wc-head-btn .material-icons {
    font-size: 21px;
}

/* ---------- Corpo ---------- */
.wc-sheet .website-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--wc-slate-50);
}

.wc-sheet .website-chat-error {
    margin: 10px 12px 0;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.82rem;
    flex-shrink: 0;
}

.wc-sheet .website-chat-error[hidden] {
    display: none;
}

.wc-sheet .website-chat-unavailable,
.wc-sheet .website-chat-success {
    margin: 16px;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 0 0 1px var(--wc-slate-200);
}

.wc-sheet .website-chat-form {
    padding: 16px;
}

.wc-sheet .website-chat-conversation {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
    gap: 0;
    display: flex;
    flex-direction: column;
}

.wc-sheet .website-chat-conversation[hidden] {
    display: none;
}

.wc-sheet .website-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 12px;
    gap: 8px;
}

/* ---------- Bolhas (MessageBubble do KOCHAT) ---------- */
.wc-sheet .website-chat-msg {
    max-width: 86%;
    padding: 8px 12px 6px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.wc-sheet .website-chat-msg.from-visitor {
    background: var(--wc-brand);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 1px 2px rgba(13, 110, 253, 0.2);
}

.wc-sheet .website-chat-msg.from-staff {
    background: #fff;
    color: var(--wc-slate-800);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 0 0 1px var(--wc-slate-200);
}

.wc-sheet .website-chat-msg.from-system {
    max-width: 92%;
    background: #fff;
    color: var(--wc-slate-500);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.74rem;
    box-shadow: 0 0 0 1px var(--wc-slate-200);
    text-align: center;
}

.wc-sheet .website-chat-msg-author {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--wc-brand);
    opacity: 1;
    margin-bottom: 1px;
}

.wc-sheet .website-chat-msg.from-visitor .website-chat-msg-author {
    display: none;
}

.wc-sheet .website-chat-msg.from-system .website-chat-msg-author {
    display: none;
}

.wc-sheet .website-chat-msg time {
    align-self: flex-end;
    margin-top: 2px;
    font-size: 0.66rem;
    opacity: 0.65;
}

.wc-sheet .website-chat-msg.from-system time {
    display: none;
}

.wc-sheet .website-chat-typing-dots span {
    background: var(--wc-brand);
    opacity: 0.55;
}

/* ---------- Composer (igual ao do KOCHAT) ---------- */
.wc-sheet .website-chat-reply {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--wc-slate-200);
    flex-shrink: 0;
}

.wc-icon-btn {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: transparent;
    color: var(--wc-slate-500);
    cursor: pointer;
    padding: 0;
    transition: background 0.16s ease, color 0.16s ease;
}

.wc-icon-btn:hover,
.wc-icon-btn[aria-expanded="true"] {
    background: var(--wc-slate-100);
    color: var(--wc-slate-800);
}

.wc-icon-btn[aria-expanded="true"] {
    background: var(--wc-brand-50);
    color: var(--wc-brand);
}

.wc-icon-btn .material-icons {
    font-size: 21px;
}

.wc-input-wrap {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    padding: 7px 12px;
    border-radius: 16px;
    background: var(--wc-slate-50);
    box-shadow: inset 0 0 0 1px var(--wc-slate-200);
    transition: box-shadow 0.16s ease;
}

.wc-input-wrap:focus-within {
    box-shadow: inset 0 0 0 1.5px #60a5fa;
}

.wc-input-wrap textarea {
    display: block;
    width: 100%;
    min-height: 24px;
    max-height: 132px;
    border: 0;
    outline: none;
    padding: 0;
    margin: 0;
    resize: none;
    background: transparent;
    color: var(--wc-slate-800);
    font: inherit;
    font-size: 0.9rem;
    line-height: 24px;
    box-shadow: none;
}

.wc-input-wrap textarea::placeholder {
    color: var(--wc-slate-400);
}

.wc-sheet .website-chat-reply-send {
    width: 38px;
    height: 38px;
    background: var(--wc-brand);
    box-shadow: 0 1px 2px rgba(13, 110, 253, 0.3);
}

.wc-sheet .website-chat-reply-send:hover {
    background: var(--wc-brand-600);
    transform: none;
}

.wc-sheet .website-chat-reply-send .material-icons {
    font-size: 18px;
    margin-left: 2px;
}

.wc-emoji-pop {
    position: absolute;
    left: 10px;
    bottom: calc(100% + 6px);
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.wc-emoji-pop[hidden] {
    display: none;
}

.wc-emoji-pop button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.wc-emoji-pop button:hover {
    background: var(--wc-slate-100);
}

@media (prefers-reduced-motion: reduce) {
    .site-dock,
    .site-dock-menu,
    .website-chat-widget.wc-sheet,
    .site-dock-main-icon .material-icons {
        transition: none !important;
        animation: none !important;
    }
}
