/* ============================================================
   AI Chat — Modern Chat UI
   Domain: chat.bty.web.id
   ============================================================ */

/* ---------- CSS Variables / Theming ---------- */
:root,
[data-theme="light"] {
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F1F5F9;
    --bg-sidebar: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-user-msg: linear-gradient(135deg, #1d72dd, #1557b0);
    --bg-bot-msg: #FFFFFF;
    --bg-hover: #F1F5F9;
    --bg-active: #EBF5FF;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;
    --text-user-msg: #FFFFFF;
    --text-bot-msg: #0F172A;
    --border-color: #E2E8F0;
    --border-input: #CBD5E1;
    --accent: #1d72dd;
    --accent-hover: #1557b0;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --success: #10B981;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 14px rgba(29, 114, 221, 0.08);
    --shadow-lg: 0 12px 36px rgba(29, 114, 221, 0.12);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-full: 9999px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 290px;
    --header-height: 64px;
    --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-tertiary: #334155;
    --bg-sidebar: #1E293B;
    --bg-input: #1E293B;
    --bg-user-msg: linear-gradient(135deg, #1d72dd, #1557b0);
    --bg-bot-msg: #1E293B;
    --bg-hover: #334155;
    --bg-active: rgba(29, 114, 221, 0.2);
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;
    --text-user-msg: #FFFFFF;
    --text-bot-msg: #F8FAFC;
    --border-color: #334155;
    --border-input: #475569;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #F87171;
    --danger-hover: #EF4444;
    --success: #10B981;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
    height: 100%;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    transition: margin-left var(--transition), transform var(--transition);
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.sidebar.collapsed {
    margin-left: calc(var(--sidebar-width) * -1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-new-chat:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); transform: scale(1.05); }

.sidebar-search {
    padding: 8px 20px;
}
.sidebar-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all var(--transition);
}
.sidebar-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }
.sidebar-search input::placeholder { color: var(--text-tertiary); }

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-primary);
    font-size: 14px;
    position: relative;
    margin-bottom: 4px;
}
.session-item:hover { background: var(--bg-hover); transform: translateY(-1px); }
.session-item.active { background: var(--bg-active); font-weight: 600; color: var(--accent); }

.session-item .session-icon { font-size: 18px; flex-shrink: 0; }
.session-item .session-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-item .session-delete {
    display: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}
.session-item:hover .session-delete { display: flex; }
.session-item .session-delete:hover { background: var(--danger); color: #fff; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    transition: background var(--transition);
}
.sidebar-user:hover { background: var(--bg-hover); }

.sidebar-user .user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-email {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .btn-logout {
    color: var(--text-secondary);
}

.sidebar-user .btn-logout:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

/* ---------- Buttons ---------- */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---------- Chat Main ---------- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
    position: relative;
    height: 100vh;
}

/* ---------- Chat Header ---------- */
.chat-header {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-height);
    padding: 0 24px;
    background: rgba(250, 250, 252, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(236, 236, 244, 0.5);
}
[data-theme="dark"] .chat-header {
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.btn-sidebar-toggle { display: flex; }

.chat-header-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.chat-title {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--success);
    font-weight: 500;
}
.chat-status::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(29, 114, 221, 0.08), rgba(0, 82, 204, 0.08));
    border: 1px solid rgba(29, 114, 221, 0.2);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}

/* ---------- Messages ---------- */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
    padding-bottom: 24px; /* Space for fixed input */
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    padding: 40px 20px;
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.welcome-orb {
    width: 90px;
    height: 90px;
    margin-bottom: 24px;
    animation: float 6s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}
.welcome-orb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}
[data-theme="dark"] .welcome-orb img {
    mix-blend-mode: screen;
    filter: brightness(1.2); /* optional boost for dark mode */
}
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
    100% { transform: translateY(0px); }
}

.welcome-screen h2 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}
.welcome-screen p {
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 40px;
    font-size: 1.1rem;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-width: 700px;
}

.suggestion-chip {
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}
.suggestion-chip:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #1d72dd, #1557b0);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(29, 114, 221, 0.3);
}

