﻿/* Floating Button */
.user-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483647;
    font-family: inherit;
}

.user-chat-widget__toggle {
    border: 0;
    border-radius: 999px;
    width: 58px;
    height: 58px;
    background: var(--color-primary, #ff5e14);
    color: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    cursor: pointer;
    position: relative;
}

.user-chat-widget__toggle i {
    font-size: 24px;
}

.user-chat-widget__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0 6px;
}

.user-chat-widget__badge.is-visible {
    display: inline-flex;
}

/* Chat Window */
.user-chat-widget__window {
    position: absolute;
    right: 75px;
    bottom: 20px;
    width: min(380px, calc(100vw - 32px));
    max-height: min(680px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

.user-chat-widget.is-open .user-chat-widget__window {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.user-chat-widget__header {
    padding: 14px 16px;
    background: var(--color-secondary, #152332);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-chat-widget__title {
    font-weight: 700;
    font-size: 16px;
}

.user-chat-widget__status {
    font-size: 12px;
    opacity: 0.85;
}

.user-chat-widget__close {
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.user-chat-widget__body {
    display: flex;
    flex-direction: column;
    min-height: 420px;
    max-height: 560px;
}

.user-chat-widget__drag-handle { display: none; }

/* Inline login flow */
.user-chat-widget__login {
    min-height: 420px;
    padding: 26px 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    background: linear-gradient(180deg, #fff 0%, #faf9fc 100%);
}

.user-chat-widget__login-icon { margin: 4px auto 0; color: var(--color-primary, #ff5e14); font-size: 34px; }
.user-chat-widget__login-title { color: #1f2937; font-size: 17px; font-weight: 800; text-align: center; }
.user-chat-widget__login-description { color: #6b7280; font-size: 13px; line-height: 1.8; text-align: center; }
.user-chat-widget__login-step { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.user-chat-widget__login-step label { color: #374151; font-size: 13px; font-weight: 700; }
.user-chat-widget__login-step input { width: 100%; border: 1px solid #d9dde5; border-radius: 12px; padding: 11px 12px; font-size: 14px; outline: none; }
.user-chat-widget__login-step input:focus { border-color: var(--color-primary, #ff5e14); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #ff5e14) 15%, transparent); }
.user-chat-widget__login-step .user-chat-widget__submit { margin-top: 8px; font-weight: 700; }
.user-chat-widget__login-back { align-self: flex-start; border: 0; background: transparent; color: var(--color-primary, #ff5e14); cursor: pointer; font-size: 12px; padding: 0; gap: 5px; }
.user-chat-widget__remember { display: flex; align-items: center; gap: 6px; font-weight: 400 !important; color: #6b7280 !important; cursor: pointer; }
.user-chat-widget__remember input { width: auto; padding: 0; }
.user-chat-widget__login-error { min-height: 20px; color: #dc2626; font-size: 12px; line-height: 1.6; text-align: center; }

/* Guest Form */
.user-chat-widget__guest-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chat-widget__guest-title {
    font-weight: 700;
    color: var(--text-primary, #1e1e1e);
    margin-bottom: 4px;
}

.user-chat-widget__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-chat-widget__field label {
    font-size: 13px;
    color: var(--text-sec, #5f5f5f);
}

.user-chat-widget__field input,
.user-chat-widget__composer textarea {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
}

.user-chat-widget__submit,
.user-chat-widget__send {
    border: 0;
    border-radius: 12px;
    background: var(--color-primary, #ff5e14);
    color: #fff;
    padding: 10px 14px;
    cursor: pointer;
}

.user-chat-widget__hint {
    font-size: 12px;
    color: #777;
    line-height: 1.6;
}

/* FAQ */
.user-chat-widget__faq {
    display: none;
    margin: 0 12px 12px;
    padding: 10px;
    border: 1px solid #e7e7e7;
    border-radius: 12px;
    background: #f9fafc;
}

.user-chat-widget__faq-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #154a6b;
    margin-bottom: 8px;
}

.user-chat-widget__faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.user-chat-widget__faq-item {
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    background: #fff;
}

.user-chat-widget__faq-question {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: right;
    padding: 8px 10px;
    font-size: 0.85rem;
    color: #0f172a;
    cursor: pointer;
}

.user-chat-widget__faq-answer {
    padding: 0 10px 10px;
    font-size: 0.8rem;
    color: #4b5563;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Messages */
.user-chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.user-chat-widget__empty {
    padding: 20px 12px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

.user-chat-widget__message-row {
    display: flex;
}

.user-chat-widget__message-row--mine {
    justify-content: flex-end;
}

.user-chat-widget__message-row--admin {
    justify-content: flex-start;
}

.user-chat-widget__bubble {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.user-chat-widget__bubble--mine {
    background: var(--color-primary, #ff5e14);
    color: #fff;
}

.user-chat-widget__bubble--admin {
    background: #fff;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.user-chat-widget__meta {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.75;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

/* File Cards */
.user-chat-widget__file-card,
.user-chat-widget__mention-card {
    margin-top: 8px;
    border-radius: 12px;
    padding: 10px;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.2);
}

.user-chat-widget__bubble--admin .user-chat-widget__file-card,
.user-chat-widget__bubble--admin .user-chat-widget__mention-card {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.user-chat-widget__file-card a,
.user-chat-widget__mention-card a {
    color: inherit;
    text-decoration: none;
}

.user-chat-widget__file-card img,
.user-chat-widget__mention-card img {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}

.user-chat-widget__file-card video {
    width: 100%;
    max-height: 180px;
    border-radius: 8px;
}

.user-chat-widget__file-name {
    font-weight: 700;
    font-size: 13px;
}

.user-chat-widget__file-subtitle {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

.user-chat-widget__mention-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.2);
    font-size: 11px;
    font-weight: 700;
}

/* Composer */
.user-chat-widget__composer {
    position: relative;
    border-top: 1px solid #e5e7eb;
    padding: 10px 12px 12px;
    background: #fff;
}

.user-chat-widget__composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.user-chat-widget__attach {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #f3f4f6;
    color: var(--color-secondary, #152332);
    cursor: pointer;
}

.user-chat-widget__composer input[type="file"] {
    display: none;
}

.user-chat-widget__composer textarea {
    min-height: 42px;
    max-height: 120px;
    padding-top: 11px;
}

.user-chat-widget__send {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-chat-widget__file-preview {
    margin-bottom: 8px;
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    padding: 8px;
    background: #f9fafb;
}

.user-chat-widget__file-preview img,
.user-chat-widget__file-preview video,
.user-chat-widget__file-preview object {
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    border-radius: 8px;
}

.user-chat-widget__file-preview-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.user-chat-widget__file-preview-remove {
    border: 0;
    background: transparent;
    color: #666;
    cursor: pointer;
}

.user-chat-widget__mention-guide {
    position: absolute;
    right: 12px;
    left: 12px;
    bottom: calc(100% + 8px);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 11px;
    border: 1px solid rgba(126, 45, 148, .3);
    border-radius: 12px;
    background: #fff;
    color: #4b5563;
    box-shadow: 0 8px 24px rgba(49, 28, 59, .16);
    font-size: 12px;
    line-height: 1.6;
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px);
    pointer-events: none;
}

.user-chat-widget__mention-guide.is-visible {
    animation: user-chat-mention-guide-in .45s cubic-bezier(.2, .8, .2, 1) forwards;
    pointer-events: auto;
}

.user-chat-widget__mention-guide.is-hiding {
    animation: user-chat-mention-guide-out .25s ease forwards;
    pointer-events: none;
}

.user-chat-widget__mention-guide-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    border-radius: 50%;
    background: #7e2d94;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
}

.user-chat-widget__mention-guide b { color: #7e2d94; }
.user-chat-widget__mention-guide button { margin-inline-start: auto; border: 0; background: transparent; color: #9ca3af; font-size: 18px; line-height: 1; cursor: pointer; }

@keyframes user-chat-mention-guide-in { to { opacity: 1; visibility: visible; transform: translateY(0); } }
@keyframes user-chat-mention-guide-out { to { opacity: 0; visibility: hidden; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
    .user-chat-widget__mention-guide.is-visible,
    .user-chat-widget__mention-guide.is-hiding { animation: none; opacity: 1; visibility: visible; transform: none; }
}

.user-chat-widget__mention-preview { margin-bottom: 8px; }
.user-chat-widget__mention-chip { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 10px; background: #eef5ff; color: #1555a5; font-size: 12px; }
.user-chat-widget__mention-chip small { color: #6b7280; margin-inline-start: auto; }
.user-chat-widget__mention-chip button { border: 0; background: transparent; color: #6b7280; cursor: pointer; font-size: 17px; line-height: 1; }
.user-chat-widget__mention-dropdown { position: relative; z-index: 5; max-height: 180px; overflow-y: auto; margin-bottom: 8px; border: 1px solid #dbe3ee; border-radius: 10px; background: #fff; box-shadow: 0 8px 20px rgba(15,23,42,.12); }
.user-chat-widget__mention-option { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 9px 11px; border: 0; border-bottom: 1px solid #eef2f7; background: #fff; color: #1f2937; text-align: right; cursor: pointer; }
.user-chat-widget__mention-option:hover { background: #f3f7fd; }
.user-chat-widget__mention-option small { color: #6b7280; }

/* Connection State */
.user-chat-widget__connection {
    font-size: 11px;
    padding: 6px 0 0;
    color: #777;
}

.user-chat-widget__connection--connected { color: #16a34a; }
.user-chat-widget__connection--connecting { color: #f59e0b; }
.user-chat-widget__connection--reconnecting { color: #f59e0b; }
.user-chat-widget__connection--disconnected { color: #dc2626; }

/* Closed State */
.user-chat-widget__closed {
    padding: 16px;
    color: #666;
    font-size: 13px;
    text-align: center;
}

/* Mobile */
@media (max-width: 768px) {
    .user-chat-widget {
        right: 0;
        bottom: 0;
    }

    .user-chat-widget__window {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100dvw;
        max-width: none;
        height: 80vh;
        height: 80dvh;
        max-height: 80vh;
        max-height: 80dvh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: transform .26s cubic-bezier(.2, .8, .2, 1), opacity .2s ease;
    }

    .user-chat-widget.is-open .user-chat-widget__window { transform: translateY(var(--user-chat-drag-offset, 0)); }
    .user-chat-widget__window.is-dragging { transition: none; }
    .user-chat-widget__toggle { display: none; }
    .user-chat-widget__drag-handle { display: flex; height: 24px; align-items: center; justify-content: center; background: #fff; cursor: grab; touch-action: none; }
    .user-chat-widget__drag-handle span { width: 42px; height: 4px; border-radius: 999px; background: #c7cbd2; }
    .user-chat-widget__drag-handle:active { cursor: grabbing; }
    .user-chat-widget__header { padding-top: 12px; }
    .user-chat-widget__body { flex: 1; min-height: 0; max-height: none; }
    .user-chat-widget__login { min-height: 0; flex: 1; overflow-y: auto; }
    .user-chat-widget__messages { min-height: 0; }
}
