/* Custom Premium CSS for ASK BORHAN */

:root {
    /* Color Palette - Mystic Sufi Dark (Default) */
    --bg-primary: #0a0c10;
    --bg-secondary: #11141d;
    --bg-sidebar: #0f121a;
    --bg-card: rgba(20, 24, 35, 0.65);
    
    --accent-primary: #5c62ec;
    --accent-primary-hover: #4a50d4;
    --accent-emerald: #10b981;
    --accent-emerald-hover: #059669;
    --accent-glow: rgba(92, 98, 236, 0.15);
    --accent-emerald-glow: rgba(16, 185, 129, 0.15);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --border-color: rgba(255, 255, 255, 0.07);
    --border-focus: rgba(92, 98, 236, 0.4);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.35);
    
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --glass-blur: 16px;
    --transition-speed: 0.3s;
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.75);
    
    --accent-primary: #4f46e5;
    --accent-primary-hover: #4338ca;
    --accent-emerald: #0f9d58;
    --accent-emerald-hover: #0b8043;
    --accent-glow: rgba(79, 70, 229, 0.08);
    --accent-emerald-glow: rgba(15, 157, 88, 0.08);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(79, 70, 229, 0.4);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* App Container Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Responsive viewport height for mobile browsers */
    position: relative;
}

/* Sidebar Styling */
.sidebar {
    width: 300px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
    transition: transform var(--transition-speed), background-color var(--transition-speed);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}


.logo-icon {
    font-size: 1.35rem;
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-sidebar-btn {
    display: none; /* Only visible on Mobile */
}

/* Sidebar Section Buttons & Cards */
.new-chat-btn {
    margin: 1.25rem 1.25rem 0.5rem 1.25rem;
    padding: 0.85rem;
    background: linear-gradient(135deg, rgba(92, 98, 236, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.2s, border-color 0.2s, background 0.2s;
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, rgba(92, 98, 236, 0.18) 0%, rgba(16, 185, 129, 0.18) 100%);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.new-chat-btn:active {
    transform: translateY(1px);
}

.sidebar-section {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Bibliothèque du Cheikh Styles */
.document-upload-card {
    background-color: var(--bg-card);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.doc-help-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.doc-help-text code {
    font-family: monospace;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-primary);
}

.server-doc-status {
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
}

.server-doc-status::-webkit-scrollbar {
    width: 4px;
}
.server-doc-status::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.status-indicator-mini {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.02);
}

.status-indicator-mini.loading i {
    color: var(--accent-primary);
}

.server-files-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0;
}

.server-file-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem;
    transition: background-color 0.2s, border-color 0.2s;
    animation: fadeIn 0.3s ease-out;
}

.server-file-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: rgba(92, 98, 236, 0.3);
}

.server-file-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.server-file-icon.docx {
    color: #2b579a; /* Word color */
}

.server-file-icon.txt, .server-file-icon.md {
    color: var(--accent-primary);
}

.server-file-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.server-file-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-file-size {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.server-file-badge {
    font-size: 0.6rem;
    background-color: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--accent-emerald);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    font-weight: bold;
    flex-shrink: 0;
}

/* History Section List */
.history-section {
    flex-grow: 1;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
}

/* Custom Scrollbar for Sidebar */
.history-section::-webkit-scrollbar {
    width: 4px;
}
.history-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.85rem;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    border: 1px solid transparent;
}

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

.history-item.active {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
}

.history-item-title-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-grow: 1;
    overflow: hidden;
}

.history-item-icon {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-item.active .history-item-icon {
    color: var(--accent-primary);
}

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

.history-item-actions {
    display: none;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.history-item:hover .history-item-actions,
.history-item.active .history-item-actions {
    display: flex;
}

.history-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.2rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: color 0.2s, background-color 0.2s;
}

.history-action-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.08);
}

/* Sidebar Footer & Key status */
.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background-color: rgba(0, 0, 0, 0.05);
}

