/* ==============================================================================
   Birby - AI Companion Modern Chat Interface Styles
   ============================================================================== */

:root {
    /* Colors */
    --primary-color: #667eea;
    --primary-hover: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --text-light: #a0aec0;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: var(--spacing-lg) var(--spacing-xl);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    font-size: 2rem;
    animation: float 3s ease-in-out infinite;
}

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: var(--radius-full);
    animation: pulse 2s ease-in-out infinite;
}

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

.status-text {
    font-weight: 500;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

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

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
    background: var(--bg-secondary);
    position: relative;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    max-width: 800px;
    margin: 0 auto;
}

/* Message Styles */
.message {
    display: flex;
    gap: var(--spacing-md);
    animation: slideIn 0.3s ease;
}

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

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

.message-avatar {
    flex-shrink: 0;
}

.avatar-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
}

.user-message .avatar-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message-bubble {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    word-wrap: break-word;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-bubble p {
    margin: 0;
    line-height: 1.5;
}

.message-bubble p + p {
    margin-top: var(--spacing-sm);
}

.welcome-message .message-bubble {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 2px solid rgba(102, 126, 234, 0.2);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    margin-top: var(--spacing-lg);
}

.typing-dots {
    display: flex;
    gap: var(--spacing-xs);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: var(--radius-full);
    animation: typingDot 1.4s ease-in-out infinite;
}

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

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Input Area */
.chat-input-container {
    padding: var(--spacing-lg) var(--spacing-xl);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.input-wrapper {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-end;
    max-width: 800px;
    margin: 0 auto;
}

#messageInput {
    flex: 1;
    padding: var(--spacing-md) var(--spacing-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    transition: all var(--transition-fast);
    background: var(--bg-secondary);
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#messageInput::placeholder {
    color: var(--text-light);
}

.btn-send {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

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

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-hints {
    margin-top: var(--spacing-sm);
    text-align: center;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 1000;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Scrollbar */
.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .status-indicator {
        display: none;
    }
    
    .chat-container {
        padding: var(--spacing-lg);
    }
    
    .message-content {
        max-width: 80%;
    }
    
    .chat-input-container {
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    .input-hints {
        display: none;
    }
}

@media (max-width: 480px) {
    .logo-icon {
        font-size: 1.5rem;
    }
    
    .logo h1 {
        font-size: 1.125rem;
    }
    
    .chat-container {
        padding: var(--spacing-md);
    }
    
    .message-content {
        max-width: 85%;
    }
}

/* Animations for new messages */
@keyframes messageAppear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.message {
    animation: messageAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==============================================================================
   Markdown Rendering Styles
   ============================================================================== */

.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
    margin: 0.75em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.message-bubble h1 { font-size: 1.5em; }
.message-bubble h2 { font-size: 1.3em; }
.message-bubble h3 { font-size: 1.15em; }
.message-bubble h4 { font-size: 1.05em; }

.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child,
.message-bubble h4:first-child {
    margin-top: 0;
}

.message-bubble p {
    margin: 0.75em 0;
    line-height: 1.6;
}

.message-bubble p:first-child {
    margin-top: 0;
}

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

.message-bubble strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-bubble em {
    font-style: italic;
}

.message-bubble code {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.15em 0.4em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #e53e3e;
}

.message-bubble pre {
    background: #2d3748;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    overflow-x: auto;
    margin: 0.75em 0;
}

.message-bubble pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: #f7fafc;
    font-size: 0.875em;
    line-height: 1.5;
}

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

.message-bubble li {
    margin: 0.35em 0;
    line-height: 1.6;
}

.message-bubble ul {
    list-style-type: disc;
}

.message-bubble ol {
    list-style-type: decimal;
}

.message-bubble blockquote {
    border-left: 4px solid var(--primary-color);
    margin: 0.75em 0;
    padding: 0.5em 0 0.5em 1em;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

.message-bubble blockquote p {
    margin: 0.35em 0;
}

.message-bubble a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

.message-bubble a:hover {
    border-bottom-color: var(--primary-color);
}

.message-bubble hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1em 0;
}

.message-bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
    font-size: 0.9em;
}

.message-bubble table th,
.message-bubble table td {
    border: 1px solid var(--border-color);
    padding: 0.5em;
    text-align: left;
}

.message-bubble table th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-bubble table tr:nth-child(even) {
    background: var(--bg-secondary);
}

/* Adjust for user messages (keep simple) */
.user-message .message-bubble code,
.user-message .message-bubble pre {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.user-message .message-bubble pre code {
    color: #ffffff;
}

/* ============================================================================
   Markdown Rendering Styles
   ============================================================================ */

/* 标题样式 */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
    margin: 0.8em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-bubble h1 { font-size: 1.8em; }
.message-bubble h2 { font-size: 1.5em; }
.message-bubble h3 { font-size: 1.3em; }
.message-bubble h4 { font-size: 1.1em; }
.message-bubble h5 { font-size: 1em; }
.message-bubble h6 { font-size: 0.9em; }

/* 第一个元素不需要顶部 margin */
.message-bubble > p:first-child,
.message-bubble > h1:first-child,
.message-bubble > h2:first-child,
.message-bubble > h3:first-child {
    margin-top: 0;
}

/* 最后一个元素不需要底部 margin */
.message-bubble > p:last-child,
.message-bubble > ul:last-child,
.message-bubble > ol:last-child,
.message-bubble > pre:last-child {
    margin-bottom: 0;
}

/* 段落样式 */
.message-bubble p {
    margin: 0.5em 0;
    line-height: 1.6;
}

/* 强调和斜体 */
.message-bubble strong {
    font-weight: 600;
}

.message-bubble em {
    font-style: italic;
}

/* 行内代码 */
.message-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* 代码块 */
.message-bubble pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.8em 0;
    border-left: 3px solid rgba(124, 77, 255, 0.3);
}

.message-bubble pre code {
    background: none;
    padding: 0;
    font-size: 0.9em;
    line-height: 1.5;
}

/* 列表样式 */
.message-bubble ul,
.message-bubble ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-bubble li {
    margin: 0.3em 0;
    line-height: 1.6;
}

.message-bubble ul {
    list-style-type: disc;
}

.message-bubble ol {
    list-style-type: decimal;
}

/* 嵌套列表 */
.message-bubble ul ul,
.message-bubble ol ol,
.message-bubble ul ol,
.message-bubble ol ul {
    margin: 0.2em 0;
}

/* 引用样式 */
.message-bubble blockquote {
    border-left: 4px solid rgba(124, 77, 255, 0.3);
    margin: 0.8em 0;
    padding: 0.5em 0 0.5em 1em;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 0 4px 4px 0;
}

.message-bubble blockquote p {
    margin: 0.3em 0;
}

/* 链接样式 */
.message-bubble a {
    color: #7c4dff;
    text-decoration: none;
    border-bottom: 1px solid rgba(124, 77, 255, 0.3);
    transition: all 0.2s ease;
}

.message-bubble a:hover {
    color: #6639d4;
    border-bottom-color: #6639d4;
}

/* 分隔线 */
.message-bubble hr {
    border: none;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    margin: 1em 0;
}

/* 表格样式 */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8em 0;
    font-size: 0.95em;
}

.message-bubble table th,
.message-bubble table td {
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.5em 0.8em;
    text-align: left;
}

.message-bubble table th {
    background: rgba(124, 77, 255, 0.1);
    font-weight: 600;
}

.message-bubble table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

/* 用户消息中的 Markdown 样式调整（保持纯文本风格） */
.user-message .message-bubble code {
    background: rgba(255, 255, 255, 0.2);
}

.user-message .message-bubble pre {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.3);
}

.user-message .message-bubble blockquote {
    border-left-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.user-message .message-bubble a {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.user-message .message-bubble a:hover {
    border-bottom-color: #ffffff;
}

.user-message .message-bubble table th {
    background: rgba(255, 255, 255, 0.2);
}

.user-message .message-bubble table th,
.user-message .message-bubble table td {
    border-color: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   Thinking Process Styles
   ============================================================================ */

/* Thinking indicator (during streaming) */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.6em 1em;
    background: rgba(124, 77, 255, 0.1);
    border: 1px solid rgba(124, 77, 255, 0.2);
    border-radius: 8px;
    margin-bottom: 0.8em;
    font-size: 0.9em;
    color: #666;
}

.thinking-indicator .thinking-icon {
    font-size: 1.2em;
    animation: thinkingPulse 1.5s ease-in-out infinite;
}

@keyframes thinkingPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.thinking-indicator .thinking-text {
    font-style: italic;
}

/* Collapsible thinking process */
.thinking-process {
    margin-bottom: 0.8em;
    border: 1px solid rgba(124, 77, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(124, 77, 255, 0.05);
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.6em 1em;
    background: rgba(124, 77, 255, 0.1);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.thinking-header:hover {
    background: rgba(124, 77, 255, 0.15);
}

.thinking-header .thinking-icon {
    font-size: 1.1em;
}

.thinking-header .thinking-label {
    flex: 1;
    font-weight: 500;
    font-size: 0.9em;
    color: #7c4dff;
}

.thinking-header .toggle-icon {
    font-size: 0.8em;
    color: #7c4dff;
    transition: transform 0.2s ease;
}

.thinking-process:not(.collapsed) .toggle-icon {
    transform: rotate(180deg);
}

.thinking-body {
    padding: 1em;
    background: rgba(0, 0, 0, 0.02);
    font-size: 0.9em;
    line-height: 1.6;
    color: #555;
    white-space: pre-wrap;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    border-top: 1px solid rgba(124, 77, 255, 0.1);
    max-height: 500px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.thinking-process.collapsed .thinking-body {
    max-height: 0;
    padding: 0 1em;
    border-top: none;
    overflow: hidden;
}

/* Scrollbar for thinking body */
.thinking-body::-webkit-scrollbar {
    width: 6px;
}

.thinking-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.thinking-body::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.3);
    border-radius: 3px;
}

.thinking-body::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 77, 255, 0.5);
}

/* ============================================================================
   Login Overlay & Authentication
   ============================================================================ */

.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-container {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-logo {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    animation: bounce 2s infinite;
}

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

.login-header h2 {
    color: var(--text-primary);
    font-size: 1.75rem;
    margin-bottom: var(--spacing-sm);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: var(--spacing-xl);
}

.google-login-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    color: #3c4043;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.google-login-btn:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    background: #f8f9fa;
}

/* User Info in Header */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    margin-right: var(--spacing-md);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--bg-primary);
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==============================================================================
   Companions List View
   ============================================================================== */

.companions-list-view {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) var(--spacing-xl);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.list-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.user-info-compact {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.companions-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.companion-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.companion-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.companion-card-avatar {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    object-fit: cover;
}

.companion-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.companion-card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.companion-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.companion-card-badge {
    display: inline-flex;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: var(--radius-sm);
}

.companion-card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.companion-card-latest {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
    font-style: italic;
}

.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--danger-color);
    color: white;
    border-radius: var(--radius-full);
}

