/* ═══════════════════════════════════════
   CHAT WIDGET — Modern Design System
   ═══════════════════════════════════════ */
.chat-widget {
    position: fixed !important;
    bottom: 1.25rem !important;
    right: 1.25rem !important;
    left: auto !important;
    top: auto !important;
    z-index: 9999;
    font-family:
        "Google Sans Flex",
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
    --chat-primary: #4f46e5;
    --chat-primary-deep: #312e81;
    --chat-primary-soft: #eef2ff;
    --chat-accent: #fb471f;
    --chat-accent-soft: #fff2ec;
    --chat-surface: rgba(255, 255, 255, 0.92);
    --chat-border: rgba(148, 163, 184, 0.18);
    --chat-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
}

/* Mobile: lift widget above bottom nav bar + iOS home indicator.
   Native-app feel — chat bubble never overlaps primary nav. */
@media (max-width: 991.98px) {
    .chat-widget {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        right: 14px !important;
    }
    .chat-widget__mini-trigger {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        right: 14px !important;
    }
}

/* ═══ BUBBLE ═══ */
.chat-widget__bubble {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid rgba(79, 70, 229, 0.12);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    padding: 0;
}

/* Vòng sáng pulse phía sau */
.chat-widget__bubble::before {
    content: "";
    position: absolute;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        rgba(109, 94, 252, 0.4),
        rgba(251, 71, 31, 0.3)
    );
    z-index: -1;
    animation: bubblePulse 2.5s ease-in-out infinite;
}

/* Vòng sáng thứ 2 lệch pha */
.chat-widget__bubble::after {
    content: "";
    position: absolute;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        rgba(251, 71, 31, 0.3),
        rgba(109, 94, 252, 0.4)
    );
    z-index: -1;
    animation: bubblePulse 2.5s ease-in-out 1.25s infinite;
}

.chat-widget__label {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: var(--chat-primary, #4f46e5);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 100px;
    margin-bottom: 0.375rem;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
    pointer-events: none;
    animation: labelBounce 3s ease-in-out infinite;
}

.chat-widget__label::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--chat-primary, #4f46e5);
}

.chat-widget--open .chat-widget__label {
    display: none;
}

@keyframes labelBounce {
    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-3px);
    }
}

.chat-widget__icon {
    width: 52px;
    height: 52px;
    object-fit: contain;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: iconFloat 3s ease-in-out infinite;
}

.chat-widget__bubble:hover .chat-widget__icon {
    transform: scale(1.12) rotate(-8deg);
    filter: drop-shadow(0 8px 20px rgba(79, 70, 229, 0.45));
}

@keyframes bubblePulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 0;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.35;
    }
}

@keyframes iconFloat {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

.chat-widget__bubble:hover {
    transform: scale(1.08) translateY(-3px);
}

.chat-widget__bubble:active {
    transform: scale(0.92);
}

.chat-widget__bubble:active .chat-widget__icon {
    filter: drop-shadow(0 2px 6px rgba(79, 70, 229, 0.3));
}

.chat-widget__hide {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    color: #475569;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1.5px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
    opacity: 1;
    transform: scale(1);
    transition:
        background 0.2s,
        color 0.2s;
    z-index: 2;
    user-select: none;
}
.chat-widget__hide:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

.chat-widget__mini-trigger {
    position: fixed;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.14);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.75;
    transition:
        opacity 0.2s,
        transform 0.2s,
        box-shadow 0.2s;
}
.chat-widget__mini-trigger:hover {
    opacity: 1;
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25);
}
.chat-widget__mini-trigger img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-widget__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
    animation: badgeBounce 0.4s ease-out;
}

@keyframes badgeBounce {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

/* ═══ PANEL ═══ */
.chat-widget__panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 420px;
    height: min(720px, calc(100vh - 88px));
    max-height: 720px;
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.98),
            rgba(248, 250, 252, 0.96)
        ),
        radial-gradient(
            circle at top right,
            rgba(99, 102, 241, 0.12),
            transparent 32%
        );
    border-radius: 28px;
    box-shadow: var(--chat-shadow);
    border: 1px solid var(--chat-border);
    backdrop-filter: blur(18px);
    overflow: hidden;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    animation: panelIn 0.25s ease-out;
}

