/* home.css */
@font-face {
    font-family: 'Share Tech';
    src: url('font/ShareTech-Regular.ttf') format('truetype');
}

body {
    font-family: 'Share Tech', monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Static colors */
    --bg-base: #0A0A0A;
    --glass-panel: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
    --accent-color: #667eea;
    --text-primary: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh; /* Dynamic height for mobile browsers */
    overflow: hidden; /* Prevent body scroll */
    font-size: 16px;
}


body.light { 
    --bg-base: #F0F2F5;
    --glass-panel: #ffffff;
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-primary: #1A1A1A;
    --text-muted: rgba(0, 0, 0, 0.6);
    background: #F0F2F5; color: #1A1A1A; 
}

.container { 
    display: flex; 
    height: 100%; /* Fill body */
    position: relative; 
    background: var(--bg-base);
    overflow: hidden; /* Important to keep input fixed */
}

.container.zen-mode .sidebar { display: none; }
.container.zen-mode .header { display: none; }

/* --- SIDEBAR --- */
.sidebar {
    width: 280px; 
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    display: flex; flex-direction: column; 
    transition: transform 0.3s ease; z-index: 100; flex-shrink: 0;
}
body.light .sidebar { background: rgba(255, 255, 255, 0.8); border-right: 1px solid rgba(0,0,0,0.05); }

@media (min-width: 769px) {
    .sidebar.hidden { transform: translateX(-100%); margin-right: -280px; }
}

.sidebar-header { padding: 20px; display: flex; gap: 10px; flex-direction: column; }
.sidebar-header-row { display: flex; gap: 10px; }

.new-chat-btn {
    flex: 1; padding: 12px; 
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border); 
    border-radius: 12px;
    color: var(--text-primary); font-family: inherit; font-size: 0.95rem; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; 
    transition: all 0.2s;
}
.sidebar-action-btn {
     width: 46px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); 
     border-radius: 12px; color: var(--text-primary); cursor: pointer; transition: all 0.2s; 
     display: flex; align-items: center; justify-content: center;
}