/* ==============================================================================
   Chat View
   ============================================================================== */

.chat-view {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.btn-back {
    margin-right: var(--spacing-sm);
}

.companion-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.companion-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.companion-info h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.companion-tag {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ============================================================================
   Voice Call UI
   ============================================================================ */

.voice-call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.voice-call-container {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.voice-call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.voice-call-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.voice-call-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
}

.voice-call-avatar {
    position: relative;
    width: 150px;
    height: 150px;
    margin: var(--spacing-lg) 0;
}

.voice-call-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.voice-call-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 180px;
    pointer-events: none;
}

.pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
    opacity: 0;
}

@keyframes pulse {
    0% {
        transform: scale(0.9);
        opacity: 0.8;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.voice-call-status {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.voice-call-status.connected {
    color: var(--success-color, #10b981);
}

.voice-call-status.error {
    color: var(--error-color, #ef4444);
}

.voice-call-transcription {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
}

.transcription-box {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.transcription-placeholder {
    color: var(--text-tertiary);
    font-style: italic;
    text-align: center;
    margin: 0;
}

.transcription-message {
    margin: var(--spacing-sm) 0;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
}

.transcription-message.user {
    background: rgba(124, 77, 255, 0.1);
    color: var(--text-primary);
    text-align: right;
}

.transcription-message.ai {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.transcription-message .source {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.voice-call-controls {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.btn-voice-control,
.btn-voice-end {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-voice-control {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-voice-control:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

.btn-voice-control.muted {
    background: #ef4444;
    color: white;
}

.btn-voice-end {
    background: #ef4444;
    color: white;
}

.btn-voice-end:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.btn-voice-control:active,
.btn-voice-end:active {
    transform: scale(0.95);
}

/* ============================================================================
   AI Demo Modal - Product Fusion Preview
   ============================================================================ */

.btn-ai-demo {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.btn-ai-demo:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

/* History Modal */
.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.history-container {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 600px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.history-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.history-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.history-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.history-item-content {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-start;
}

.history-deal-id {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
    word-break: break-all;
    flex: 1;
    margin-right: var(--spacing-sm);
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

.history-item-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.history-thumbnail {
    flex-shrink: 0;
}

.history-thumbnail img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 0;
}

.history-companion-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary-color);
}

.history-product {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.history-empty {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-light);
}

.history-empty p {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
}

.history-empty small {
    font-size: 0.85rem;
}

/* AI Demo Modal */
.ai-demo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-demo-container {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
}

.ai-demo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.ai-demo-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.ai-demo-header .btn-icon {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.ai-demo-header .btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.ai-demo-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.ai-demo-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.ai-demo-input-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.ai-demo-input-group input {
    padding: var(--spacing-md) var(--spacing-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.ai-demo-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-demo-input-group input::placeholder {
    color: var(--text-light);
}

.btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-generate:active:not(:disabled) {
    transform: translateY(0);
}

.btn-generate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-generate .spinner {
    animation: spin 1s linear infinite;
}

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

.ai-demo-result {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

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

.result-sources {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.source-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

.source-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.source-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
}

.source-plus,
.source-equals {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
}

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

.result-image img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.result-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.result-details strong {
    color: var(--text-primary);
}

.ai-demo-error {
    padding: var(--spacing-md);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: #dc2626;
    font-size: 0.9rem;
    text-align: center;
}

/* AI Demo Result - All Three Images */
.ai-demo-result-header {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.ai-demo-result-header h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.ai-demo-result-header .text-muted {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.ai-demo-source-images {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.ai-demo-source-images .source-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

.ai-demo-source-images .source-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
}

.ai-demo-source-images .source-image span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.ai-demo-generated-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

.generated-image-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.generated-image-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.image-card-header {
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.image-card-header h5 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.image-card-header p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.image-card-header .badge-cached {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.65rem;
    border-radius: var(--radius-sm);
    margin-left: var(--spacing-xs);
}

.image-card-header .badge-new {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    font-size: 0.65rem;
    border-radius: var(--radius-sm);
    margin-left: var(--spacing-xs);
}

.generated-image-card .image-wrapper {
    padding: var(--spacing-sm);
    text-align: center;
}

.generated-image-card .image-wrapper img {
    max-width: 100%;
    max-height: 250px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.generated-image-card .image-wrapper img:hover {
    transform: scale(1.02);
}

.generated-image-card .image-placeholder {
    padding: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-align: center;
}

.generated-image-card .image-placeholder.error {
    background: rgba(239, 68, 68, 0.05);
    color: #dc2626;
}

.generated-image-card .image-placeholder span {
    font-size: 0.9rem;
    font-weight: 500;
}

.generated-image-card .image-placeholder small {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: var(--spacing-xs);
}

/* Video Generation Button and Results */
.image-card-actions {
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.btn-generate-video {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.btn-generate-video:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-generate-video:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.video-warning {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.7rem;
    color: #f59e0b;
    text-align: center;
    opacity: 0.8;
}

.video-result {
    margin-top: var(--spacing-sm);
}

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

.video-success p {
    color: #10b981;
    font-size: 0.85rem;
    margin-bottom: var(--spacing-sm);
}

.video-success video {
    margin-bottom: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
}

.video-download-link {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: background var(--transition-fast);
}

.video-download-link:hover {
    background: var(--bg-primary);
}

.video-error {
    text-align: center;
    padding: var(--spacing-sm);
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-md);
}

.video-error p {
    color: #dc2626;
    font-size: 0.85rem;
    margin-bottom: var(--spacing-sm);
}

.btn-retry {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-retry:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .ai-demo-generated-images {
        grid-template-columns: 1fr;
    }
    
    .generated-image-card .image-wrapper img {
        max-height: 300px;
    }
}

@media (max-width: 600px) {
    .ai-demo-container {
        padding: var(--spacing-lg);
    }
    
    .result-sources {
        gap: var(--spacing-sm);
    }
    
    .source-item img {
        width: 60px;
        height: 60px;
    }
    
    .source-plus,
    .source-equals {
        font-size: 1.2rem;
    }
    
    .ai-demo-source-images {
        gap: var(--spacing-md);
    }
    
    .ai-demo-source-images .source-image img {
        width: 60px;
        height: 60px;
    }
}

