/* Public site chat widget. Keep this file isolated from footer.html. */
.site-chat-widget {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 99999;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.site-chat-fab {
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(220, 53, 69, 0.4);
    font-size: 24px;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.site-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 34px rgba(220, 53, 69, 0.45);
}

.site-chat-online-dot,
.site-chat-status-dot {
    position: absolute;
    background: #10b981;
    border-radius: 50%;
}

.site-chat-online-dot {
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    display: none;
}

.site-chat-online-dot.site-chat-has-unread {
    display: block;
    animation: siteChatPulse 2s infinite;
}

.site-chat-window {
    position: fixed;
    width: 350px;
    height: 500px;
    min-width: 350px;
    min-height: 500px;
    max-width: calc(100vw - 64px);
    max-height: calc(100vh - 64px);
    right: 32px;
    bottom: 104px;
    left: auto;
    top: auto;
    resize: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    transform-origin: right bottom;
}

.site-chat-window[hidden] {
    display: none !important;
}

.site-chat-window.site-chat-opening {
    animation: siteChatOpen 0.24s ease forwards;
}

.site-chat-window.site-chat-closing {
    animation: siteChatClose 0.22s ease forwards;
    pointer-events: none;
}

.site-chat-header {
    flex: 0 0 auto;
    background: #1e293b;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    cursor: default;
}

.site-chat-operator {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.site-chat-avatar-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
}

.site-chat-avatar-wrap img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
}

.site-chat-status-dot {
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border: 2px solid #1e293b;
}

.site-chat-title {
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.15;
}

.site-chat-subtitle {
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    line-height: 1.2;
    margin-top: 3px;
}

.site-chat-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
    padding: 0;
    font-size: 18px;
}

.site-chat-close:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(1px);
}

.site-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    background: #f8fafc;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.site-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.site-chat-row {
    display: flex;
    margin-bottom: 2px;
}

.site-chat-row-user {
    justify-content: flex-end;
}

.site-chat-row-support {
    align-items: flex-end;
    gap: 8px;
}

.site-chat-row-system {
    justify-content: center;
}

.site-chat-avatar-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.site-chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.site-chat-bubble-user {
    background: #dc3545;
    color: #fff;
    border-radius: 14px 14px 4px 14px;
}

.site-chat-bubble-support {
    background: #fff;
    color: #334155;
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.site-chat-footer {
    flex: 0 0 auto;
    background: #fff;
    padding: 15px;
    border-top: 1px solid #f1f5f9;
}

.site-chat-contact-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.site-chat-contact-fields[hidden] {
    display: none !important;
}

.site-chat-input {
    width: 100%;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    padding: 8px;
    outline: none;
}

.site-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 5px;
}

.site-chat-textarea {
    flex: 1;
    border: none;
    resize: none;
    min-height: 32px;
    max-height: 96px;
    font-size: 13px;
    line-height: 1.35;
    padding: 7px 8px;
    outline: none;
    overflow-y: auto;
}

.site-chat-textarea::placeholder {
    font-size: 12px;
    white-space: nowrap;
}

.site-chat-send {
    background: #dc3545;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background-color 0.15s ease;
    flex: 0 0 auto;
}

.site-chat-send:hover {
    transform: scale(1.06);
    background: #c92f41;
}

.site-chat-resize-handle {
    position: absolute;
    z-index: 30;
    display: block;
    background: transparent;
    touch-action: none;
}

.site-chat-resize-handle[data-dir="n"] { top: 0; left: 20px; right: 20px; height: 12px; cursor: ns-resize; }
.site-chat-resize-handle[data-dir="s"] { bottom: 0; left: 20px; right: 20px; height: 12px; cursor: ns-resize; }
.site-chat-resize-handle[data-dir="e"] { top: 20px; right: 0; bottom: 20px; width: 12px; cursor: ew-resize; }
.site-chat-resize-handle[data-dir="w"] { top: 20px; left: 0; bottom: 20px; width: 12px; cursor: ew-resize; }
.site-chat-resize-handle[data-dir="ne"] { top: 0; right: 0; width: 24px; height: 24px; cursor: nesw-resize; }
.site-chat-resize-handle[data-dir="nw"] { top: 0; left: 0; width: 24px; height: 24px; cursor: nwse-resize; }
.site-chat-resize-handle[data-dir="se"] { right: 0; bottom: 0; width: 24px; height: 24px; cursor: nwse-resize; }
.site-chat-resize-handle[data-dir="sw"] { left: 0; bottom: 0; width: 24px; height: 24px; cursor: nesw-resize; }


.site-chat-system-note {
    align-self: center;
    max-width: 92%;
    padding: 8px 12px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
}

.site-chat-finish-card {
    align-self: stretch;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.site-chat-finish-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 10px;
}

.site-chat-finish-actions {
    display: flex;
    gap: 8px;
}

.site-chat-finish-action {
    flex: 1;
    border: 0;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.site-chat-finish-action.yes {
    background: #10b981;
    color: #fff;
}

.site-chat-finish-action.no {
    background: #f1f5f9;
    color: #334155;
}


@keyframes siteChatOpen {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes siteChatClose {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(18px) scale(0.98); }
}

@keyframes siteChatPulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@media (max-width: 991px), (pointer: coarse) {
    .site-chat-widget {
        right: 15px;
        bottom: 85px;
    }

    .site-chat-window {
        width: min(350px, calc(100vw - 30px));
        height: min(500px, calc(100vh - 120px));
        min-width: 300px;
        min-height: 450px;
        max-width: calc(100vw - 30px);
        max-height: calc(100vh - 120px);
        right: 15px;
        bottom: 85px;
        left: auto !important;
        top: auto !important;
    }

    .site-chat-header {
        touch-action: auto;
    }

    .site-chat-resize-handle {
        display: none !important;
    }
}
