/* Premium design tokens */
:root {
    --bg-main: rgb(219, 255, 224);
    --bg-sidebar: #c9ebd0;
    --bg-input: #ffffff;
    --bg-message-user: #ffffff;
    --text-primary: #121212;
    --text-secondary: #4d4d4d;
    --border-color: rgba(0, 0, 0, 0.1);
    --hover-color: rgba(0, 0, 0, 0.05);
    --hover-input: #fcfcfc;
    --accent: #212121;
    --logo-icon: #212121;
    --btn-disabled-bg: #d0d0d0;
    --btn-disabled-text: #888888;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --radius-full: 9999px;
    --radius-xl: 1.5rem;
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --radius-sm: 0.5rem;
}

/* Dark Theme Overrides */
:root[data-theme="dark"] {
    --bg-main: #000000;
    --bg-sidebar: #0a0a0a;
    --bg-input: #1a1a1a;
    --bg-message-user: #1a1a1a;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --border-color: rgba(255, 255, 255, 0.1);
    --hover-color: rgba(255, 255, 255, 0.08);
    --hover-input: #222222;
    --accent: #ffffff;
    --logo-icon: #ffffff;
    --btn-disabled-bg: #333333;
    --btn-disabled-text: #666666;
    --hover-sidebar: #1a1a1a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden; /* Avoid main body scroll */
    height: 100dvh;
}

.app-container {
    display: flex;
    height: 100dvh;
    width: 100vw;
}

/* Sidebar styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem 0.75rem;
    flex-shrink: 0;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
    overflow: hidden;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-sm);
    cursor: default; /* Disabled state behavior */
    transition: background-color 0.2s ease, opacity 0.2s ease;
    opacity: 0.8;
}

.nav-button:hover {
    background-color: var(--hover-color);
    opacity: 1;
}

.nav-button i {
    font-size: 1.25rem;
}

/* Let's make "New chat" stand out slightly if desired, though in disabled state it might be muted */
.nav-group {
    margin-top: 1rem;
}

/* Main Chat Area */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-main);
}

.chat-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    /* For a truly immersive feel, could be fixed matching chatgpt */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-left: 0;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
    transition: color 0.2s;
}

.mobile-menu-btn:hover {
    color: var(--text-primary);
}

.chat-header h2:hover {
    opacity: 0.8;
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 2rem;
    padding-top: 60px; /* Space for header */
    scroll-behavior: smooth;
}

.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 60%;
    margin: auto;
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.empty-state .logo-wrapper {
    width: 60px;
    height: 60px;
    background-color: var(--accent);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.empty-state .logo-wrapper i {
    font-size: 2rem;
    color: var(--bg-main);
}

.empty-state h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

/* Chat Messages */
.message-wrapper {
    width: 100%;
    max-width: 48rem;
    padding: 1.5rem 1rem;
    display: flex;
    gap: 1rem;
    animation: slideUp 0.3s ease-out forwards;
    opacity: 0;
}

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

.message-wrapper.user {
    justify-content: flex-end;
}

.message-wrapper.ai {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 85%;
    line-height: 1.6;
    font-size: 1rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-wrapper.user .message-bubble {
    background-color: var(--bg-message-user);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-xl);
    border-bottom-right-radius: 0.2rem;
}

.message-wrapper.ai .message-bubble {
    padding: 0.5rem 0;
}

.ai-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.ai-avatar i {
    font-size: 1rem;
}

/* Refresh Button Styling */
.refresh-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem;
    margin-top: 0.4rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.6;
    width: 28px;
    height: 28px;
}

.refresh-btn:hover {
    background-color: var(--hover-color);
    color: var(--accent);
    opacity: 1;
    transform: rotate(45deg);
}

.refresh-btn i {
    font-size: 1.1rem;
}

.refresh-btn.spinning i {
    animation: spin 1s infinite linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* Input Area */
.chat-input-container {
    width: 100%;
    max-width: 50rem;
    margin: 0 auto;
    padding: 0 1rem 1rem 1rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-form {
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border-radius: var(--radius-full);
    width: 100%;
    padding: 0.5rem;
    border: 1px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chat-form:focus-within {
    border-color: var(--border-color);
    background-color: var(--hover-input);
}

.attachment-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    flex-shrink: 0;
}

.attachment-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--accent);
}

.attachment-btn i {
    font-size: 1.25rem;
}

#chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    padding: 0 0.5rem;
    outline: none;
    height: 40px;
}

#chat-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background-color: var(--accent);
    color: var(--bg-main);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    flex-shrink: 0;
    margin-right: 0.25rem;
}

.send-btn:disabled {
    background-color: var(--btn-disabled-bg);
    color: var(--btn-disabled-text);
    cursor: not-allowed;
    opacity: 0.5;
}