body.light .new-chat-btn, body.light .sidebar-action-btn { 
    background: white; border-color: rgba(0,0,0,0.1); color: #000; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.new-chat-btn:hover, .sidebar-action-btn:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-1px); }
body.light .new-chat-btn:hover, body.light .sidebar-action-btn:hover { background: #f8f9fa; }

/* Temp Chat Button Style */
.temp-chat-btn { border-style: dashed; opacity: 0.8; }
.temp-chat-btn:hover { opacity: 1; border-style: solid; }

.section-label {
    padding: 15px 12px 8px; font-size: 0.75rem; color: var(--text-muted); 
    font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
}

.chats-list { flex: 1; overflow-y: auto; padding: 0 10px; }
.chats-list::-webkit-scrollbar { width: 4px; }
.chats-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.chat-item {
    padding: 12px 14px; margin-bottom: 6px; border-radius: 10px; cursor: pointer;
    transition: all 0.2s; position: relative; display: flex; align-items: center;
    gap: 12px; font-size: 0.9rem; color: var(--text-muted);
}
.chat-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
body.light .chat-item:hover { background: rgba(0,0,0,0.05); }
.chat-item.active { 
    background: rgba(102, 126, 234, 0.15); 
    color: var(--text-primary); 
    border: 1px solid rgba(102, 126, 234, 0.3);
}
body.light .chat-item.active { background: #fff; border-color: var(--accent-color); color: var(--accent-color); box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

.chat-item-title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.chat-menu-btn {
    background: transparent; border: none; color: inherit; opacity: 0;
    padding: 6px; border-radius: 4px; cursor: pointer; transition: opacity 0.2s; font-size: 1rem;
}
.chat-item:hover .chat-menu-btn { opacity: 1; }
.chat-item.active .chat-menu-btn { opacity: 1; }
.chat-menu-btn:hover { background: rgba(255,255,255,0.2); }

/* Context Menu */
.popover-menu {
    position: absolute; 
    background: #0A0A0A; 
    border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 6px; z-index: 200; display: none;
    min-width: 160px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
body.light .popover-menu { background: white; border-color: rgba(0,0,0,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.1); }
.popover-menu.active { display: block; animation: fadeIn 0.2s; }
.popover-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 14px; text-align: left;
    background: transparent; border: none; color: inherit;
    cursor: pointer; font-size: 0.9rem; border-radius: 8px; font-family: inherit;
}
.popover-item:hover { background: rgba(255,255,255,0.1); }
body.light .popover-item:hover { background: rgba(0,0,0,0.05); }

.sidebar-footer {
    display: flex;
    flex-direction: row !important;      /* Force side-by-side alignment */
    align-items: center;      /* Vertically center everything */
    justify-content: space-between;
    padding: 12px;
    gap: 12px;                /* consistent spacing */
}

.profile-info {
    flex: 1;                  
    display: flex;
    flex-direction: column;   /* Keep name above model text */
    justify-content: center;
    min-width: 0;             /* Prevents text overflow issues */
}

/* Ensure action buttons (gear/logout) stay side-by-side */
.profile-actions {
    display: flex;
    flex-direction: row;      /* Force buttons side-by-side */
    gap: 8px;                 /* Space between buttons */
    flex-shrink: 0;           /* Prevent buttons from squishing */
}
.profile-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.profile-engine { font-size: 0.75rem; opacity: 0.7; cursor: pointer; }
.profile-engine:hover { text-decoration: underline; color: var(--accent-color); }

.profile-actions button {
    padding: 8px; background: transparent; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1.1rem; border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
}
.profile-actions button:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }

/* --- MAIN CONTENT --- */
.main-content { 
    flex: 1; display: flex; flex-direction: column; background: transparent; width: 100%; 
}

.header {
    padding: 16px 24px; 
    border-bottom: 1px solid var(--glass-border); 
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(10, 10, 10, 0.6);
    backdrop-filter: blur(5px);
}
body.light .header { background: rgba(255, 255, 255, 0.6); border-bottom-color: rgba(0,0,0,0.05); }

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    background: transparent; border: none; color: var(--text-muted); font-size: 1.2rem;
    cursor: pointer; padding: 8px; border-radius: 8px; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }
body.light .icon-btn:hover { background: rgba(0,0,0,0.05); }

.header-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }

/* --- CHAT AREA --- */
.chat-area { 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden;
    display: flex; 
    flex-direction: column; 
    padding: 24px 0; 
    gap: 30px; 
    padding-bottom: 20px;
    min-height: 0; /* Critical for flex scrolling */
}

.empty-state {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center; opacity: 0.8;
}
.empty-state h2 { font-size: 3rem; margin-bottom: 16px; font-weight: 700; color: var(--text-primary); }
.empty-state p { color: var(--text-muted); font-size: 1.1rem; max-width: 400px; }

/* Message Rows */
.message-row {
    display: flex; width: 100%; flex-direction: column; padding: 0 10%;
}
@media (max-width: 1024px) { .message-row { padding: 0 5%; } }

.message-row:hover .message-actions { opacity: 1; }

.message-container { display: flex; width: 100%; }
.message-content-wrapper { max-width: 90%; position: relative; }

