/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Dark mode */
[data-theme="dark"] {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --border-color: #374151;
    --border-light: #4b5563;
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}

[data-theme="dark"] .header {
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(10px);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .sidebar {
    background: var(--bg-secondary);
    border-right-color: var(--border-color);
}

[data-theme="dark"] .main-input {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .main-input::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .action-btn,
[data-theme="dark"] .voice-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .chat-item {
    color: var(--text-primary);
}

[data-theme="dark"] .chat-item:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .message.user .message-content {
    background: var(--primary-color);
    color: white;
}

[data-theme="dark"] .message.assistant .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
}

.header-content .sidebar-toggle {
    margin-right: -1000px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.logo:hover {
    transform: translateY(-1px);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    box-shadow: var(--shadow-md);
}

.dropdown-icon {
    font-size: 12px;
    color: #666;
    margin-left: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.btn-plus {
    background: linear-gradient(135deg, var(--secondary-color), #7c3aed);
    color: white;
    padding: 10px 16px;
    font-size: 14px;
}

.btn-plus:hover {
    background: linear-gradient(135deg, #7c3aed, var(--secondary-color));
}

.plus-icon {
    font-size: 12px;
}

.help-btn,
.settings-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: #f0f0f0;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #666;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
}

.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 120px;
}

.menu-item {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.menu-item:hover {
    background-color: #f0f0f0;
}

.hidden {
    display: none !important;
}

/* Landing page styles */
.landing-page {
    padding-top: 60px;
}

.main-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 40px 20px;
}

.container {
    width: 100%;
    max-width: 800px;
    text-align: center;
}

.hero-title {
    font-size: 48px;
    font-weight: 300;
    color: #333;
    margin-bottom: 40px;
    line-height: 1.2;
}

.input-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.input-field {
    position: relative;
    background: var(--bg-primary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.input-field:focus-within {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}

.main-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 18px;
    outline: none;
    color: var(--text-primary);
    font-weight: 500;
    min-height: 24px;
}

.main-input::placeholder {
    color: var(--text-muted);
    font-weight: 100;
    font-size: 18px;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.action-btn,
.voice-btn {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-weight: 600;
    min-width: 100px;
    justify-content: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.action-btn:hover,
.voice-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

.icon {
    font-size: 14px;
}

/* Dashboard styles */
.dashboard-page {
    padding-top: 64px;
}

.dashboard-container {
    display: flex;
    height: calc(100vh - 64px);
}

.sidebar {
    width: 300px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

/* Sidebar toggle button */
.sidebar-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.9);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Collapsed sidebar state */
body.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: hidden;
}

body.sidebar-collapsed .main-content {
    width: 100%;
}

.sidebar-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-nav {
    margin-bottom: 30px;
}

.nav-item {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #666;
    transition: background-color 0.2s ease;
    margin-bottom: 4px;
}

.nav-item:hover {
    background-color: #f0f0f0;
}

.nav-item.active {
    background-color: #f0f0f0;
    color: #333;
}

.chats-section {
    flex: 1;
    margin-bottom: 20px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chats-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    margin-bottom: 4px;
}

.chat-item:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
}

.chat-title {
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.delete-chat-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    background: var(--error-color);
    color: white;
    transform: scale(1.1);
}

.delete-icon {
    font-size: 12px;
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: #f8f8f8;
    border-radius: 8px;
    margin-top: auto;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #666;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.profile-details {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.profile-plan {
    font-size: 12px;
    color: #666;
}

.upgrade-btn {
    padding: 6px 12px;
    background-color: transparent;
    border: 1px solid #666;
    border-radius: 6px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
}

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    overflow-x: hidden; /* prevent horizontal scroll */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: transparent;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.welcome-message h1 {
    font-size: 48px;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 40px;
    line-height: 1.2;
}

.welcome-message .input-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.message {
    margin-bottom: 24px;
    width: 100%;
    max-width: 800px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-content {
    padding: 16px 20px;
    border-radius: var(--radius-xl);
    font-size: 16px;
    line-height: 1.6;
    max-width: 80%;
    position: relative;
    box-shadow: var(--shadow-sm);
    white-space: pre-wrap; /* preserve newlines */
    overflow-wrap: anywhere; /* break long words/urls */
    word-break: break-word;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-content {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: var(--radius-sm);
}

.message.assistant .message-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent var(--bg-primary) transparent transparent;
}

.message.user .message-content::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 8px 8px;
    border-color: transparent transparent var(--primary-color) transparent;
}

.typing-indicator {
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.message {
    animation: fadeInUp 0.3s ease-out;
}

.chat-item {
    animation: slideInRight 0.2s ease-out;
}

.btn:hover {
    animation: pulse 0.3s ease-in-out;
}

/* Notifications */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    animation: slideInRight 0.3s ease-out;
}

.notification-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
}

.notification-success {
    background: var(--success-color);
    color: white;
}

.notification-error {
    background: var(--error-color);
    color: white;
}

.notification-info {
    background: var(--accent-color);
    color: white;
}

.notification-warning {
    background: var(--warning-color);
    color: white;
}

.notification-message {
    font-weight: 500;
    font-size: 14px;
}

.notification-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    margin-left: 12px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.notification-close:hover {
    opacity: 1;
}

.chat-input-container {
    padding: 24px 40px;
    background: transparent;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.chat-input-container .input-field {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    min-height: 60px;
    backdrop-filter: blur(20px);
    transition: all 0.3s ease;
    position: relative;
}

/* Center only the placeholder text (keep typed text left-aligned) */
.chat-input-container .main-input::placeholder {
    text-align: center;
    color: var(--text-muted);
    font-weight: 400;
}

.chat-input-container .input-field:focus-within {
    background: rgba(255, 255, 255, 0.98);
    border-color: var(--primary-color);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.action-buttons-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    padding: 16px 0;
    flex-wrap: wrap;
}

.input-icon {
    font-size: 20px;
    color: #666;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid var(--border-light);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-input-container .main-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    color: #333;
    padding-left: 28px; /* space for the + icon */
    resize: none;
    overflow: hidden; /* hide scrollbar while auto-expanding */
    line-height: 1.6;
}

.chat-input-container .main-input::placeholder {
    text-align: center;
    color: var(--text-muted);
    font-weight: 400;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    white-space: nowrap;
}

.chat-input-container .input-actions {
    display: flex;
    gap: 8px;
}

.chat-input-container .voice-btn,
.chat-input-container .audio-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.chat-input-container .voice-btn:hover,
.chat-input-container .audio-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* Auth page styles */
.auth-page {
    background-color: #f8f8f8;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.auth-header {
    padding: 30px 30px 20px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.auth-content {
    padding: 30px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tab-btn.active {
    color: #333;
    border-bottom-color: #333;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-form.hidden {
    display: none;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group input {
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    border-color: #333;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.alert-success {
    background-color: #efe;
    color: #363;
    border: 1px solid #cfc;
}

/* Responsive design */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
    }
    
    .hero-title {
        font-size: 32px;
    }
    
    .chat-messages {
        padding: 20px;
    }
    
    .chat-input-container {
        padding: 20px;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}