.send-btn:not(:disabled):hover {
    opacity: 0.9;
}
.send-btn:not(:disabled):active {
    transform: scale(0.95);
}

/* Thinking Toggle Button */
.thinking-toggle-btn {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-right: 0.25rem;
    opacity: 0.55;
    position: relative;
}

.thinking-toggle-btn i {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.thinking-toggle-btn:hover {
    opacity: 0.85;
    border-color: var(--accent);
    color: var(--accent);
}

.thinking-toggle-btn.active {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: transparent;
    color: #fff;
    opacity: 1;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.thinking-toggle-btn.active i {
    transform: scale(1.1);
}

.thinking-toggle-btn.active:hover {
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.6);
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    text-align: center;
}

/* Loading animation for AI */
.typing-dots {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 0;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background-color: var(--bg-main);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeInScale 0.8s ease-out forwards;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.splash-logo-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.splash-logo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.splash-text {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    padding: 0 1rem;
}

/* Chat History List */
.chat-history-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
    padding-right: 0.25rem;
}

.chat-history-list::-webkit-scrollbar {
    width: 4px;
}
.chat-history-list::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.history-item {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    text-align: left;
    border: none;
    background: transparent;
    font-family: inherit;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
}

.delete-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s, color 0.2s;
    padding: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.history-item:hover .delete-chat-btn {
    opacity: 0.5;
}

.delete-chat-btn:hover {
    opacity: 1 !important;
    color: #e53935;
}

.history-item:hover, .history-item.active {
    background-color: var(--hover-color);
    color: var(--text-primary);
}

.history-disclaimer, .sidebar-disclaimer {
    font-size: 0.65rem;
    color: var(--text-secondary);
    opacity: 0.7;
    text-align: center;
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
    line-height: 1.3;
}

/* Sidebar Search Architecture */
.sidebar-search-form {
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border-radius: var(--radius-full);
    width: 100%;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
    height: 40px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.sidebar-search-form:focus-within {
    border-color: var(--border-color);
    background-color: var(--hover-input);
}

#sidebar-search-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0 0.25rem;
    outline: none;
    width: 10px; /* shrink to trigger flex-grow mostly */
}

.sidebar-search-submit {
    background-color: var(--accent);
    color: var(--bg-main);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-search-close {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    margin-left: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color 0.2s;
}

.sidebar-search-close:hover {
    color: var(--text-primary);
}

.search-results-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
    padding-right: 0.25rem;
}

.search-results-list::-webkit-scrollbar {
    width: 4px;
}
.search-results-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.search-result-item {
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: left;
    border: none;
    background: transparent;
    font-family: inherit;
    width: 100%;
}

.search-result-item:hover {
    background-color: var(--hover-color);
}

.search-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-snippet {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Input Warning */
.input-warning {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    text-align: center;
    margin-bottom: 0.5rem;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.input-warning.hidden {
    opacity: 0;
}

.disclaimer a {
    color: var(--text-secondary);
    text-decoration: underline;
}
.disclaimer a:hover {
    color: var(--text-primary);
}

/* Interactive Bubble Design */
.interactive-bubble {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.2) 60%, rgba(255,255,255,0.05));
    box-shadow: inset -2px -2px 6px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(4px);
    cursor: pointer;
    animation: wobble 4s infinite ease-in-out alternate;
    transition: filter 0.2s;
    flex-shrink: 0;
}

.interactive-bubble:hover {
    box-shadow: inset -2px -2px 6px rgba(0, 0, 0, 0.1), 0 6px 16px rgba(0, 0, 0, 0.1);
    filter: brightness(1.1);
}

@keyframes wobble {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    33% { transform: scale(1.05) translate(2px, -2px) rotate(5deg); }
    66% { transform: scale(0.95) translate(-2px, 1px) rotate(-3deg); }
    100% { transform: scale(1.02) translate(1px, -1px) rotate(2deg); }
}

.interactive-bubble.burst {
    animation: burst 0.3s cubic-bezier(0.1, 0.9, 0.2, 1) forwards !important;
    pointer-events: none;
}

@keyframes burst {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.8; }
    100% { transform: scale(1.8); opacity: 0; border: 1px solid rgba(255,255,255,0.5); }
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 1.5rem 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    min-width: 280px;
    animation: popIn 0.2s ease-out forwards;
}

@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
}

.modal-btn {
    background: transparent;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    padding: 0.5rem 1rem;
}

.modal-btn:hover {
    opacity: 0.7;
}

.modal-btn.cancel {
    color: #e53935;
}

.modal-btn.confirm {
    color: var(--text-primary);
}