.key-status-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.success { color: var(--accent-emerald); }
.status-indicator.success .indicator-dot {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

.status-indicator.warning { color: #f59e0b; }
.status-indicator.warning .indicator-dot {
    background-color: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

.config-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s, transform 0.2s;
}

.config-btn:hover {
    color: var(--accent-primary);
    transform: rotate(45deg);
}

.guide-trigger-box {
    text-align: center;
    background-color: rgba(92, 98, 236, 0.06);
    border: 1px dashed rgba(92, 98, 236, 0.2);
    border-radius: 10px;
    padding: 0.75rem;
}

.guide-trigger-box p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.guide-link-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s, text-shadow 0.2s;
}

.guide-link-btn:hover {
    color: #7b80f9;
    text-shadow: 0 0 4px rgba(123, 128, 249, 0.3);
}

.google-session-info {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.google-icon {
    color: #4285f4;
    font-size: 0.8rem;
    margin-top: 0.1rem;
}

/* Chat Main Area */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-secondary);
    transition: background-color var(--transition-speed);
}

.topbar {
    height: 64px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 90;
    background-color: rgba(16, 20, 29, 0.4);
    backdrop-filter: blur(8px);
}

.menu-btn {
    display: none; /* Mobile only */
}

.chat-info {
    display: flex;
    flex-direction: column;
}

.chat-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.chat-subtitle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.2rem;
}

.model-badge {
    font-size: 0.65rem;
    background-color: rgba(92, 98, 236, 0.12);
    border: 1px solid rgba(92, 98, 236, 0.25);
    color: var(--text-primary);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 500;
}

.doc-badge {
    font-size: 0.65rem;
    background-color: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--accent-emerald);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lang-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0 0.5rem;
    height: 36px;
    gap: 0.35rem;
    transition: border-color 0.2s, background-color 0.2s;
}
.lang-select-wrapper:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}
.lang-select-wrapper .lang-icon {
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
}
.lang-select-wrapper .lang-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    padding-right: 0.25rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}
.lang-select-wrapper .lang-select option {
    background-color: #1e1e2e;
    color: #f8f8f2;
}

/* For dark/light theme compatibility */
body.light-theme .lang-select-wrapper {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}
body.light-theme .lang-select-wrapper:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}
body.light-theme .lang-select-wrapper .lang-select {
    color: var(--text-primary);
}
body.light-theme .lang-select-wrapper .lang-select option {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Icon Buttons standard styling */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation; /* Removes tap delay on mobile */
    transition: color 0.2s, background-color 0.2s, transform 0.2s;
}

/* Prevent icons from blocking click events on buttons */
.icon-btn i, .send-btn i, .voice-control-btn i, .new-chat-btn i, .speak-msg-btn i {
    pointer-events: none;
}

.icon-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Messages container & items */
.messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Scrollbar for chat messages */
.messages-container::-webkit-scrollbar {
    width: 6px;
}
.messages-container::-webkit-scrollbar-track {
    background: transparent;
}
.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

/* Welcome Screen style */
.welcome-screen {
    max-width: 580px;
    margin: auto;
    text-align: center;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    background-color: var(--bg-card);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.welcome-avatar {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    box-shadow: 0 8px 20px rgba(92, 98, 236, 0.25);
    margin-bottom: 0.5rem;
}


.welcome-screen h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 600;
}

.welcome-quote {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.5;
    position: relative;
    padding: 0 1.5rem;
}

.welcome-quote::before, .welcome-quote::after {
    content: '"';
    font-family: var(--font-heading);
    font-size: 2rem;
    position: absolute;
    color: rgba(92, 98, 236, 0.25);
    line-height: 1;
}

.welcome-quote::before { left: 0; top: -0.25rem; }
.welcome-quote::after { right: 0; bottom: -0.5rem; }

.welcome-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.welcome-actions {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    margin-top: 1rem;
}