.message-bubble {
    padding: 20px 24px; border-radius: 18px; line-height: 1.6;
    word-wrap: break-word; font-size: 1.05rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* AI Message */
.message-row.assistant .message-container { justify-content: flex-start; }
.message-row.assistant .message-bubble {
    background: rgba(255, 255, 255, 0.05); 
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}
body.light .message-row.assistant .message-bubble { 
    background: white; border-color: rgba(0,0,0,0.05); color: #000; box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* User Message */
.message-row.user .message-container { justify-content: flex-end; }
.message-row.user .message-bubble {
    background: var(--accent-color); 
    color: #fff; 
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Message Actions Toolbar */
.message-actions {
    display: flex; gap: 8px; margin-top: 8px; opacity: 0; transition: opacity 0.2s;
    font-size: 0.9rem; color: var(--text-muted);
}
@media (max-width: 768px) { .message-actions { opacity: 1; } }

.message-row.user .message-actions { justify-content: flex-end; padding-right: 4px; }
.message-row.assistant .message-actions { justify-content: flex-start; padding-left: 0; }

.action-btn {
    background: rgba(255,255,255,0.05); border: 1px solid transparent; 
    color: inherit; cursor: pointer;
    padding: 6px 10px; border-radius: 8px; display: flex; align-items: center; gap: 4px;
    font-size: 0.9rem;
}
.action-btn:hover { background: rgba(255,255,255,0.15); color: var(--text-primary); border-color: var(--glass-border); }

/* --- INPUT AREA --- */
.input-area { 
    padding: 24px; 
    background: var(--bg-base); 
}

.input-wrapper {
    max-width: 800px; margin: 0 auto; position: relative; 
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 10px; 
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2); 
    display: flex; flex-direction: column;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.input-wrapper:focus-within {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.15);
}
body.light .input-wrapper { background: white; border-color: rgba(0,0,0,0.1); box-shadow: 0 4px 20px rgba(0,0,0,0.05); }

.input-tools {
    display: flex; gap: 12px; padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.05);
}
body.light .input-tools { border-bottom-color: rgba(0,0,0,0.05); }

.tool-btn {
    background: transparent; border: none; color: var(--text-muted); 
    opacity: 0.7; cursor: pointer; font-size: 1rem; transition: 0.2s;
}
.tool-btn:hover { opacity: 1; color: var(--text-primary); transform: translateY(-1px); }

.input-box {
    width: 100%; background: transparent; border: none; color: var(--text-primary);
    font-family: inherit; font-size: 1rem; outline: none; resize: none;
    padding: 16px 60px 16px 16px; max-height: 200px; min-height: 52px;
}

.send-btn {
    position: absolute; right: 10px; bottom: 10px; padding: 0; 
    background: #fff; 
    border: none; border-radius: 50%; 
    color: var(--accent-color); cursor: pointer; font-size: 1.1rem;
    width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.send-btn.edit-mode { background: #f39c12; color: white; }
.send-btn:hover:not(:disabled) { transform: scale(1.1); box-shadow: 0 6px 15px rgba(0,0,0,0.3); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; background: rgba(255,255,255,0.1); color: #888; }

.token-counter {
    text-align: center; font-size: 0.75rem; color: var(--text-muted); margin-top: 8px;
}

.sidebar-backdrop {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(3px); z-index: 90;
}

/* Search Bar */
.search-bar {
    margin: 0 12px 12px; padding: 12px; 
    background: rgba(0,0,0,0.2); 
    border-radius: 12px;
    border: 1px solid var(--glass-border); 
    color: white; display: none; font-family: inherit; font-size: 0.9rem;
}
.search-bar.active { display: block; }
body.light .search-bar { background: #f0f0f0; border: none; color: black; }

/* Toast */
.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: #667eea; 
    color: white; padding: 12px 24px; border-radius: 50px;
    font-size: 0.95rem; opacity: 0; transition: all 0.3s; pointer-events: none; z-index: 1000;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-10px); }

/* Modals */
.custom-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); z-index: 999; display: none;
    align-items: center; justify-content: center;
}
.custom-modal-overlay.open { display: flex; animation: fadeIn 0.3s; }

.custom-modal {
    background: #0A0A0A; 
    border: 1px solid var(--glass-border);
    border-radius: 20px; padding: 28px; width: 90%; max-width: 420px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); transform: scale(0.95);
    animation: slideIn 0.3s forwards;
}
@keyframes slideIn { to { transform: scale(1); } }
body.light .custom-modal { background: white; border-color: rgba(0,0,0,0.1); color: #000; }

.custom-modal h3 { margin-bottom: 20px; font-size: 1.4rem; font-weight: 700; }
.custom-modal input {
    width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.3); color: white; margin-bottom: 24px;
    font-family: inherit; font-size: 1rem;
}
body.light .custom-modal input { background: #f0f0f0; border-color: #ccc; color: black; }

.modal-btns { display: flex; justify-content: flex-end; gap: 12px; }
.modal-btn {
    padding: 10px 20px; border-radius: 50px; border: none; cursor: pointer;
    font-size: 0.95rem; font-weight: 600; transition: all 0.2s;
}
.modal-btn.cancel { background: transparent; color: var(--text-muted); border: 1px solid var(--glass-border); }
.modal-btn.cancel:hover { background: rgba(255,255,255,0.05); color: white; }
.modal-btn.confirm { background: #fff; color: var(--accent-color); box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); }
.modal-btn.confirm:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); }