/* Mobile Responsive Design */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Attachment Choice Menu Architecture */
.attachment-menu-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.attachment-float-menu {
    position: absolute;
    bottom: 50px;
    left: -4px;
    display: flex;
    gap: 0.6rem;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    z-index: 1001;
    transform-origin: bottom left;
    animation: slideUpFade 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.attachment-btn i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.attachment-btn.open i {
    transform: rotate(45deg);
}

.float-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.float-btn i {
    font-size: 1.25rem;
}

.float-btn:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Attachment Preview Container Constraints */
.attachment-preview-container {
    padding: 0.5rem 1rem 0 1rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Base style for both pills and thumbnails */
.attachment-card {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

/* Text document pill */
.attachment-card.pill {
    padding: 0.35rem 0.75rem;
    padding-right: 2rem; /* space for absolute close button */
    gap: 0.5rem;
}

.attachment-card.pill i {
    font-size: 1.2rem;
    color: var(--accent);
}

.attachment-card.pill span {
    font-size: 0.85rem;
    color: var(--text-primary);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Image thumbnail */
.attachment-card.thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 12px;
}

.attachment-card.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* The Close 'X' Button Overlay */
.remove-attachment-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
}

.attachment-card.pill .remove-attachment-btn {
    top: 50%;
    transform: translateY(-50%);
    background: var(--hover-input);
    color: var(--text-secondary);
}

.attachment-card.pill .remove-attachment-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.attachment-card.thumbnail .remove-attachment-btn:hover {
    background: rgba(0,0,0,0.7);
}


@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100dvh;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: block;
    }

    .chat-header {
        padding: 0 1rem;
    }

    .message-wrapper {
        padding: 1rem 0.5rem;
    }

    .message-bubble {
        max-width: 90%;
    }

/* Settings Sub-Menu Styling */
.settings-menu-wrapper {
    position: relative;
    width: 100%;
}

.settings-float-menu {
    position: absolute;
    bottom: -10px;
    left: 270px; /* Appear next to sidebar in desktop */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-message-user);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    animation: slideRightFade 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.2) forwards;
}

@media (max-width: 768px) {
    .settings-float-menu {
        left: unset;
        right: -10px;
        bottom: 60px;
        animation: slideUpFade 0.3s ease-out forwards;
    }
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem;
}

.settings-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.settings-icon-btn:hover {
    background: var(--accent);
    color: var(--bg-main);
}

.options-group {
    display: flex;
    background: var(--hover-color);
    padding: 4px;
    border-radius: 12px;
    gap: 2px;
}

.option-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.option-btn.active {
    background: var(--bg-main);
    color: var(--text-primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

@keyframes slideRightFade {
    from { opacity: 0; transform: translateX(-20px) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

    .chat-input-container {
        padding: 0 0.5rem 1rem 0.5rem;
    }
    
    /* Improve touch targets */
    .nav-button {
        padding: 1rem;
    }
    
    .chat-form {
        padding: 0.25rem;
    }
    
    #chat-input {
        font-size: 16px; /* Prevents iOS auto-zoom on focus */
    }
}

/* --- Markdown & Code Block Aesthetics --- */

/* Markdown spacing and typography inside message bubbles */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
}
.message-bubble h1 { font-size: 1.35rem; }
.message-bubble h2 { font-size: 1.2rem; }
.message-bubble h3 { font-size: 1.1rem; }
.message-bubble h4 { font-size: 1.0rem; }

.message-bubble p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}
.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
}

.message-bubble li {
    margin-bottom: 0.35rem;
}

.message-bubble blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 0.75rem;
    margin: 0.5rem 0 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-bubble a {
    color: #10b981; /* Theme-matching green/emerald */
    text-decoration: underline;
    text-underline-offset: 2px;
}
.message-bubble a:hover {
    opacity: 0.8;
}

.message-bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: 0.9rem;
}
.message-bubble th,
.message-bubble td {
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-align: left;
}
.message-bubble th {
    background-color: var(--hover-color);
    font-weight: 600;
}

.message-bubble code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.88em;
    background-color: var(--hover-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Reset code elements inside pre container to prevent double borders/padding */
.message-bubble pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    font-size: 0.9rem;
    color: inherit;
}

/* Premium Code Block Layout & Header */
.code-block-wrapper {
    margin: 1.25rem 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    background-color: #1d1f21; /* Dark theme regardless of light/dark mode */
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #282a2e;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: #969896;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    user-select: none;
}

.code-block-lang {
    font-weight: 600;
    font-family: var(--font-family);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-block-copy-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: transparent;
    border: none;
    color: #969896;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.code-block-copy-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.code-block-copy-btn.copied {
    color: #10b981;
}

/* Adjust Prism CSS margin and layout */
.message-bubble pre[class*="language-"] {
    margin: 0 !important;
    padding: 1rem !important;
    background: #1d1f21 !important;
    overflow-x: auto;
    border-radius: 0 !important;
    border: none !important;
}

.message-bubble code[class*="language-"] {
    background: transparent !important;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;
}