/* Message bubbles */
.message-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    max-width: 1100px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.message-row.user { justify-content: flex-end; }
.message-row.bot { justify-content: flex-start; }

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1d72dd, #1557b0);
    color: white;
    box-shadow: var(--shadow-sm);
}
.message-row.user .message-avatar { display: none; }

.message-row > div:not(.message-avatar),
.message-row-container {
    max-width: 90%;
    min-width: 0; /* Cegah konten panjang (nowrap) melebarkan bubble keluar jalur */
    display: flex;
    flex-direction: column;
    position: relative;
}
.message-row-container > div {
    min-width: 0;
    max-width: 100%;
}
.message-row.user > div:not(.message-avatar),
.message-row.user .message-row-container {
    align-items: flex-end;
}
.message-row.bot > div:not(.message-avatar),
.message-row.bot .message-row-container {
    align-items: flex-start;
}

.message-bubble {
    width: auto;
    max-width: 100%;
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    word-break: break-word; /* Ensure long text without spaces wraps */
    overflow-wrap: break-word;
    position: relative;
    box-shadow: var(--shadow-sm);
    font-size: 15px;
    text-align: left;
}
.message-row.user .message-bubble {
    background: var(--bg-user-msg);
    color: var(--text-user-msg);
    border-bottom-right-radius: 6px;
    text-align: left;
}
.message-row.bot .message-bubble {
    background: var(--bg-bot-msg);
    color: var(--text-bot-msg);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.message-bubble p { margin-bottom: 10px; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble pre {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}
.message-bubble code {
    font-family: var(--font-mono);
    font-size: 13px;
}
.message-bubble :not(pre) > code {
    background: rgba(0,0,0,0.05);
    padding: 3px 6px;
    border-radius: 6px;
}
[data-theme="dark"] .message-bubble :not(pre) > code {
    background: rgba(255,255,255,0.1);
}

.message-bubble ul, .message-bubble ol {
    padding-left: 24px;
    margin: 10px 0;
}

.message-bubble strong { font-weight: 600; }

/* Markdown Table Styles */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13.5px;
    display: block;
    overflow-x: auto;
    max-width: 100%;
}
.message-bubble th,
.message-bubble td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}
.message-bubble th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
    text-align: right;
}
.message-row.bot .message-time { text-align: left; }

/* File attachments in messages */
.message-files {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}
.message-file-thumb {
    max-width: 240px;
    max-height: 240px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
    transition: transform var(--transition);
    box-shadow: var(--shadow-sm);
}
.message-file-thumb:hover { transform: scale(1.02); }

.message-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    backdrop-filter: blur(4px);
}
.message-row.bot .message-file-card {
    background: var(--bg-tertiary);
}
.message-file-card .file-icon { font-size: 22px; }
.message-file-card .file-name {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.generated-image {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}
.generated-image img {
    display: block;
    width: min(100%, 512px);
    max-height: 512px;
    object-fit: contain;
    border-radius: var(--radius-md);
    cursor: zoom-in;
    box-shadow: var(--shadow-md);
    animation: pulsePlaceholder 1.5s infinite ease-in-out;
}

@keyframes pulsePlaceholder {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.generated-image img.loaded {
    animation: none;
}

.image-download {
    align-self: flex-start;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}
.image-download:hover { text-decoration: underline; }

/* ---------- AI Thinking Indicator ---------- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 20px;
    max-width: 850px;
    margin: 0 auto;
}
.typing-indicator.hidden { display: none; }

.thinking-orb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1d72dd, #1557b0);
    animation: pulseOrb 1.5s infinite ease-in-out;
    box-shadow: 0 0 15px rgba(29, 114, 221, 0.5);
}
@keyframes pulseOrb {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.5; }
}

.thinking-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
}

/* ---------- Animated Thinking Dots ---------- */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 4px;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: translateY(0) scale(0.85);
        opacity: 0.45;
    }
    40% {
        transform: translateY(-7px) scale(1.35);
        opacity: 1;
        box-shadow: 0 2px 10px rgba(29, 114, 221, 0.7);
    }
}