.chat-widget__window {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ═══ HEADER (Glassmorphism) ═══ */
.chat-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.125rem;
    background:
        radial-gradient(
            circle at top left,
            rgba(255, 255, 255, 0.18),
            transparent 25%
        ),
        linear-gradient(135deg, #5b5cf0 0%, #3f4ab8 55%, #2f3d8f 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.25px;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.chat-widget__header .chat-widget__back {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    margin-right: 0.5rem;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 0.875rem;
    border-radius: 14px;
    transition: all 0.2s;
}

.chat-widget__header .chat-widget__back:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.chat-widget__close {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 14px;
    transition: all 0.2s;
}

.chat-widget__close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

/* ═══ BODY ═══ */
.chat-widget__body {
    padding: 1.35rem;
    flex: 1;
    overflow-y: auto;
}

.chat-widget__welcome {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: #1a1d26;
    letter-spacing: -0.35px;
}

.chat-widget__subtitle {
    font-size: 0.84rem;
    color: #6b7280;
    margin-bottom: 1.35rem;
}

/* ═══ CHANNEL BUTTONS ═══ */
.chat-widget__channel-btn {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 18px;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.96),
        rgba(248, 250, 252, 0.94)
    );
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0.75rem;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.chat-widget__channel-btn:hover {
    border-color: rgba(79, 70, 229, 0.38);
    background: linear-gradient(180deg, #f8f9ff, #eef2ff);
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(79, 70, 229, 0.1);
}

.chat-widget__channel-btn--disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-widget__channel-btn--disabled:hover {
    border-color: #e5e7eb;
    background: #fff;
    transform: none;
    box-shadow: none;
}

.chat-widget__channel-icon {
    font-size: 1.35rem;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.chat-widget__channel-btn strong {
    display: block;
    font-size: 0.875rem;
    color: #1a1d26;
    letter-spacing: -0.1px;
}

.chat-widget__channel-btn small {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 1px;
}

.chat-widget__channel-btn--ai {
    border-color: #c7d2fe;
    background: linear-gradient(135deg, #f5f6ff, #eef2ff);
}

.chat-widget__channel-btn--ai .chat-widget__channel-icon {
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    color: #fff;
    font-size: 1.25rem;
}

.chat-widget__channel-icon-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 14px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: transform 0.25s ease;
}

.chat-widget__channel-btn:hover .chat-widget__channel-icon-img {
    transform: scale(1.08);
}

.chat-widget__channel-btn--ai:hover {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
}

/* ═══ MESSAGES ═══ */
.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.05rem 1.2rem;
    min-height: 0;
    max-height: none;
    background:
        radial-gradient(
            circle at top,
            rgba(99, 102, 241, 0.06),
            transparent 30%
        ),
        linear-gradient(180deg, #fbfcff, #f4f7fb 58%, #eef2f7 100%);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.chat-widget__messages::-webkit-scrollbar {
    width: 5px;
}

.chat-widget__messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.55);
    border-radius: 999px;
}

.chat-widget__msg {
    margin-bottom: 0.9rem;
    max-width: 85%;
    animation: widgetMsgIn 0.2s ease-out;
}

@keyframes widgetMsgIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-widget__msg--user {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-widget__msg--admin {
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Avatar + body row layout */
.chat-widget__msg-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.chat-widget__msg--user .chat-widget__msg-row {
    flex-direction: row-reverse;
}
.chat-widget__msg-av {
    flex-shrink: 0;
    padding-top: 2px;
}
.chat-widget__msg-body {
    min-width: 0;
    flex: 1;
}

.chat-widget__msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.12);
}

.chat-widget__msg-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: #7c8798;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget__msg--user .chat-widget__msg-name {
    text-align: right;
    justify-content: flex-end;
}

.chat-widget__msg-text {
    padding: 0.8rem 1rem;
    border-radius: 20px;
    font-size: 0.92rem;
    line-height: 1.58;
    word-wrap: break-word;
    white-space: pre-wrap;
    backdrop-filter: blur(8px);
}

.chat-widget__msg--user .chat-widget__msg-text {
    background: linear-gradient(135deg, #5f6ef4 0%, #4251c9 60%, #3949ab 100%);
    color: #fff;
    border-bottom-right-radius: 8px;
    box-shadow: 0 12px 28px rgba(57, 73, 171, 0.18);
}

.chat-widget__msg--admin .chat-widget__msg-text {
    background: rgba(255, 255, 255, 0.88);
    color: #1f2937;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-bottom-left-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.chat-widget__msg--bot .chat-widget__msg-text {
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.96),
            rgba(239, 244, 255, 0.92)
        ),
        radial-gradient(
            circle at top left,
            rgba(79, 70, 229, 0.08),
            transparent 35%
        );
    border: 1px solid rgba(99, 102, 241, 0.18);
    box-shadow: 0 14px 30px rgba(79, 70, 229, 0.08);
}

.chat-widget__msg-time {
    font-size: 0.64rem;
    color: #a8b0bc;
    margin-top: 5px;
    padding: 0 0.35rem;
    font-weight: 600;
}