.welcome-action-btn {
    flex: 1;
    padding: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.welcome-action-btn:hover {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
}

.welcome-action-btn.secondary:hover {
    background-color: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: white;
}

/* Chat Messages Bubbles */
.message-row {
    display: flex;
    width: 100%;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message-card {
    display: flex;
    gap: 1rem;
    max-width: 78%;
}

.message-row.user .message-card {
    flex-direction: row-reverse;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
}


.message-row.assistant .avatar {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    color: white;
}

.message-row.user .avatar {
    background-color: #3b82f6;
    color: white;
}

.bubble {
    padding: 0.85rem 1.15rem;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.6;
    word-break: break-word;
    box-shadow: var(--shadow-sm);
}

.message-row.assistant .bubble {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.message-row.user .bubble {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #3b82f6 100%);
    color: white;
    border-top-right-radius: 4px;
}

/* Format parsed content inside bubble */
.bubble p {
    margin-bottom: 0.75rem;
}
.bubble p:last-child {
    margin-bottom: 0;
}

.bubble pre {
    background-color: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 0.75rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.bubble code {
    font-family: Consolas, Monaco, monospace;
    font-size: 0.85rem;
    padding: 0.1rem 0.25rem;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.bubble pre code {
    padding: 0;
    background-color: transparent;
    font-size: 0.8rem;
}

.bubble ul, .bubble ol {
    margin-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.bubble blockquote {
    border-left: 3px solid var(--accent-emerald);
    padding-left: 0.75rem;
    margin: 0.75rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 44%, 100% { transform: translateY(0); }
    22% { transform: translateY(-6px); }
}

/* Chat Input Footer Area */
.chat-input-area {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: rgba(16, 20, 29, 0.3);
    backdrop-filter: blur(8px);
}

.chat-input-container {
    max-width: 760px;
    margin: auto;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.chat-input-container:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 16px var(--accent-glow);
}

/* Context indicator inside textarea */
.input-doc-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(16, 185, 129, 0.08);
    border-bottom: 1px solid rgba(16, 185, 129, 0.15);
    padding: 0.45rem 0.85rem;
    font-size: 0.72rem;
    color: var(--accent-emerald);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    padding: 0.75rem 1rem;
}

.chat-input-container textarea {
    flex-grow: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 16px; /* 16px minimum prevents iOS Safari auto-zoom which causes offsets */
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    outline: none;
    padding: 0.1rem 0;
}

.chat-input-container textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background-color: var(--accent-primary);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s, transform 0.2s;
    margin-left: 0.5rem;
}

.send-btn:hover {
    background-color: var(--accent-primary-hover);
}

.send-btn:disabled {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

.input-footer {
    max-width: 760px;
    margin: 0.5rem auto 0 auto;
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Modals Overlay Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    width: 90%;
    max-width: 480px;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-secondary);
}

.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-modal-btn {
    font-size: 1.5rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    line-height: 1;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-with-icon input {
    width: 100%;
    padding: 0.75rem 12px 0.75rem 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
    font-size: 16px; /* 16px minimum prevents iOS Safari auto-zoom */
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-icon input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 10px var(--accent-glow);
}

.toggle-password-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem;
}

.toggle-password-btn:hover {
    color: var(--text-primary);
}

/* Modal Actions Buttons */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: rgba(0, 0, 0, 0.05);
}

.btn {
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
    border: 1px solid transparent;
}

.btn.primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn.primary:hover {
    background-color: var(--accent-primary-hover);
}

.btn.primary-accent {
    background-color: var(--accent-emerald);
    color: white;
}

.btn.primary-accent:hover {
    background-color: var(--accent-emerald-hover);
}

.btn.secondary {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn:active {
    transform: scale(0.98);
}

/* Google Account Helper Assist Box */
.google-auth-assist-card {
    background-color: rgba(66, 133, 244, 0.06);
    border: 1px solid rgba(66, 133, 244, 0.15);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1.25rem;
}

.assist-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: #4285f4;
    margin-bottom: 0.4rem;
}

.google-auth-assist-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.assist-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #4285f4;
    text-decoration: none;
    transition: color 0.2s;
}

.assist-link:hover {
    color: #669df6;
    text-decoration: underline;
}

/* ========================================================
   Interactive Guide Modal styling & Mockup drawings
   ======================================================== */

.guide-card {
    max-width: 620px;
}

.text-center {
    text-align: center;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-column {
    flex-direction: column;
}

.guide-carousel {
    position: relative;
    min-height: 340px;
    overflow: hidden;
}

.guide-slide {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: fadeSlideIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.guide-slide.active {
    display: flex;
}

.slide-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
}

.slide-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.55;
    max-width: 480px;
    margin-bottom: 1rem;
}

.slide-actions {
    margin-top: 0.5rem;
}

.slide-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* High Fidelity Browser UI Mockup in Pure CSS */
.slide-illustration {
    width: 100%;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.browser-mockup {
    width: 320px;
    height: 160px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.browser-header {
    height: 28px;
    background-color: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    gap: 4px;
    position: relative;
}

.browser-header .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    display: inline-block;
}

.browser-address {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.2);
    font-size: 0.6rem;
    padding: 0.15rem 2rem;
    border-radius: 4px;
    color: var(--text-muted);
    white-space: nowrap;
    border: 1px solid var(--border-color);
}

.browser-body {
    flex-grow: 1;
    padding: 0.75rem;
    background-color: rgba(0,0,0,0.05);
}

/* Simulated Elements inside Browser Mockup */
.auth-card-illustration {
    width: 140px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    box-shadow: var(--shadow-sm);
}

.google-large-icon {
    font-size: 1.5rem;
    color: #4285f4;
}

.auth-card-illustration .line {
    height: 4px;
    border-radius: 2px;
    background-color: var(--border-color);
}

.auth-card-illustration .line.long { width: 80px; }
.auth-card-illustration .line.medium { width: 50px; }

.btn-mockup {
    margin-top: 0.25rem;
    font-size: 0.5rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    background-color: #4285f4;
    color: white;
    border-radius: 4px;
    text-align: center;
}

.logo-studio-mockup {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.85rem;
}

.logo-spin {
    font-size: 0.8rem;
    color: var(--accent-primary);
    animation: spin 3s linear infinite;
}

.key-button-mockup {
    padding: 0.45rem 0.85rem;
    background-color: var(--accent-primary);
    color: white;
    font-weight: bold;
    font-size: 0.65rem;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(92, 98, 236, 0.3);
}

.key-creation-dialog {
    width: 200px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem;
    box-shadow: var(--shadow-md);
}

.key-creation-dialog h5 {
    font-size: 0.65rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.input-mock {
    font-size: 0.55rem;
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    color: var(--text-muted);
}

.btn-group-mock {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.btn-mock {
    font-size: 0.5rem;
    font-weight: bold;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-mock.active {
    background-color: var(--accent-emerald);
    color: white;
    border-color: var(--accent-emerald);
}

.key-display-mock {
    display: flex;
    align-items: center;
    border: 1px solid rgba(16, 185, 129, 0.3);
    background-color: rgba(16, 185, 129, 0.06);
    border-radius: 6px;
    padding: 0.4rem 0.65rem;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.key-box {
    font-family: monospace;
    font-size: 0.6rem;
    color: var(--accent-emerald);
}

.copy-btn-mock {
    font-size: 0.55rem;
    background-color: var(--accent-emerald);
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.success-banner {
    font-size: 0.6rem;
    color: var(--accent-emerald);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.key-paste-illustration {
    position: relative;
    width: 180px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key-floating {
    position: absolute;
    font-size: 2rem;
    color: var(--accent-primary);
    top: 10px;
    text-shadow: 0 4px 12px rgba(92, 98, 236, 0.4);
}

.input-glow-mock {
    border: 1px solid var(--accent-primary);
    background-color: rgba(92, 98, 236, 0.05);
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 3rem;
    box-shadow: 0 0 15px rgba(92, 98, 236, 0.2);
}

/* Carousel controls and dots styling */
.carousel-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.carousel-control {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: color 0.2s, background-color 0.2s;
}

.carousel-control:hover:not(:disabled) {
    color: var(--accent-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.carousel-control:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.carousel-dots {
    display: flex;
    gap: 0.5rem;
}

.carousel-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-color);
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
}

.carousel-dots .dot.active {
    background-color: var(--accent-primary);
    transform: scale(1.3);
}

/* Animations CSS */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

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

@keyframes flash {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-8px) rotate(5deg); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px rgba(92, 98, 236, 0.15); }
    50% { box-shadow: 0 0 20px rgba(92, 98, 236, 0.35); }
}

.animate-pulse { animation: pulse 2s infinite ease-in-out; }
.animate-bounce { animation: bounce 2s infinite ease-in-out; }
.animate-flash { animation: flash 1.5s infinite; }
.animate-float { animation: float 4s infinite ease-in-out; }
.animate-glow { animation: glow 2s infinite ease-in-out; }

.animate-zoom {
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================================
   Responsive Styling for Mobile
   ======================================================== */

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .close-sidebar-btn {
        display: flex;
    }
    
    .menu-btn {
        display: flex;
    }
    
    .message-card {
        max-width: 90%;
    }
    
    .welcome-screen {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .welcome-actions {
        flex-direction: column;
    }
    
    .modal-card {
        width: 95%;
        margin: 10px;
        max-height: 82dvh;
    }
    
    .chat-input-area {
        padding: 0.75rem 1rem; /* Adjust padding for mobile screens */
    }
    
    .topbar {
        padding: 0 1rem;
    }

    .topbar-actions {
        display: flex;
        gap: 0.5rem;
    }
    
    .lang-select-wrapper {
        display: none !important;
    }

    .mobile-settings-btn {
        display: flex !important;
        color: var(--text-secondary);
        font-size: 1.2rem;
    }

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

    .chat-info {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
    }

    .chat-title {
        display: none !important;
    }
    
    .chat-subtitle {
        display: none !important;
    }
    
    .mobile-topbar-logo {
        display: block !important;
        width: 38px !important;
        height: 38px !important;
        border-radius: 50%;
        object-fit: cover;
        border: 1.5px solid var(--accent-emerald);
        margin: 0 auto;
    }
}

/* ========================================================
   Magical Splash & Loading Screen Overlay
   ======================================================== */

.magic-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #05070a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.6s;
    overflow: hidden;
}

.magic-loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.magic-loader-overlay.translucent {
    background-color: rgba(5, 7, 10, 0.85);
    backdrop-filter: blur(10px);
}

.magic-loader-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.25rem;
    text-align: center;
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.magic-rings-container {
    position: relative;
    width: 300px;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-img-container {
    width: 260px;
    height: 260px; /* Perfect circle */
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 3px solid rgba(212, 175, 55, 0.45);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 
                0 0 30px rgba(16, 185, 129, 0.15),
                inset 0 0 30px rgba(212, 175, 55, 0.2);
    z-index: 10;
    background-color: var(--bg-secondary);
    transition: transform 0.5s ease;
}

.magic-loader-overlay:not(.hidden) .loader-img-container {
    animation: pulseGlow 3s infinite ease-in-out;
}

.loader-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Magic Circles / Portal Rings */
.magic-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
}

.ring-outer {
    width: 380px;
    height: 380px;
    border: 2px dashed rgba(212, 175, 55, 0.18);
    animation: rotateClockwise 25s linear infinite;
    z-index: 1;
}

.ring-middle {
    width: 330px;
    height: 330px;
    border-top: 3px solid var(--accent-emerald);
    border-bottom: 3px solid rgba(16, 185, 129, 0.15);
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    animation: rotateCounterClockwise 5s cubic-bezier(0.44, 0.05, 0.55, 0.95) infinite;
    z-index: 2;
    filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.7));
}

.ring-inner {
    width: 290px;
    height: 290px;
    border-right: 3px solid rgba(212, 175, 55, 0.85);
    border-left: 3px solid rgba(212, 175, 55, 0.15);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    animation: rotateClockwise 3.5s cubic-bezier(0.44, 0.05, 0.55, 0.95) infinite;
    z-index: 3;
    filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.9));
}

/* Loading status text & title styling */
.magic-loader-text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 20;
}

.magic-loader-title {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: 6px;
    background: linear-gradient(135deg, #ffd700 0%, #10b981 60%, #5c62ec 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    margin-bottom: 0.25rem;
}

.magic-loader-status {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.magic-loader-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    font-weight: 500;
    text-transform: uppercase;
}

.magic-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.magic-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    display: inline-block;
    animation: magicDotPulse 1.5s infinite ease-in-out both;
}

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

/* Rotations and Pulses animations */
@keyframes rotateClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

@keyframes magicDotPulse {
    0%, 80%, 100% {
        transform: scale(0.2);
        opacity: 0.3;
    }
    40% {
        transform: scale(1);
        opacity: 1;
        background-color: #ffd700;
        box-shadow: 0 0 10px #ffd700, 0 0 20px var(--accent-emerald);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 
                    0 0 30px rgba(16, 185, 129, 0.15),
                    inset 0 0 30px rgba(212, 175, 55, 0.1);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6), 
                    0 0 45px rgba(16, 185, 129, 0.35),
                    0 0 25px rgba(212, 175, 55, 0.25),
                    inset 0 0 40px rgba(212, 175, 55, 0.3);
        transform: scale(1.02);
    }
}

/* Responsiveness Scale for smaller viewports */
@media (max-width: 480px) {
    .magic-loader-card {
        transform: scale(0.72);
    }
}

/* ========================================================
   Voice Input & Output Interface Styles (V6)
   ======================================================== */

.voice-input-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
    margin-left: 0.25rem;
}