/* ---------- Chat Input ---------- */
.chat-input-area {
    position: relative;
    padding: 0 24px 24px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    background: linear-gradient(to top, var(--bg-primary) 80%, transparent);
    z-index: 20;
    transition: left var(--transition), width var(--transition);
}
.sidebar.collapsed ~ .chat-main .chat-input-area {
    left: 0;
    width: 100%;
}

.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.file-preview.hidden { display: none; }

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.file-preview-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}
.file-preview-item .remove-file {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all var(--transition);
}
.file-preview-item .remove-file:hover { background: var(--danger); color: #fff; }

.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-input);
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
}
.chat-form:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(29, 114, 221, 0.18), 0 8px 24px rgba(29, 114, 221, 0.12);
    transform: translateY(-2px);
}

.file-input-hidden { display: none; }

.input-actions-left {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-bottom: 4px;
}

.btn-attach {
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
}
.btn-attach:hover { color: var(--accent); background: var(--bg-hover); }

.textarea-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 4px 0;
}

#message-input {
    width: 100%;
    max-height: 72px; /* Approx 3 lines */
    padding: 8px 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
}
#message-input::placeholder { color: var(--text-tertiary); }

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #1d72dd, #1557b0);
    color: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
    margin-bottom: 2px;
}
.btn-send:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 4px 14px rgba(29, 114, 221, 0.4); }
.btn-send:disabled { opacity: 0.45; cursor: not-allowed; background: linear-gradient(135deg, #1d72dd, #1557b0); color: #ffffff; }

.input-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 12px;
}

/* ---------- Image Lightbox ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: fadeIn 0.3s ease;
}
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ---------- Sidebar Overlay (mobile) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 90;
}
.sidebar-overlay.active { display: block; }

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ---------- Streaming Cursor ---------- */
.streaming-cursor {
    animation: cursorBlink 0.8s infinite;
    color: var(--accent);
    font-weight: 300;
    margin-left: 2px;
    display: inline-block;
    width: 8px;
    height: 1em;
    background-color: var(--accent);
    vertical-align: middle;
}
.streaming-bubble {
    min-height: 24px;
}

/* ---------- Document Download Bar ---------- */
.doc-download-bar {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.btn-download-doc {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #1d72dd, #1557b0);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
    box-shadow: var(--shadow-sm);
}
.btn-download-doc:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn-download-doc:disabled {
    opacity: 0.6;
    cursor: wait;
}
.btn-download-doc.btn-download-alt {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-download-doc.btn-download-alt:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }

    .btn-sidebar-toggle { display: flex; }

    .message-row > div:not(.message-avatar) { max-width: 90%; }

    .welcome-suggestions { flex-direction: column; align-items: stretch; }
    .suggestion-chip { text-align: center; }

    .chat-input-area {
        padding: 0 16px 16px;
        left: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sidebar { width: 85vw; min-width: 85vw; }
    .messages { padding: 16px; padding-bottom: 100px; }
    .message-row { gap: 12px; }
    .message-row > div:not(.message-avatar) { max-width: 95%; }
    .message-bubble { padding: 12px 16px; }
    .welcome-screen h2 { font-size: 1.8rem; }
    .welcome-orb { width: 72px; height: 72px; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .chat-input-area, .typing-indicator, .chat-header { display: none !important; }
    .chat-main { display: block; }
    .messages { overflow: visible; height: auto; padding: 0; }
}

/* ---------- Reply Chat Feature ---------- */
.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    animation: slideUp 0.2s ease;
}
.reply-preview.hidden {
    display: none;
}
.reply-preview-content {
    flex: 1;
    min-width: 0;
}
.reply-preview-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.reply-preview-text {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}
.btn-cancel-reply {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all var(--transition);
}
.btn-cancel-reply:hover {
    background: var(--danger);
    color: #fff;
}

/* Reply Quote inside Message Bubble */
.message-reply-quote {
    background: rgba(0, 0, 0, 0.04);
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 13.5px;
    color: var(--text-secondary);
    max-width: 100%;
}
[data-theme="dark"] .message-reply-quote {
    background: rgba(255, 255, 255, 0.05);
}
.message-row.user .message-reply-quote {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #fff;
    color: rgba(255, 255, 255, 0.9);
}
.reply-quote-role {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}
.reply-quote-text {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reply Button on Message Hover */
/* Note: .message-row & .message-row-container styles are merged above */
.message-actions {
    display: none;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}
.message-row.user .message-actions {
    left: -60px;
}
.message-row.bot .message-actions {
    right: -60px;
}
.message-row:hover .message-actions {
    display: flex;
    animation: fadeIn 0.2s ease;
}
.btn-message-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-message-action:hover {
    color: var(--accent);
    background: var(--bg-hover);
}

/* ---------- Edit Message Inline ---------- */
.edit-message-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 280px;
    width: 100%;
}
.edit-message-input {
    width: 100%;
    min-height: 60px;
    max-height: 300px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}
.edit-message-input:focus {
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.18);
}
.edit-message-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.btn-edit-cancel,
.btn-edit-send {
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-edit-cancel {
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
}
.btn-edit-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
}
.btn-edit-send {
    background: #fff;
    color: var(--accent, #1d72dd);
}
.btn-edit-send:hover {
    opacity: 0.85;
}

/* ---------- Modal Profile ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity var(--transition);
}
.modal.hidden {
    display: none;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}
.modal-card {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    z-index: 1010;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    background: var(--bg-tertiary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.modal-close:hover {
    background: var(--danger);
    color: #fff;
}
.modal-body {
    padding: 24px;
    overflow-y: auto;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
}
.modal-footer-profile {
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
.modal-footer-actions {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

/* Profile Avatar Section */
.profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}
.profile-avatar-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--bg-primary);
    box-shadow: 0 0 0 2px var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.profile-avatar-wrapper:hover {
    box-shadow: 0 0 0 2px var(--accent);
}
.profile-avatar-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    transition: opacity var(--transition);
}
.profile-avatar-wrapper:hover .avatar-upload-overlay {
    opacity: 1;
}
.avatar-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 10px;
}