.chat-widget__msg--user .chat-widget__msg-time {
    text-align: right;
}

.chat-widget__link {
    color: #3651d4;
    text-decoration: underline;
    word-break: break-all;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
}

.chat-widget__msg--user .chat-widget__link {
    color: #fff;
    text-decoration: underline;
}

.chat-widget__msg-img-link {
    display: inline-block;
    margin-bottom: 4px;
}
.chat-widget__msg-img {
    max-width: 200px;
    max-height: 160px;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
    object-fit: cover;
    display: block;
    border: 1px solid rgba(148, 163, 184, 0.15);
}
.chat-widget__msg-img:hover {
    opacity: 0.88;
}

/* ═══ SUGGESTIONS ═══ */
.chat-widget__suggestions {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding: 6px 12px;
    flex: 0 0 auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    background: linear-gradient(
        180deg,
        rgba(248, 250, 255, 0.9),
        rgba(255, 255, 255, 0.95)
    );
}

.chat-widget__suggestions::-webkit-scrollbar {
    height: 4px;
}

.chat-widget__suggestions::-webkit-scrollbar {
    width: 4px;
}

.chat-widget__suggestions::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}

.chat-widget__suggest-btn {
    flex-shrink: 0;
    padding: 6px 13px;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.9);
    color: #4f46e5;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.06);
}

.chat-widget__suggest-btn:hover {
    background: #eef2ff;
    border-color: rgba(79, 70, 229, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

/* ═══ TYPING ═══ */
.chat-widget__typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 1rem 2px;
    font-size: 0.7rem;
    color: #8b95a5;
    font-style: italic;
    flex: 0 0 auto;
}

.chat-widget__typing-dots {
    display: inline-flex;
    gap: 3px;
}

.chat-widget__typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #9ca3af;
    animation: widgetTyping 1.4s infinite;
}

.chat-widget__typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-widget__typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes widgetTyping {
    0%,
    60%,
    100% {
        opacity: 0.25;
    }

    30% {
        opacity: 1;
    }
}

/* ═══ FOOTER ═══ */
.chat-widget__footer {
    padding: 0.75rem 0.95rem 0.95rem;
    border-top: 1px solid rgba(226, 232, 240, 0.85);
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.96),
        rgba(248, 250, 252, 0.98)
    );
    backdrop-filter: blur(12px);
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
}

.chat-widget__footer .input-group {
    display: flex;
    align-items: flex-end;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 22px;
    overflow: hidden;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
    background: rgba(255, 255, 255, 0.95);
    min-height: 48px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
    padding: 0;
}

.chat-widget__footer .input-group:focus-within {
    border-color: rgba(79, 70, 229, 0.45);
    box-shadow:
        0 0 0 4px rgba(79, 70, 229, 0.08),
        0 12px 30px rgba(79, 70, 229, 0.08);
    transform: translateY(-1px);
}

.chat-widget__footer .form-control {
    border: none;
    border-radius: 0;
    font-size: 0.88rem;
    padding: 0.65rem 0.25rem 0.65rem 0.25rem;
    box-shadow: none;
    background: transparent;
    color: #1f2937;
    flex: 1 1 auto;
    min-width: 0;
}

.chat-widget__footer .form-control::placeholder {
    color: #9ca3af;
}

.chat-widget__footer .form-control:focus {
    box-shadow: none;
    border: none;
    outline: none;
}

.chat-widget__footer .btn[type="submit"] {
    flex: 0 0 auto;
    border: none;
    border-radius: 18px;
    margin: 6px;
    height: 36px;
    font-size: 0.82rem;
    font-weight: 700;
    background: linear-gradient(135deg, #5b5cf0, #3458d4);
    color: #fff;
    padding: 0 1rem;
    transition:
        background 0.2s,
        box-shadow 0.2s,
        transform 0.15s;
    box-shadow: 0 6px 14px rgba(52, 88, 212, 0.2);
}

.chat-widget__footer .btn[type="submit"]:hover {
    background: linear-gradient(135deg, #5253eb, #274abf);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(52, 88, 212, 0.28);
}

/* ═══ ATTACH + EMOJI (icon-only, subtle) ═══ */
.chat-widget__footer .chat-widget__attach-btn,
.chat-widget__footer #widgetEmojiToggle {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 6px 2px 6px 6px;
    border: none;
    border-radius: 50%;
    color: #6b7280;
    font-size: 0.9rem;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    transition:
        background-color 0.15s,
        color 0.15s,
        transform 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-widget__footer #widgetEmojiToggle {
    margin-left: 0;
}

.chat-widget__footer .chat-widget__attach-btn:hover,
.chat-widget__footer #widgetEmojiToggle:hover {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.08);
    transform: none;
}