.voice-input-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.voice-input-btn:active {
    transform: scale(0.92);
}

.voice-input-btn.listening {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    animation: voicePulse 1.4s infinite ease-in-out;
}

@keyframes voicePulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Audio Player Button on messages */
.speak-msg-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    font-size: 0.82rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
    margin-left: 0.45rem;
    margin-top: 0.25rem;
    border: 1px solid transparent;
}

.message-card:hover .speak-msg-btn {
    color: var(--text-secondary);
}

.speak-msg-btn:hover {
    color: var(--accent-primary) !important;
    background-color: rgba(255, 255, 255, 0.05);
}

.speak-msg-btn.speaking {
    color: var(--accent-emerald) !important;
    background-color: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
    animation: voicePulse 1.8s infinite ease-in-out;
}

/* Voice Config Card in Settings */
.voice-settings-card {
    background-color: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.voice-settings-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.form-group-row {
    display: flex;
    align-items: center;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}

.toggle-container input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-emerald);
    cursor: pointer;
}

.form-group-voice {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.voice-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.voice-options {
    display: flex;
    gap: 0.75rem;
}

.voice-option {
    cursor: pointer;
}

.voice-option input {
    display: none;
}

.voice-btn-label {
    padding: 0.45rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    background-color: rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.voice-option:hover .voice-btn-label {
    background-color: rgba(255, 255, 255, 0.02);
    border-color: var(--text-muted);
}

.voice-option input:checked + .voice-btn-label {
    border-color: var(--accent-emerald);
    background-color: rgba(16, 185, 129, 0.08);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

/* ========================================================
   Google Identity Services (Sign-in with Google) Auth Gate
   ======================================================== */
.auth-gate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 10, 18, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-gate-card {
    max-width: 440px;
    width: 100%;
    padding: 3rem 2.5rem;
    text-align: center;
    border-radius: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg), 
                0 20px 50px rgba(0, 0, 0, 0.5), 
                inset 0 0 20px rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
}

.auth-gate-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.auth-logo-img {
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.25);
}

.auth-gate-logo h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.auth-gate-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.google-signin-wrapper {
    margin: 0.5rem 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Mock Google Button styling for local fallback */
.mock-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 320px;
    padding: 0.85rem 1.5rem;
    background-color: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 100px;
    color: #3c4043;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.mock-google-btn:hover {
    background-color: #f8f9fa;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.mock-google-btn:active {
    background-color: #f1f3f4;
    transform: translateY(0);
}

.mock-google-btn .google-icon {
    font-size: 1.15rem;
    color: #4285f4; /* Google Blue */
}

.auth-gate-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

/* User Profile & Logout button in Sidebar Footer */
.user-profile-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 0.75rem;
    width: 100%;
    gap: 0.5rem;
}