/* Form Controls inside Modal */
.form-group {
    margin-bottom: 20px;
}
.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all var(--transition);
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(29, 114, 221, 0.15);
}
.form-control[readonly] {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Buttons */
.btn-primary {
    padding: 12px 24px;
    background: linear-gradient(135deg, #1d72dd, #1557b0);
    color: #fff;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-secondary {
    padding: 12px 24px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-secondary:hover {
    background: var(--bg-hover);
}
.btn-danger {
    padding: 12px 24px;
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 20px;
    font-weight: 500;
}
.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ---------- Custom Elegant Model Dropdown & Right Input Actions ---------- */
.input-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.custom-model-dropdown {
    position: relative;
    display: inline-block;
}

.btn-model-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid rgba(29, 114, 221, 0.25);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.btn-model-trigger:hover, .btn-model-trigger.active {
    border-color: var(--accent);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(29, 114, 221, 0.15);
    transform: translateY(-1px);
}
.model-chevron {
    transition: transform var(--transition);
    color: var(--text-tertiary);
}
.btn-model-trigger.open .model-chevron {
    transform: rotate(180deg);
}

.model-options-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    min-width: 250px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.05);
    padding: 6px;
    z-index: 200;
    backdrop-filter: blur(12px);
    animation: popUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.model-options-menu.hidden {
    display: none;
}

@keyframes popUp {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.model-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.model-option:hover {
    background: var(--bg-hover);
}
.model-option.active {
    background: rgba(29, 114, 221, 0.1);
}
.option-icon {
    font-size: 18px;
    flex-shrink: 0;
}
.option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.option-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
}
.option-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}
.option-check {
    font-weight: bold;
    color: var(--accent);
    opacity: 0;
    transition: opacity var(--transition);
}
.model-option.active .option-check {
    opacity: 1;
}

/* ---------- Input Toggles (Web Search) ---------- */
.btn-input-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-input-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-input-toggle.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(29, 114, 221, 0.3);
}

