/* assets/css/chat.css */
:root {
    --chat-bg: #111a27;
    --chat-header-bg: #0f1724;
    --chat-text: #ecf1f8;
    --chat-accent: #6f8cff;
    --chat-agent-msg: #222d3e;
    --chat-visitor-msg: #5f7cf6;
    --chat-border: #2f3b50;
    --chat-muted: #9fb0c7;
    --chat-font: 'Noto Sans SC', sans-serif;
}

#chat-widget-container {
    position: fixed;
    bottom: 26px;
    right: 22px;
    z-index: 9500;
    font-family: var(--chat-font);
}

#chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-accent);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(111, 140, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(111, 140, 255, 0.42);
}

#chat-toggle-btn svg {
    width: 25px;
    height: 25px;
    fill: currentColor;
}

#chat-window {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 356px;
    height: 520px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#chat-window.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.chat-header {
    background: var(--chat-header-bg);
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 15px;
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.chat-status {
    font-size: 12px;
    color: var(--chat-muted);
}

#chat-close {
    color: #aeb9cb;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    line-height: 1;
}

#chat-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e4ebf7;
}

.chat-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background: linear-gradient(180deg, #131d2a 0%, #111b28 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 84%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}

.message.visitor {
    align-self: flex-end;
    background: var(--chat-visitor-msg);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.agent {
    align-self: flex-start;
    background: var(--chat-agent-msg);
    color: #e2e9f3;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-bottom-left-radius: 4px;
}

.message-label {
    font-size: 13px;
    margin-bottom: 6px;
    color: inherit;
}

.message audio {
    display: block;
    width: min(240px, 100%);
    height: 34px;
}

.message-audio-fallback {
    margin-top: 6px;
    font-size: 12px;
    color: #cbd8ea;
    text-decoration: underline;
}

.chat-footer {
    padding: 10px 12px;
    background: var(--chat-header-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 8px;
}

.chat-footer input {
    flex: 1;
    background: #172233;
    border: 1px solid var(--chat-border);
    color: #fff;
    padding: 10px 11px;
    border-radius: 8px;
    outline: none;
    font-size: 14px;
}

.chat-footer input::placeholder {
    color: #8ea0b7;
}

.chat-footer input:focus {
    border-color: var(--chat-accent);
}

.chat-footer button {
    background: transparent;
    border: none;
    color: #c5d1e4;
    cursor: pointer;
    padding: 0 8px;
    font-weight: 700;
}

.chat-footer button:hover {
    color: #fff;
}

.chat-meta {
    text-align: right;
    padding: 0 12px 8px;
}

#chat-reset {
    font-size: 11px;
    color: #8fa0b8;
    cursor: pointer;
}

#chat-reset:hover {
    color: #d6e0ef;
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #34445d;
    border-radius: 3px;
}

#chat-tooltip {
    position: fixed;
    bottom: 32px;
    right: 84px;
    background-color: #233047;
    color: #ecf2fb;
    padding: 7px 11px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 9600;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.25s ease;
    pointer-events: none;
}

#chat-toggle-btn:hover+#chat-tooltip,
#chat-tooltip.show {
    opacity: 1;
    transform: translateX(0);
}

#chat-tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #233047;
}

@media (max-width: 768px) {
    #chat-widget-container {
        right: 12px !important;
        bottom: calc(96px + env(safe-area-inset-bottom)) !important;
    }

    #chat-window {
        width: min(420px, calc(100vw - 24px)) !important;
        height: min(62vh, 500px);
        bottom: 72px;
        right: 0;
    }

    #chat-toggle-btn {
        width: 52px;
        height: 52px;
    }

    #chat-tooltip {
        display: none;
    }
}

@media (max-width: 380px) {
    #chat-window {
        height: 58vh;
    }
}