.user-profile-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    overflow: hidden;
    flex-grow: 1;
}

.user-profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--accent-emerald);
    flex-shrink: 0;
}

.user-profile-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-align: left;
}

.user-profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.logout-btn:hover {
    color: #ef4444; /* Soft Red */
    background-color: rgba(239, 68, 68, 0.08);
}

/* RTL Mode Styles */
html[dir="rtl"] .history-item-actions {
    margin-left: 0;
    margin-right: 0.5rem;
}
html[dir="rtl"] .bubble ul, html[dir="rtl"] .bubble ol {
    margin-left: 0;
    margin-right: 1.25rem;
}
html[dir="rtl"] .bubble blockquote {
    border-left: none;
    border-right: 3px solid var(--accent-emerald);
    padding-left: 0;
    padding-right: 0.75rem;
}
html[dir="rtl"] .send-btn {
    margin-left: 0;
    margin-right: 0.5rem;
}
html[dir="rtl"] .voice-input-btn {
    margin-left: 0;
    margin-right: 0.25rem;
}
html[dir="rtl"] .speak-msg-btn {
    margin-left: 0;
    margin-right: 0.45rem;
}
html[dir="rtl"] .user-profile-details {
    text-align: right;
}

/* First Login Language Selection Modal */
.lang-selection-card {
    max-width: 420px;
    padding: 1.5rem;
}
.lang-options-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}
.lang-opt-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.25s, border-color 0.25s, transform 0.2s;
}
.lang-opt-btn:hover {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
}
.lang-flag {
    font-size: 1.25rem;
}
.lang-name {
    flex-grow: 1;
    text-align: left;
}
html[dir="rtl"] .lang-name {
    text-align: right;
}