/* ---------- Document Live Preview Modal ---------- */
.doc-preview-card {
    max-width: 800px;
    width: 95vw;
    height: 85vh;
}
.doc-preview-body {
    background: var(--bg-tertiary);
    padding: 24px;
}
.doc-preview-paper {
    background: #ffffff;
    color: #1f2937;
    max-width: 680px;
    margin: 0 auto;
    padding: 40px 48px;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    font-family: var(--font-sans);
    line-height: 1.7;
}
.doc-preview-paper h1 { font-size: 2rem; color: #1e3a8a; margin-bottom: 16px; border-bottom: 2px solid #e2e8f0; padding-bottom: 8px; }
.doc-preview-paper h2 { font-size: 1.5rem; color: #2563eb; margin: 24px 0 12px; }
.doc-preview-paper h3 { font-size: 1.2rem; color: #374151; margin: 18px 0 8px; }
.doc-preview-paper table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.doc-preview-paper th { background: #1d72dd; color: #ffffff; padding: 10px 12px; border: 1px solid #cbd5e1; text-align: left; }
.doc-preview-paper td { padding: 8px 12px; border: 1px solid #e2e8f0; }
.doc-preview-paper tr:nth-child(even) { background: #f8fafc; }
.doc-preview-paper blockquote { border-left: 4px solid #818cf8; padding-left: 14px; margin: 16px 0; color: #4b5563; font-style: italic; }
.doc-preview-paper pre { background: #f8fafc; border: 1px solid #e2e8f0; border-left: 4px solid #1d72dd; padding: 12px; border-radius: 6px; font-family: var(--font-mono); font-size: 13px; overflow-x: auto; }

/* ---------- Premium Styling for Folder Chips & Header Buttons ---------- */

/* Folder Filter Bar */
.folder-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}
.folder-filter-bar::-webkit-scrollbar {
    display: none;
}

.folder-chips {
    display: flex;
    gap: 10px;
}

.folder-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.folder-chip:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.folder-chip.active {
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

#btn-add-folder {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    border: 1px dashed var(--accent);
    background: transparent;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
#btn-add-folder:hover {
    background: rgba(37, 99, 235, 0.1);
    transform: rotate(90deg);
}

/* Header Action Buttons */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.header-action-btn svg {
    color: inherit;
    transition: transform 0.3s ease;
}
.header-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-2px);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.model-option:hover {
    background: var(--bg-hover);
}
.model-option.active {
    background: rgba(29, 114, 221, 0.1);
}
.option-icon {
    font-size: 18px;
    flex-shrink: 0;
}
.option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.option-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
}
.option-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}
.option-check {
    font-weight: bold;
    color: var(--accent);
    opacity: 0;
    transition: opacity var(--transition);
}
.model-option.active .option-check {
    opacity: 1;
}

/* ---------- Input Toggles (Web Search) ---------- */
.btn-input-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-input-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-input-toggle.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(29, 114, 221, 0.3);
}

/* ---------- Document Live Preview Modal ---------- */
.doc-preview-card {
    max-width: 800px;
    width: 95vw;
    height: 85vh;
}
.doc-preview-body {
    background: var(--bg-tertiary);
    padding: 24px;
}
.doc-preview-paper {
    background: #ffffff;
    color: #1f2937;
    max-width: 680px;
    margin: 0 auto;
    padding: 40px 48px;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    font-family: var(--font-sans);
    line-height: 1.7;
}
.doc-preview-paper h1 { font-size: 2rem; color: #1e3a8a; margin-bottom: 16px; border-bottom: 2px solid #e2e8f0; padding-bottom: 8px; }
.doc-preview-paper h2 { font-size: 1.5rem; color: #2563eb; margin: 24px 0 12px; }
.doc-preview-paper h3 { font-size: 1.2rem; color: #374151; margin: 18px 0 8px; }
.doc-preview-paper table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.doc-preview-paper th { background: #1d72dd; color: #ffffff; padding: 10px 12px; border: 1px solid #cbd5e1; text-align: left; }
.doc-preview-paper td { padding: 8px 12px; border: 1px solid #e2e8f0; }
.doc-preview-paper tr:nth-child(even) { background: #f8fafc; }
.doc-preview-paper blockquote { border-left: 4px solid #818cf8; padding-left: 14px; margin: 16px 0; color: #4b5563; font-style: italic; }
.doc-preview-paper pre { background: #f8fafc; border: 1px solid #e2e8f0; border-left: 4px solid #1d72dd; padding: 12px; border-radius: 6px; font-family: var(--font-mono); font-size: 13px; overflow-x: auto; }

/* ---------- Premium Styling for Folder Chips & Header Buttons ---------- */

/* Folder Filter Bar */
.folder-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}
.folder-filter-bar::-webkit-scrollbar {
    display: none;
}

.folder-chips {
    display: flex;
    gap: 10px;
}

.folder-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.folder-chip:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.folder-chip.active {
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

#btn-add-folder {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    border: 1px dashed var(--accent);
    background: transparent;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
#btn-add-folder:hover {
    background: rgba(37, 99, 235, 0.1);
    transform: rotate(90deg);
}

/* Header Action Buttons */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.header-action-btn svg {
    color: inherit;
    transition: transform 0.3s ease;
}
.header-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.header-action-btn:hover svg {
    transform: scale(1.1);
}
#pinned-count-badge {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* ---------- Mobile Responsive Fixes ---------- */
@media (max-width: 768px) {
    /* Layout Fixes to prevent keyboard overlap and scroll issues */
    .chat-main {
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        height: 100vh; /* Fallback */
    }
    .messages {
        padding: 12px;
        padding-bottom: 24px; /* Remove large padding meant for fixed input */
    }
    .message-row {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 0 16px 0 !important;
        gap: 10px !important;
    }
    .message-row > div:not(.message-avatar),
    .message-row-container {
        max-width: 88% !important;
    }
    .message-bubble {
        max-width: 100% !important;
        font-size: 14px !important;
        padding: 10px 14px !important;
        text-align: left !important;
    }
    .message-bubble table {
        font-size: 12.5px !important;
    }
    .chat-input-area {
        position: relative !important;
        left: 0 !important;
        width: 100% !important;
        padding: 0 16px 16px !important;
        background: var(--bg-primary) !important; /* Solid background */
        flex-shrink: 0;
        z-index: 20;
    }
    .welcome-screen {
        height: auto;
        min-height: 100%;
        padding-bottom: 40px;
    }

    /* Header Fixes */
    .chat-header-info {
        flex: 1;
        min-width: 0; /* allows truncation */
        margin-right: 8px;
    }
    .chat-title {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .header-action-btn span:not(#pinned-count-badge) {
        display: none; /* Hide 'Bagikan' text on mobile, keep icon */
    }
    .header-action-btn {
        padding: 8px;
    }
    .ai-badge {
        display: none; /* Hide smart AI badge on mobile to save space */
    }

    /* Input Area Fixes */
    .input-actions-right {
        gap: 4px;
    }
    .btn-model-trigger {
        padding: 6px 10px;
        font-size: 11px;
    }
    #model-current-label {
        display: none; /* Hide model label text on mobile */
    }
    .model-options-menu {
        right: auto;
        left: 0; /* Align left to avoid overflow on mobile */
    }
    .input-actions .btn-icon {
        width: 34px;
        height: 34px;
    }
    .btn-send {
        width: 38px;
        height: 38px;
    }

    /* Suggestions Fix */
    .welcome-suggestions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    .suggestion-chip {
        flex: 0 1 auto;
        font-size: 13px;
        padding: 8px 14px;
    }
}

@media (max-width: 480px) {
    .chat-header-actions {
        gap: 6px;
    }
    .chat-input-area {
        padding: 0 12px 12px !important;
    }
    .chat-input-container {
        padding: 10px 12px;
    }
}