.share-options { display: flex; flex-direction: column; gap: 10px; }
.share-option-btn {
    padding: 14px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); 
    border-radius: 12px; color: inherit; cursor: pointer; text-align: left; 
    display: flex; align-items: center; gap: 14px;
    font-size: 1rem; transition: all 0.2s;
}
.share-option-btn:hover { background: rgba(255,255,255,0.1); transform: translateX(5px); }

/* --- MOBILE & GESTURE OPTIMIZATION --- */
.swipe-trigger-zone {
    position: fixed; top: 0; left: 0; width: 20px; height: 100%; z-index: 50; display: none;
}
.zen-exit-btn {
    position: absolute; top: 20px; right: 20px; z-index: 1000;
    width: 45px; height: 45px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: #ececf1; cursor: pointer; display: none;
    align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); transition: all 0.3s;
}
.zen-exit-btn:hover { background: rgba(255, 255, 255, 0.2); transform: rotate(90deg); }
.container.zen-mode .zen-exit-btn { display: flex; }

/* =========================================
   MOBILE SPECIFIC ADJUSTMENTS (max-width: 768px)
   ========================================= */
@media (max-width: 768px) {
    /* Lower Text Size */
    body { font-size: 15px; } /* Slightly lower */
    
    .sidebar { 
        position: absolute; left: 0; top: 0; height: 100%; 
        transform: translateX(-100%); 
        background: #0A0A0A; /* Solid bg on mobile */
        
        will-change: transform;
    }
    .sidebar:focus{
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5); 
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .swipe-trigger-zone { display: block; }

    /* More Width */
    .message-row { 
        padding: 0 10px; /* Reduced side padding (was 20px or 10%) */
    }
    .message-content-wrapper { 
        max-width: 98%; /* Allow messages to take up almost full width */
    }

    /* AI Reply Optimization: Remove Background */
    .message-row.assistant .message-bubble {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        padding-left: 0; /* Remove left padding to align with edge */
        padding-right: 0;
        font-size: 1rem; /* Specific size */
    }

    /* Input Area Compact */
    .input-area { padding: 16px 12px; }
    .input-box { padding: 14px 45px 14px 14px; }
    
    /* Header Adjust */
    .header { padding: 12px 16px; }
    .header-title { font-size: 1rem; }
}
.profile-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary-bg);
    color: var(--text-primary);
    font-size: 1.2rem;
    overflow: hidden;
    flex-shrink: 0;
}

/* Remove background for emoji profiles */
.profile-icon.emoji-profile {
    background: transparent !important;
}

.profile-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.profile-icon span {
    font-size: 1.8rem;
    line-height: 1;
}
@font-face {
    font-family: 'Share Tech';
    src: url('font/ShareTech-Regular.ttf') format('truetype');
}

body {
    font-family: 'Share Tech', monospace;
}
/* =========================================
   THEME REPAIR & OPTIMIZATIONS
   ========================================= */

/* 1. Fix Bold & Heading Colors (Critical) */
/* Uses !important to override the inline 'color: #fff' injected by JS */
.message-bubble strong,
.message-bubble b,
.message-bubble h1, .message-bubble h2, .message-bubble h3, 
.message-bubble h4, .message-bubble h5, .message-bubble h6 {
    color: var(--text-primary) !important;
    font-weight: 700;
}

/* 2. Fix Code Blocks for Light Mode */
/* Ensures code isn't white-on-white in light theme */
body.light .message-bubble code {
    color: #c7254e; /* Pinkish red for inline code */
    background: rgba(0, 0, 0, 0.05);
}