/* ========================================================
   ChatGPT-like Voice Mode Overlay
   ======================================================== */
.voice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(9, 11, 16, 0.88);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.voice-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    background: rgba(20, 24, 35, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    box-shadow: var(--shadow-lg), 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

@media (max-width: 640px) {
    .voice-container {
        max-height: 100%;
        height: 100%;
        width: 100%;
        border-radius: 0;
        border: none;
        padding: 1.5rem;
    }
}

.voice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.voice-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.voice-close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.voice-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
    transform: scale(1.05);
}

.voice-sphere-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.voice-sphere-wrapper {
    position: relative;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.voice-sphere {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.4), inset 0 -4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.voice-sphere:hover {
    transform: scale(1.05);
}

.voice-mic-icon {
    font-size: 2.2rem;
    color: white;
    transition: all 0.3s ease;
}

.voice-ring {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--accent-emerald);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    transition: all 0.5s ease;
}

.voice-status {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 0.2px;
    min-height: 1.5rem;
}

.voice-transcript-section {
    width: 100%;
    margin-bottom: 2rem;
}

.voice-transcript-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 1.25rem;
    height: 120px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
}

.transcript-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.transcript-content {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.transcript-content::-webkit-scrollbar {
    width: 4px;
}
.transcript-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.transcript-placeholder {
    font-style: italic;
    color: var(--text-muted);
}

.voice-error-box {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    width: 100%;
}

.voice-error-title {
    font-weight: 600;
    color: #ef4444;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.voice-error-msg {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.app-store-btn {
    display: inline-block;
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 0.5rem;
    transition: transform 0.2s;
}

.app-store-btn:hover {
    transform: scale(1.05);
}

.voice-controls-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.voice-control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.voice-control-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.voice-control-btn.mute:hover {
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.voice-control-btn.mute.muted-active {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.15);
}

.voice-control-btn.stop {
    color: #f59e0b;
}

.voice-control-btn.stop:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.voice-control-btn.exit {
    color: #ef4444;
}

.voice-control-btn.exit:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ========================================================
   Sphere Animation States
   ======================================================== */

/* 1. LISTENING STATE */
.voice-overlay.state-listening .voice-sphere {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    animation: voiceListenPulse 2s infinite ease-in-out;
}

.voice-overlay.state-listening .voice-ring {
    border-color: rgba(16, 185, 129, 0.4);
    animation: voiceRingRipple 3s infinite cubic-bezier(0.1, 0.8, 0.3, 1);
}

.voice-overlay.state-listening .ring-2 {
    animation-delay: 1s;
}

.voice-overlay.state-listening .ring-3 {
    animation-delay: 2s;
}

@keyframes voiceListenPulse {
    0% { transform: scale(1); box-shadow: 0 0 30px rgba(16, 185, 129, 0.4); }
    50% { transform: scale(1.06); box-shadow: 0 0 50px rgba(92, 98, 236, 0.6); }
    100% { transform: scale(1); box-shadow: 0 0 30px rgba(16, 185, 129, 0.4); }
}

@keyframes voiceRingRipple {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* 2. THINKING STATE */
.voice-overlay.state-thinking .voice-sphere {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #a855f7 100%);
    animation: voiceMorphThinking 2.5s infinite linear;
    box-shadow: 0 0 35px rgba(92, 98, 236, 0.5);
}

.voice-overlay.state-thinking .voice-ring {
    border-color: rgba(92, 98, 236, 0.3);
    animation: voiceThinkingRing 2s infinite linear;
}

.voice-overlay.state-thinking .ring-2 {
    animation-delay: 0.67s;
}

.voice-overlay.state-thinking .ring-3 {
    animation-delay: 1.33s;
}

@keyframes voiceMorphThinking {
    0% { border-radius: 50% 50% 50% 50%; transform: rotate(0deg) scale(1); }
    25% { border-radius: 40% 60% 45% 55%; }
    50% { border-radius: 50% 40% 60% 40%; transform: rotate(180deg) scale(0.95); }
    75% { border-radius: 60% 45% 50% 55%; }
    100% { border-radius: 50% 50% 50% 50%; transform: rotate(360deg) scale(1); }
}

@keyframes voiceThinkingRing {
    0% { transform: scale(1) rotate(0deg); opacity: 0.4; border-radius: 45% 55% 50% 50%; }
    50% { transform: scale(1.3) rotate(180deg); opacity: 0.2; border-radius: 55% 45% 50% 50%; }
    100% { transform: scale(1) rotate(360deg); opacity: 0.4; border-radius: 45% 55% 50% 50%; }
}

/* 3. SPEAKING STATE */
.voice-overlay.state-speaking .voice-sphere {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-primary) 100%);
    animation: voiceSpeakVibrate 0.15s infinite alternate ease-in-out;
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.5);
}

