/* JanitorAI Style Frontend Chat CSS - 3-Section Layout */

/* Section Layout Container */
.chat-main-wrapper {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 140px);
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* ───────────────────────────────────────────────────────────── */
/* SECTION 1: CHAT SUB HEADER (TRANSFORMS TO FLOATING ON SCROLL) */
/* ───────────────────────────────────────────────────────────── */
.chat-sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    width: 100%;
    box-sizing: border-box;
    z-index: 90;
    transition: background 0.3s ease, box-shadow 0.3s ease, padding 0.25s ease;
}

/* Floating glass card when scrolled */
.chat-sub-header.is-scrolled-header {
    position: sticky;
    top: 67px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: calc(100% - 48px);
    max-width: 950px;
    border-radius: 16px;
    background: rgba(12, 16, 26, 0.94);
    border: 1px solid rgba(212, 163, 42, 0.35);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(212, 163, 42, 0.15);
    padding: 10px 24px;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 98;
    transition: all 0.3s ease;
}

/* Sub Header Collapse & Slide Up Animations */
.chat-sub-header.sub-header-slide-up {
    animation: subHeaderSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.chat-sub-header.sub-header-slide-down {
    animation: subHeaderSlideDown 0.25s cubic-bezier(0, 0, 0.2, 1) forwards;
}

.chat-sub-header.sub-header-hidden {
    display: none !important;
}

@keyframes subHeaderSlideUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-100%);
    }
}