.chat-widget__footer .chat-widget__attach-btn:focus,
.chat-widget__footer #widgetEmojiToggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.chat-widget__upload-preview {
    position: relative;
    padding: 6px 14px;
    background: #f9fafb;
}

.chat-widget__upload-preview img {
    max-height: 80px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.chat-widget__upload-preview button {
    position: absolute;
    top: 2px;
    right: 10px;
    background: #ef4444;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s;
}

.chat-widget__upload-preview button:hover {
    transform: scale(1.1);
}

/* ═══ MODE SWITCH ═══ */
.chat-widget__mode-switch {
    display: flex;
    gap: 8px;
    padding: 0 0 6px;
}

.chat-widget__escalate-btn,
.chat-widget__ai-btn {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.chat-widget__escalate-btn {
    color: #fb471f;
    border-color: #fecaca;
}

.chat-widget__escalate-btn:hover {
    background: #fef2f2;
    border-color: #fb471f;
    transform: translateY(-1px);
}

.chat-widget__ai-btn {
    color: #4f46e5;
    border-color: #c7d2fe;
}

.chat-widget__ai-btn:hover {
    background: #eef2ff;
    border-color: #4f46e5;
    transform: translateY(-1px);
}

/* ═══ BOT STYLES ═══ */
.chat-widget__bot-tag {
    display: inline-flex;
    align-items: center;
    font-size: 0.58rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    color: #fff;
    padding: 3px 8px;
    border-radius: 100px;
    letter-spacing: 0.45px;
    box-shadow: 0 8px 14px rgba(79, 70, 229, 0.14);
}

.chat-widget__thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9ca3af;
    font-style: italic;
    font-size: 0.75rem;
}

/* ═══ AI INFO ═══ */
.chat-widget__ai-info {
    padding: 2px 8px 0;
    text-align: center;
}

.chat-widget__lang-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0 6px;
}

.chat-widget__lang-label {
    font-size: 0.58rem;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: 0.02em;
    margin-right: 4px;
    text-transform: uppercase;
}

.chat-widget__lang-btn {
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1;
    padding: 4px 9px;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.9);
    color: #4f46e5;
    cursor: pointer;
    transition:
        background-color 0.15s,
        border-color 0.15s,
        color 0.15s,
        transform 0.12s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chat-widget__lang-btn:hover {
    background: #eef2ff;
    border-color: rgba(79, 70, 229, 0.5);
    transform: translateY(-1px);
}

.chat-widget__lang-btn[aria-pressed="true"] {
    background: linear-gradient(135deg, #5b5cf0, #3458d4);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 10px rgba(52, 88, 212, 0.22);
}

.chat-widget__lang-btn[aria-pressed="true"]:hover {
    transform: translateY(-1px);
}

.chat-widget__ai-disclaimer {
    font-size: 0.55rem;
    line-height: 1.15;
    color: #6b7280;
    padding: 0 2px 2px;
}

.chat-widget__ai-quota {
    padding: 0.3rem 0.45rem;
    text-align: left;
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 10px;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.96),
        rgba(244, 247, 255, 0.92)
    );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.75),
        0 4px 10px rgba(57, 73, 171, 0.05);
}

.chat-widget__ai-quota-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    margin-bottom: 0.22rem;
}

.chat-widget__ai-quota-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-widget__ai-quota-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: #374151;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-widget__ai-quota-caption {
    display: none;
}

.chat-widget__ai-quota-value {
    min-width: 40px;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #5c6bc0, #3949ab);
    box-shadow: 0 4px 10px rgba(57, 73, 171, 0.14);
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
}

.chat-widget__ai-quota-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        rgba(226, 232, 240, 0.95),
        rgba(209, 213, 219, 0.9)
    );
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.chat-widget__ai-quota-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffd166 0%, #ff8a3d 45%, #fb471f 100%);
    box-shadow: 0 0 18px rgba(251, 71, 31, 0.25);
    transition:
        width 0.25s ease,
        box-shadow 0.25s ease;
}

.chat-widget__ai-quota-scale {
    display: none;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #9ca3af;
}

/* ═══ GUEST INFO ═══ */
.chat-widget__guest-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.375rem;
    font-size: 0.6875rem;
    color: #9ca3af;
}

.chat-widget__guest-info a {
    color: #fb471f;
    text-decoration: none;
    font-weight: 500;
}

.chat-widget__guest-info a:hover {
    text-decoration: underline;
}