body.light .message-bubble pre {
    background: #f6f8fa !important; /* Light gray background */
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.light .message-bubble pre code {
    color: #24292e; /* Dark text for code blocks */
    background: transparent;
}

/* 3. Global Transition Smoothing */
/* Makes switching between light/dark mode feel smoother */
body, .sidebar, .header, .input-wrapper, .message-bubble {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

/* 4. Scrollbar Polish */
/* Makes scrollbars look cleaner and match the theme */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Light mode scrollbar */
body.light ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}
body.light ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* 5. Text Selection Style */
::selection {
    background: rgba(102, 126, 234, 0.3); /* Your accent color low opacity */
    color: inherit;
}
body.light ::selection {
    background: rgba(102, 126, 234, 0.2);
}
/* --- APPEND TO BOTTOM OF home.css --- */

/* Ultra-Smooth Theme Switching */
body, .sidebar, .header, .input-wrapper, 
.message-bubble, .popover-menu {
    transition: background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Message Bubble Entrance "Pop" */
.message-row {
    animation: messagePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transform-origin: bottom left;
}
.message-row.user {
    transform-origin: bottom right;
}

@keyframes messagePop {
    0% { opacity: 0; transform: scale(0.9) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Fluid Sidebar Slide (Mobile) */
.sidebar {
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Send Button Interaction */
.send-btn {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.send-btn:hover:not(:disabled) {
    transform: scale(1.15) rotate(-5deg);
}

/* Chat Item Hover Slide */
.chat-item {
    transition: background 0.2s ease, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chat-item:hover {
    transform: translateX(4px);
}
@media (max-width: 768px) {
    .input-area {
        padding: 10px;
        background: var(--bg-base);
        /* Ensure it sits above virtual keyboard if possible */
        position: relative;
        z-index: 20; 
    }

    /* Adjust input wrapper to look better on small screens */
    .input-wrapper {
        border-radius: 10px;
    }
}
/* Web Search Specific Styles */
.tool-btn.active {

    color: white;
}

.search-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.5);
    border-radius: 12px;
    font-size: 0.75rem;
    color: #4CAF50;
}

.search-indicator i {
    font-size: 0.7rem;
}

.search-citations {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85rem;
    color: #888;
}

.search-citations a {
    color: var(--accent-color);
    text-decoration: none;
    display: block;
    margin-top: 4px;
    transition: color 0.2s;
}

.search-citations a:hover {
    color: #fff;
    text-decoration: underline;
}

/* Usage Stats Styles */
.usage-stats {
    padding: 16px;
    margin: 12px;
    background: --glass-panel;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.usage-item {
    margin-bottom: 16px;
}
/* Fix for mobile audio context */
@media (max-width: 768px) {
    .speak-btn {
        min-width: 40px;
        min-height: 40px;
        font-size: 1.2rem !important;
    }
    
    .message-actions {
        gap: 8px !important;
    }
}
.usage-item:last-child {
    margin-bottom: 0;
}

.usage-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: --text-primary;
    margin-bottom: 6px;
}

.usage-label i {
    font-size: 0.9rem;
    color: var(--accent-color);
}

.usage-bar {
    height: 6px;
    background: --glass-panel;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
}

.usage-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #667eea);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

.usage-fill.warning {
    background: linear-gradient(90deg, #f39c12, #e74c3c);
}

.usage-fill.critical {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.usage-count {
    font-size: 0.75rem;
    color: --text-primary;
    text-align: right;
}
/* Add this to your home.css file */

/* Loading animation for AI response */
.ai-loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 100px;
}

.ai-loading {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ai-loading-logo {
    width: 40px;
    height: 40px;
    background-image: url('/icon/logo.png'); /* Your logo path */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
    animation: logo-pulse 2s infinite ease-in-out;
}

.ai-loading-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 1;
}

.ai-loading-circle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        transparent 0deg,
        transparent 180deg,
        #4285F4 180deg,
        #4285F4 360deg
    );
    animation: circle-rotate 1.5s linear infinite;
    mask: radial-gradient(circle, transparent 50%, #000 51%);
    -webkit-mask: radial-gradient(circle, transparent 50%, #000 51%);
}

.ai-loading-circle::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    background: var(--secondary-bg);
    border-radius: 50%;
    z-index: 1;
}

/* Light theme support */
.light-theme .ai-loading-circle::after {
    background: #f5f5f5;
}

/* Animations */
@keyframes circle-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes logo-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Fade in/out animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

.ai-loading-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.ai-loading-fade-out {
    animation: fadeOut 0.3s ease forwards;
}
/* Ensure the bubble itself doesn't expand from internal margins */
.message-bubble {
    overflow: hidden; /* This "contains" internal margins */
    display: flex;
    flex-direction: column;
}

/* Remove margins from the first and last elements inside the bubble */
.message-bubble > *:first-child {
    margin-top: 0 !important;
}

.message-bubble > *:last-child {
    margin-bottom: 0 !important;
}

/* If you are using <p> tags for paragraphs, they often have huge default margins */
.message-bubble p {
    margin: 0 0 8px 0; /* Tighten up paragraph spacing */
}
body {
    height: 100dvh; 
    width: 100vw;
    font-size: 16px;
    padding-top: 0;
    padding-bottom: 0;
}
body.cordova-android-mode {
    padding-top: env(safe-area-inset-top); 
    padding-bottom: env(safe-area-inset-bottom); 
}
.container { 
    display: flex; 
    height: 100%;
    width: 100%;
    position: relative; 
    background: var(--bg-base);
}
body.cordova-android-mode .header {
    /* Ensure header accounts for the padding if it's fixed */
    padding-top: 10px !important; 
}
/* --- KEYBOARD & SCROLL FIX (No overflow:hidden on body) --- */

html, body {
    /* 100% height ensures the app shrinks when keyboard opens */
    height: 100% !important; 
    margin: 0;
    padding: 0;
}

.container {
    /* Forces the layout to fill exactly the visible screen */
    height: 100% !important; 
    display: flex;
}

.chat-area {
    /* This allows the messages to scroll independently */
    flex: 1; 
    overflow-y: scroll !important; 
    -webkit-overflow-scrolling: touch; /* Smooth scroll */
    height: auto;
    min-height: 0; /* Critical fix for flexbox scrolling */
}

.input-area {
    /* Keeps input bar from getting crushed */
    flex-shrink: 0; 
    position: relative; 
    z-index: 10;
}
/* --- MARKDOWN FORMATTING FIXES --- */

/* 1. Reset Flexbox on bubble so block elements (lists/paragraphs) flow naturally */
.message-bubble {
    display: block !important; /* Overrides the 'flex' that was causing issues */
}

/* 2. Style Paragraphs to remove huge gaps */
.message-bubble p {
    margin: 0 0 10px 0; /* consistent bottom spacing */
    display: inline-block; /* Helps text flow better in some cases, or just use block */
    width: 100%;
}
.message-bubble p:last-child {
    margin-bottom: 0;
}

/* 3. Fix List Spacing & Indentation */
.message-bubble ul, 
.message-bubble ol {
    margin: 8px 0 8px 20px; /* Indent lists slightly */
    padding-left: 0;
}

.message-bubble li {
    margin-bottom: 6px;
    line-height: 1.6;
}

/* Ensure list content flows on the same line */
.message-bubble li p {
    display: inline; /* This forces the "Heading: Content" to stay on one line */
    margin: 0;
}

/* 4. Fix Bold/Strong text colors */
.message-bubble strong {
    color: var(--text-primary);
    font-weight: 700;
}
/* --- FIX LIST NUMBERS CUTTING OFF --- */

.message-bubble ol {
    /* 1. Add padding back so numbers have space to sit */
    padding-left: 32px !important; 
    
    /* 2. Ensure numbers stay outside the text block for clean alignment */
    list-style-position: outside;
    
    /* 3. Reset margin to avoid double spacing */
    margin-left: 0;
}

/* Optional: Tweaks for unordered lists (bullets) too */
.message-bubble ul {
    padding-left: 25px !important;
    list-style-position: outside;
}
/* =========================================
   AI REPLY FORMATTING (Tables, Links, Code)
   ========================================= */

/* --- 1. TABLES (Fixes collapsed/invisible tables) --- */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    display: block;       /* Allows scrolling on mobile */
    overflow-x: auto;
    white-space: nowrap;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
}

.message-bubble th,
.message-bubble td {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.message-bubble th {
    background: rgba(255, 255, 255, 0.1);
    font-weight: 700;
}

/* Light Mode Tables */
body.light .message-bubble table { border-color: rgba(0,0,0,0.1); }
body.light .message-bubble th, 
body.light .message-bubble td { border-color: rgba(0,0,0,0.1); color: #333; }
body.light .message-bubble th { background: rgba(0,0,0,0.05); }

/* --- 2. LINKS (Fixes dark blue color) --- */
.message-bubble a {
    color: #4facfe;       /* Bright Cyan/Blue for Dark Mode */
    text-decoration: none;
    border-bottom: 1px solid rgba(79, 172, 254, 0.5);
    word-break: break-all;
    transition: all 0.2s;
}

.message-bubble a:hover {
    color: #fff;
    border-bottom-color: #fff;
}

/* Light Mode Links */
body.light .message-bubble a { color: #0066cc; border-bottom-color: rgba(0, 102, 204, 0.3); }
body.light .message-bubble a:hover { color: #004499; }

/* --- 3. CODE BLOCKS (Fixes unstyled code) --- */
.message-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid var(--glass-border);
}

.message-bubble code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
}

/* Reset background for code inside pre blocks */
.message-bubble pre code {
    background: transparent;
    padding: 0;
    color: #e0e0e0;
}

/* Light Mode Code */
body.light .message-bubble pre { background: #f6f8fa; border-color: rgba(0,0,0,0.1); }
body.light .message-bubble pre code { color: #24292e; }
body.light .message-bubble code { background: rgba(0,0,0,0.05); color: #c7254e; }

/* --- 4. BLOCKQUOTES --- */
.message-bubble blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 10px 0;
    padding-left: 12px;
    color: var(--text-muted);
    font-style: italic;
}
/* =========================================
   FULL SCREEN INITIAL LOADER
   ========================================= */
   .fullscreen-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-base); /* Matches your theme background */
    z-index: 9999; /* on top of everything */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

/* Optional text below the spinner */
.loading-text {
    margin-top: 20px;
    font-family: 'Share Tech', monospace;
    color: var(--text-muted);
    font-size: 1rem;
    letter-spacing: 1px;
    animation: pulseText 2s infinite;
}

@keyframes pulseText {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Class to hide the loader smoothly */
.fullscreen-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Ensure Logo matches the size used in chat */
.fullscreen-loader .ai-loading {
    transform: scale(1.5); /* Make it slightly bigger for full screen */
}
@media (min-width: 769px) {
    .message-row {
        padding: 0 15% !important; /* Adds space on left/right */
    }
    
    .message-content-wrapper {
        max-width: 95% !important; /* Prevents bubbles from getting too wide */
    }
}

/* 3. Message Bubble Safety */
/* Ensures text wraps correctly and doesn't push bounds */
.message-bubble {
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}
/* =========================================
   PC VIEW ALIGNMENT FIX (FINAL)
   ========================================= */

   @media (min-width: 769px) {
    /* 1. Reset the wrapper padding so it doesn't push content off-screen */
    .message-row {
        padding: 0 !important; 
    }

    /* 2. Center the content in a readable column (Standard Chat Layout) */
    .message-container {
        width: 100%;
        max-width: 1500px;        /* Restricts width so bubbles don't stretch too far */
        margin: 0 auto;          /* Automatically centers the container */
        padding: 0 20px;         /* Adds safe spacing on both sides */
        box-sizing: border-box;  /* Prevents sizing errors */
    }
    
    /* 3. Safety Fix for Horizontal Overflow */
    body, html, .main-content {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}