@keyframes subHeaderSlideDown {
    0% {
        opacity: 0;
        transform: translateY(-100%);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Collapse Toggle Button & Unhide Floating Pill */
.btn-sub-header-toggle {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: none; /* Hidden by default in static top state */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

/* Only display collapse chevron button when sub-header is floating */
.chat-sub-header.is-scrolled-header .btn-sub-header-toggle {
    display: inline-flex;
}

.btn-sub-header-toggle:hover {
    background: rgba(212, 163, 42, 0.2);
    color: var(--accent, #d4a32a);
    border-color: rgba(212, 163, 42, 0.4);
    transform: translateY(-1px);
}

.sub-header-unhide-pill {
    position: sticky;
    top: 67px;
    left: 0;
    right: 0;
    margin: 0 auto 10px auto;
    z-index: 99;
    background: rgba(12, 16, 26, 0.92);
    border: 1px solid rgba(212, 163, 42, 0.4);
    color: #f1f5f9;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    animation: subHeaderFloatIn 0.25s ease forwards;
}

.sub-header-unhide-pill:hover {
    background: rgba(212, 163, 42, 0.25);
    color: #fff;
    border-color: var(--accent, #d4a32a);
    transform: scale(1.04);
}

@keyframes subHeaderFloatIn {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.back-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease;
}
.back-btn:hover { color: var(--accent); }

.char-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.char-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 2px solid var(--accent);
    box-shadow: 0 0 14px rgba(212, 163, 42, 0.35);
    flex-shrink: 0;
    transition: all 0.3s ease;
}
.is-scrolled-header .char-header-avatar {
    width: 36px;
    height: 36px;
}

.char-header-text {
    display: flex;
    flex-direction: column;
}

.char-header-name {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #f8fafc;
    transition: all 0.3s ease;
}
.is-scrolled-header .char-header-name {
    font-size: 1rem;
}

.char-status-badge {
    font-size: 0.76rem;
    color: #2ed573;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    font-size: 0.55rem;
    animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.chat-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(212, 163, 42, 0.12);
    border: 1px solid rgba(212, 163, 42, 0.3);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
}

/* ───────────────────────────────────────────────────────────── */
/* SECTION 2: CHAT CONTENT AREA (MESSAGES & WELCOME CARD)        */
/* ───────────────────────────────────────────────────────────── */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 950px;
    margin: 0 auto;
    width: 100%;
    padding: 28px 20px;
    box-sizing: border-box;
    gap: 22px;
    min-height: 380px;
}

/* Chat container custom scrollbar managed by centralized ScrollbarManager */

/* Welcome Intro Card */
.chat-welcome-card {
    text-align: center;
    padding: 28px 24px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    backdrop-filter: blur(15px);
    margin-bottom: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.welcome-avatar-ring {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px auto;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, var(--accent) 0%, #38bdf8 100%);
    box-shadow: 0 0 25px rgba(212, 163, 42, 0.35);
}

.welcome-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
}

.welcome-title {
    margin: 0 0 8px 0;
    font-size: 1.35rem;
    font-weight: 800;
    color: #f8fafc;
}

.welcome-desc {
    margin: 0 auto 16px auto;
    max-width: 600px;
    font-size: 0.92rem;
    color: #94a3b8;
    line-height: 1.55;
}

.welcome-meta-pills {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    font-size: 0.78rem;
    color: #cbd5e1;
}

/* JanitorAI Style Message Layout */
.message {
    display: flex;
    gap: 14px;
    max-width: 85%;
    align-items: flex-start;
}

.msg-char {
    align-self: flex-start;
}

.msg-user {
    align-self: flex-end;
    flex-direction: row;
}

.msg-user .msg-body {
    order: 1;
    align-items: flex-end;
}

.msg-user .msg-avatar {
    order: 2;
}

.msg-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.user-avatar-badge {
    background: var(--accent);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    border: none;
}

.msg-body {
    display: flex;
    flex-direction: column;
}

.msg-user .msg-body {
    align-items: flex-end;
}

.msg-char .msg-body {
    align-items: flex-start;
}

.msg-header {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.msg-name {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.msg-name-char {
    color: #38bdf8;
}

.msg-name-user {
    color: #f59e0b;
}

.bubble {
    padding: 14px 20px;
    border-radius: 16px;
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.msg-bubble-content {
    display: block;
    width: 100%;
}

.msg-char .bubble {
    background: var(--msg-bubble-bg-char, rgba(30, 41, 59, 0.75));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--msg-plain-color-char, #f1f5f9);
    border-top-left-radius: 4px;
}

.msg-user .bubble {
    background: var(--msg-bubble-bg-user, var(--accent));
    color: var(--msg-plain-color-user, #0f172a);
    font-weight: 500;
    border-top-right-radius: 4px;
}

/* === Italic / Narration (*...*) === */
.msg-char .bubble em,
.msg-char .bubble .msg-narration {
    color: var(--msg-narration-color, #f59e0b);
    font-style: italic;
    font-weight: 400;
}

.msg-user .bubble em,
.msg-user .bubble .msg-narration {
    color: var(--msg-narration-color, #f59e0b);
    font-style: italic;
    font-weight: 500;
    opacity: 0.8;
}

/* === Bold (**...**) === */
.msg-char .bubble strong,
.msg-char .bubble .msg-bold {
    color: var(--msg-bold-color-char, var(--msg-bold-color, #f8fafc));
    font-weight: 700;
}

.msg-user .bubble strong,
.msg-user .bubble .msg-bold {
    color: var(--msg-bold-color-user, var(--msg-bold-color, #f8fafc));
    font-weight: 700;
    opacity: 0.85;
}

/* === Dialogue / Speech ("...") === */
.msg-char .bubble .msg-dialogue {
    color: var(--msg-dialogue-color-char, #f8fafc);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.msg-user .bubble .msg-dialogue {
    color: var(--msg-dialogue-color-user, #0f172a);
    font-weight: 600;
}

/* === Action Badges ([...]) — character bubble === */
.msg-char .bubble .msg-action-narration {
    color: var(--msg-action-color-char, #38bdf8);
    background: rgba(56, 189, 248, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.92em;
    font-style: italic;
    border: 1px solid rgba(56, 189, 248, 0.2);
    display: inline;
}

/* === Action Badges ([...]) — user bubble === */
.msg-user .bubble .msg-action-narration {
    color: var(--msg-action-color-user, #78350f);
    background: rgba(255, 255, 255, 0.22);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.92em;
    font-style: italic;
    display: inline;
}

.typing-indicator {
    display: none;
    align-self: flex-start;
}

.typing-bubble {
    background: rgba(30, 41, 59, 0.75);
    padding: 14px 20px;
    border-radius: 16px;
    display: flex;
    gap: 5px;
    align-items: center;
    border-top-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Scroll to Bottom Helper Button */
.scroll-to-bottom-btn {
    position: fixed;
    bottom: 120px;
    right: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.9);
    border: 1.5px solid var(--accent);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 163, 42, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 105;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-to-bottom-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scroll-to-bottom-btn:hover {
    background: var(--accent);
    color: #0f172a;
    transform: translateY(-2px) scale(1.08);
}

/* ───────────────────────────────────────────────────────────── */
/* SECTION 3: CHAT INPUT AREA (FLOATING RIGHT ABOVE FOOTER)      */
/* ───────────────────────────────────────────────────────────── */
.input-area-section {
    position: relative;
    background: transparent;
    padding: 10px 24px;
    margin-top: auto;
    width: 100%;
    box-sizing: border-box;
    z-index: 90;
    transition: all 0.3s ease;
}

/* Sticky Floating Input Area when scrolled past trigger */
.input-area-section.is-sticky-input {
    position: sticky;
    bottom: 14px;
    animation: inputFloatUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes inputFloatUp {
    0% {
        opacity: 1;
        transform: translateY(16px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-area-section::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(10, 15, 26, 0.88) 0%, rgba(10, 15, 26, 0.7) 88%, rgba(10, 15, 26, 0.55) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.input-area-container {
    max-width: 950px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    border: 1px solid rgba(212, 163, 42, 0.35);
    border-radius: 20px;
    padding: 14px 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(212, 163, 42, 0.15);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    transition: all 0.3s ease;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #060911;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 8px 12px 8px 20px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(212, 163, 42, 0.3);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #f8fafc;
    font-size: 0.98rem;
    outline: none;
    resize: none;
    overflow: hidden;
    min-height: 26px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.5;
}

.send-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #f3c64d 100%);
    color: #0f172a;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    transition: all 0.25s ease;
    box-shadow: 0 4px 14px rgba(212, 163, 42, 0.4);
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(212, 163, 42, 0.6);
}

.send-btn:disabled {
    background: #475569;
    color: #94a3b8;
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
}

/* Stop Generating Button (Option 2 Stream Abort) */
.send-btn.btn-stop-generating {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 0 16px rgba(225, 29, 72, 0.5) !important;
    animation: stopBtnPulse 1.2s infinite ease-in-out alternate;
}

.send-btn.btn-stop-generating:hover {
    transform: scale(1.12);
    box-shadow: 0 0 22px rgba(225, 29, 72, 0.75) !important;
}

@keyframes stopBtnPulse {
    0% { box-shadow: 0 0 10px rgba(225, 29, 72, 0.4); }
    100% { box-shadow: 0 0 20px rgba(225, 29, 72, 0.85); }
}

.input-footer-hints {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 0.75rem;
    color: #64748b;
}

.input-hint strong {
    color: #cbd5e1;
}

.input-disclaimer i {
    color: var(--accent);
}

/* Mobile & Small Screen Responsive */
@media (max-width: 768px) {
    .chat-sub-header.is-scrolled-header {
        top: 116px;
        width: calc(100% - 24px);
        padding: 8px 14px;
        border-radius: 14px;
    }
    .scroll-to-bottom-btn {
        right: 20px;
        bottom: 160px;
    }
}

@media (max-width: 640px) {
    .chat-sub-header {
        padding: 8px 14px;
    }
    .chat-sub-header.is-scrolled-header {
        top: 116px;
        width: calc(100% - 20px);
        border-radius: 14px;
    }
    .chat-mode-pill { display: none; }
    .chat-container { padding: 18px 12px; }
    .message { max-width: 92%; }
    .input-area-section { padding: 8px 12px; }
    .input-area-container { padding: 10px 14px; border-radius: 16px; }
    
    /* Requirement 1: Hide Keyboard hint on mobile */
    .input-hint {
        display: none !important;
    }
    .input-footer-hints {
        justify-content: center;
    }
    .scroll-to-bottom-btn {
        right: 16px;
        bottom: 160px;
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }
}

/* ==========================================================================
   Expandable Message Quick Menu (Top-Right for AI, Top-Left for User)
   ========================================================================== */
.msg-body {
    position: relative;
}

.msg-quick-menu {
    position: absolute;
    top: 6px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 2px 4px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.65;
}

.msg-quick-menu:hover,
.msg-quick-menu.active {
    opacity: 1;
    border-color: rgba(212, 163, 42, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* AI Character Message: Top-Right (Expands to Left) */
.msg-char .msg-quick-menu,
.msg-quick-menu.dir-top-right {
    right: 8px;
    flex-direction: row-reverse;
}

/* User Message: Top-Left (Expands to Right) */
.msg-user .msg-quick-menu,
.msg-quick-menu.dir-top-left {
    left: 8px;
    flex-direction: row;
}

.btn-quick-toggle {
    background: none;
    border: none;
    color: #cbd5e1;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: transform 0.25s ease, color 0.15s ease;
}

.btn-quick-toggle:hover {
    color: var(--accent);
}

.msg-quick-menu:hover .btn-quick-toggle,
.msg-quick-menu.active .btn-quick-toggle {
    transform: rotate(90deg);
    color: var(--accent);
}

/* Sliding Drawer for Action Buttons */
.quick-actions-drawer {
    display: flex;
    align-items: center;
    gap: 2px;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, padding 0.25s ease;
    padding: 0;
}

.msg-quick-menu:hover .quick-actions-drawer,
.msg-quick-menu.active .quick-actions-drawer {
    max-width: 140px;
    opacity: 1;
    pointer-events: auto;
    padding: 0 4px;
}

.btn-msg-action {
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 0.78rem;
    padding: 3px 6px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-msg-action:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

.btn-msg-action.btn-copy:hover {
    color: var(--accent);
    background: rgba(212, 163, 42, 0.2);
}

.btn-msg-action.btn-delete:hover {
    color: #f43f5e;
    background: rgba(244, 63, 94, 0.2);
}

.msg-swipe-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-swipe {
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-swipe:hover:not(:disabled) {
    color: var(--accent);
    background: rgba(212, 163, 42, 0.15);
}

.btn-swipe:disabled {
    color: #475569;
    cursor: not-allowed;
    opacity: 0.4;
}

.swipe-indicator {
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 0.03em;
    padding: 0 4px;
    user-select: none;
}

.swipe-indicator.loading {
    opacity: 0.5;
    animation: swipePulse 0.8s infinite ease-in-out alternate;
}

/* User Message Regenerate Response Toolbar */
.msg-user-retry-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 6px;
    animation: fadeIn 0.3s ease forwards;
}

.btn-user-retry {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(212, 163, 42, 0.35);
    color: var(--accent, #d4a32a);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.btn-user-retry:hover {
    background: rgba(212, 163, 42, 0.2);
    border-color: var(--accent, #d4a32a);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(212, 163, 42, 0.35);
}

.btn-user-retry i {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.btn-user-retry:hover i {
    transform: rotate(180deg);
}

.btn-user-retry:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

@keyframes swipePulse {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

.bubble.swipe-generating {
    padding: 12px 18px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    background: rgba(30, 41, 59, 0.6);
    border: 1px dashed rgba(212, 163, 42, 0.4);
}

.swipe-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
}

.swipe-typing-bubble .dot {
    width: 8px;
    height: 8px;
    background: var(--accent, #d4a32a);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.swipe-typing-bubble .dot:nth-child(1) { animation-delay: -0.32s; }
.swipe-typing-bubble .dot:nth-child(2) { animation-delay: -0.16s; }

/* Swipe Slide Directional Animations */
.msg-bubble-content.swipe-slide-out-left,
.bubble.swipe-slide-out-left {
    animation: swipeSlideOutLeft 0.16s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.msg-bubble-content.swipe-slide-in-right,
.bubble.swipe-slide-in-right {
    animation: swipeSlideInRight 0.20s cubic-bezier(0, 0, 0.2, 1) forwards;
}

.msg-bubble-content.swipe-slide-out-right,
.bubble.swipe-slide-out-right {
    animation: swipeSlideOutRight 0.16s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.msg-bubble-content.swipe-slide-in-left,
.bubble.swipe-slide-in-left {
    animation: swipeSlideInLeft 0.20s cubic-bezier(0, 0, 0.2, 1) forwards;
}

@keyframes swipeSlideOutLeft {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(-24px); opacity: 0; }
}
@keyframes swipeSlideInRight {
    0% { transform: translateX(24px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes swipeSlideOutRight {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(24px); opacity: 0; }
}
@keyframes swipeSlideInLeft {
    0% { transform: translateX(-24px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   In-Chat Toast Notification Positioning & Responsive Design
   ========================================================================== */
#chatToastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 420px;
}

.chat-toast-item {
    background: rgba(225, 29, 72, 0.92);
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-toast-item.toast-success {
    background: rgba(16, 185, 129, 0.92);
}

.chat-toast-item.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Mobile Positioning: Middle top under main floating header */
@media (max-width: 768px) {
    #chatToastContainer {
        top: 75px;
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 90%;
        max-width: 380px;
        align-items: center;
    }

    .chat-toast-item {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
        justify-content: center;
        transform: translateY(-12px) scale(0.96);
    }

    .chat-toast-item.show {
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   Custom Glassmorphic Delete Confirmation Modal
   ========================================================================== */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.custom-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.custom-modal-content {
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 28px 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(225, 29, 72, 0.15);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-modal-overlay.active .custom-modal-content {
    transform: scale(1) translateY(0);
}

.modal-icon.warning-glow {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(225, 29, 72, 0.15);
    border: 1.5px solid rgba(225, 29, 72, 0.4);
    color: #f43f5e;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px auto;
    box-shadow: 0 0 20px rgba(225, 29, 72, 0.25);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 8px;
}

.modal-description {
    font-size: 0.88rem;
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-modal {
    flex: 1;
    padding: 11px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-modal-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-modal-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.btn-modal-confirm {
    background: #e11d48;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(225, 29, 72, 0.4);
}

.btn-modal-confirm:hover {
    background: #f43f5e;
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.6);
    transform: translateY(-1px);
}

/* Expanded Bubble when editing */
.bubble.is-editing {
    padding: 16px 20px !important;
    background: rgba(10, 14, 24, 0.95) !important;
    border: 1px solid rgba(212, 163, 42, 0.45) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(212, 163, 42, 0.15) !important;
}

/* Inline Message Editing UI */
.msg-edit-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.msg-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.msg-edit-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: normal;
}

.msg-edit-hint kbd {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.7rem;
    color: #cbd5e1;
}

.msg-edit-textarea {
    width: 100%;
    min-height: 60px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(212, 163, 42, 0.35);
    border-radius: 12px;
    color: #f8fafc;
    font-family: inherit;
    font-size: 0.98rem;
    line-height: 1.65;
    padding: 12px 14px;
    box-sizing: border-box;
    outline: none;
    resize: vertical;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.msg-edit-textarea:focus {
    border-color: var(--accent, #d4a32a);
    box-shadow: 0 0 15px rgba(212, 163, 42, 0.25), inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.msg-edit-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

.btn-edit-save {
    background: linear-gradient(135deg, var(--accent, #d4a32a), #b8860b);
    color: #000;
    font-weight: 700;
    border: none;
    padding: 8px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(212, 163, 42, 0.3);
}

.btn-edit-save:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(212, 163, 42, 0.4);
}

.btn-edit-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-edit-cancel:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}