.voice-overlay.state-speaking .voice-ring {
    border-color: rgba(16, 185, 129, 0.35);
    animation: voiceSpeakRingRipple 1.5s infinite cubic-bezier(0.2, 0.6, 0.4, 1);
}

.voice-overlay.state-speaking .ring-2 {
    animation-delay: 0.5s;
}

.voice-overlay.state-speaking .ring-3 {
    animation-delay: 1s;
}

@keyframes voiceSpeakVibrate {
    0% { transform: scale(1.02) translateY(-1px) rotate(-1deg); }
    100% { transform: scale(0.98) translateY(1px) rotate(1deg); }
}

@keyframes voiceSpeakRingRipple {
    0% {
        transform: scale(0.95);
        opacity: 0.9;
        border-width: 3px;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
        border-width: 1px;
    }
}

/* 4. MUTED STATE */
.voice-overlay.state-muted .voice-sphere {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
}

.voice-overlay.state-muted .voice-ring {
    border-color: rgba(156, 163, 175, 0.2);
    transform: scale(1);
    opacity: 0.3;
}

.voice-overlay.state-muted .voice-mic-icon {
    color: #9ca3af;
}

/* 5. IDLE STATE */
.voice-overlay.state-idle .voice-sphere {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

.voice-overlay.state-idle .voice-ring {
    opacity: 0.1;
    transform: scale(1);
}

/* Custom Guide Screenshots */
.guide-screenshot-img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    object-fit: contain;
}