/* ═══ LOGIN PROMPT ═══ */
.chat-widget__login-prompt {
    padding: 1rem;
    text-align: center;
}

.chat-widget__login-prompt p {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-bottom: 0.625rem;
}

/* ═══ REDUCED MOTION ═══ */
@media (prefers-reduced-motion: reduce) {
    .chat-widget__panel {
        animation: none;
    }

    .chat-widget__msg {
        animation: none;
    }

    .chat-widget__badge {
        animation: none;
    }

    .chat-widget__bubble {
        transition: none;
    }
}

/* ═══ RESPONSIVE ═══ */
@media (min-width: 1400px) {
    .chat-widget__panel {
        width: 460px;
        height: min(680px, calc(100vh - 120px));
        max-height: 680px;
    }
}

@media (max-width: 767.98px) {
    /* Raise bubble above mobile bottom nav (~64-76px tall) */
    .chat-widget {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        right: 0.75rem !important;
        left: auto !important;
    }

    .chat-widget__panel {
        width: min(420px, calc(100vw - 1.5rem));
        right: -0.25rem;
        bottom: 68px;
    }
}

@media (max-width: 575.98px) {
    .chat-widget {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        right: 0.5rem !important;
        left: auto !important;
    }

    .chat-widget__panel {
        width: calc(100vw - 1.5rem);
        right: -0.5rem;
        bottom: 68px;
        height: min(78vh, calc(100vh - 180px));
        max-height: 78vh;
        border-radius: 22px;
    }

    .chat-widget__footer .btn[type="submit"] {
        min-width: 64px;
    }
}

/* ═══ WIDGET EMOJI PICKER ═══ */
.chat-widget__emoji-wrap {
    display: inline-block;
}
.chat-widget__emoji-panel {
    position: fixed;
    width: 240px;
    max-height: 160px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    z-index: 999999;
}
.chat-widget__emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    user-select: none;
}
.chat-widget__emoji-item:hover {
    background: #f3f4f6;
}

/* ═══ RATING ═══ */
.chat-widget__rating {
    padding: 12px;
    text-align: center;
    border-top: 1px solid #e5e7eb;
    background: #fefaf6;
}
.chat-widget__stars {
    display: flex;
    justify-content: center;
    gap: 4px;
}
.chat-widget__star {
    font-size: 28px;
    color: #f59e0b;
    cursor: pointer;
    transition: transform 0.15s;
    user-select: none;
}
.chat-widget__star:hover {
    transform: scale(1.2);
}

/* ═══ TEXTAREA INPUT (auto-grow) ═══ */
.chat-widget__textarea {
    resize: none;
    min-height: 22px;
    max-height: 120px;
    line-height: 1.45;
    overflow-y: auto;
    overflow-x: hidden;
    word-break: break-word;
    white-space: pre-wrap;
    -webkit-text-decoration-skip: none;
    text-decoration: none;
}

.chat-widget__textarea::-webkit-scrollbar {
    width: 4px;
}
.chat-widget__textarea::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}

/* ═══ MARKDOWN BODY (bot messages) ═══ */
.chat-widget__msg-text p {
    margin: 0 0 0.35em;
}
.chat-widget__msg-text p:last-child {
    margin-bottom: 0;
}
.chat-widget__msg-text p:first-child {
    margin-top: 0;
}

.chat-widget__msg-text strong {
    font-weight: 700;
}
.chat-widget__msg-text em {
    font-style: italic;
}

.chat-widget__msg-text ul,
.chat-widget__msg-text ol {
    margin: 0.15em 0 0.35em;
    padding-left: 1.25em;
}
.chat-widget__msg-text ul:last-child,
.chat-widget__msg-text ol:last-child {
    margin-bottom: 0;
}
.chat-widget__msg-text li {
    margin-bottom: 0.1em;
}
.chat-widget__msg-text li:last-child {
    margin-bottom: 0;
}
.chat-widget__msg-text li > br + a,
.chat-widget__msg-text li > br {
    line-height: 1.3;
}
/* Inline anchor/break inside list items keeps tight spacing */
.chat-widget__msg-text li a {
    word-break: break-word;
}

.chat-widget__msg-text code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82em;
    background: rgba(148, 163, 184, 0.14);
    padding: 1px 5px;
    border-radius: 4px;
}

.chat-widget__msg-text pre {
    margin: 0.4em 0;
    padding: 0.55em 0.7em;
    background: rgba(15, 23, 42, 0.04);
    border-radius: 8px;
    overflow-x: auto;
}
.chat-widget__msg-text pre code {
    background: transparent;
    padding: 0;
    font-size: 0.8em;
}
