@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #10a37f;
    --primary-glow: rgba(16, 163, 127, 0.3);
    --accent: #6366f1;
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1e1e1e;
    --bg-hover: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border: #2a2a2a;
    --border-light: #3a3a3a;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --gradient: linear-gradient(135deg, #10a37f 0%, #6366f1 100%);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-sidebar {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.new-chat-btn {
    margin: 15px;
    padding: 14px 20px;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.sidebar-section {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item {
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-item i {
    font-size: 14px;
    opacity: 0.6;
}

.quick-section {
    flex: 0;
    border-top: 1px solid var(--border);
}

.quick-actions {
    display: flex;
    gap: 8px;
}

.quick-actions button {
    flex: 1;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.quick-actions button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
}

.sidebar-footer select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 10px;
}

.sidebar-footer p {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
}

/* Header */
.chat-header {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center h1 {
    font-size: 18px;
    font-weight: 600;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.web-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    border: 1px solid var(--border);
}

.web-toggle input { display: none; }

.toggle-track {
    width: 36px;
    height: 20px;
    background: var(--bg-hover);
    border-radius: 10px;
    position: relative;
    transition: var(--transition);
}

.toggle-thumb {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition);
}

.web-toggle input:checked + .toggle-track {
    background: var(--primary);
}

.web-toggle input:checked + .toggle-track .toggle-thumb {
    left: 18px;
}

.web-toggle i {
    color: var(--text-secondary);
    font-size: 14px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ==================== MESSAGES ==================== */
.messages-wrapper {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.messages {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Welcome Screen */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    animation: fadeUp 0.6s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero-icon {
    width: 100px;
    height: 100px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
}

.hero-icon i {
    font-size: 45px;
    color: white;
    z-index: 2;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--primary);
    animation: ringPulse 3s infinite;
}

.ring1 { width: 100%; height: 100%; animation-delay: 0s; }
.ring2 { width: 130%; height: 130%; animation-delay: 0.5s; opacity: 0.5; }
.ring3 { width: 160%; height: 160%; animation-delay: 1s; opacity: 0.3; }

@keyframes ringPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.2; }
}

.welcome-hero h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
}

.welcome-hero h1 span {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-hero p {
    color: var(--text-secondary);
    font-size: 16px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 40px;
    width: 100%;
    max-width: 700px;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 15px;
    text-align: center;
    transition: var(--transition);
}

.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.feature-card i {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
}

.feature-card p {
    font-size: 12px;
    color: var(--text-muted);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 700px;
}

.suggestions button {
    padding: 10px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 25px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.suggestions button:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.05);
}

/* Message Bubbles */
.message {
    margin-bottom: 25px;
    animation: msgIn 0.4s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
}

.message.user .avatar {
    background: var(--accent);
}

.message.assistant .avatar {
    background: var(--gradient);
}

.sender-name {
    font-weight: 600;
    font-size: 14px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.message-content {
    padding: 16px 20px;
    border-radius: var(--radius);
    line-height: 1.7;
}

.message.user .message-content {
    background: var(--accent);
    margin-left: 44px;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    margin-left: 44px;
}

.message-content p { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }

.message-content ul, .message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li { margin-bottom: 6px; }

.message-content a {
    color: var(--primary);
    text-decoration: none;
}

.message-content a:hover { text-decoration: underline; }

/* Code Blocks */
.message-content pre {
    background: #0d0d0d;
    border-radius: 8px;
    padding: 0;
    margin: 15px 0;
    overflow: hidden;
    border: 1px solid var(--border);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.copy-code {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.copy-code:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.message-content pre code {
    display: block;
    padding: 15px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Fira Code', monospace;
}

.message-content pre code { background: transparent; padding: 0; }

/* Message Actions */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    margin-left: 44px;
    opacity: 0;
    transition: var(--transition);
}

.message:hover .message-actions { opacity: 1; }

.action-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Search Results */
.search-results {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
    margin-left: 44px;
}

.search-results-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
}

.search-result-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item a {
    color: #58a6ff;
    font-size: 14px;
    text-decoration: none;
    font-weight: 500;
}

.search-result-item a:hover { text-decoration: underline; }

.search-result-item p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.5;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 20px;
    margin-left: 44px;
}

.typing-dot {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Search Animation */
.search-animation {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    margin-left: 44px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}

.search-icon-container {
    width: 40px;
    height: 40px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.search-icon-container i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.search-text {
    display: flex;
    flex-direction: column;
}

.search-status {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    animation: fadeIn 0.3s ease;
}

.search-dots {
    display: flex;
    gap: 2px;
}

.search-dots span {
    color: var(--primary);
    font-size: 20px;
    animation: dotPulse 1.5s infinite;
}

.search-dots span:nth-child(1) { animation-delay: 0s; }
.search-dots span:nth-child(2) { animation-delay: 0.3s; }
.search-dots span:nth-child(3) { animation-delay: 0.6s; }

@keyframes dotPulse {
    0%, 60%, 100% { opacity: 0.2; }
    30% { opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Search Results Animation */
.search-results.animate-in {
    animation: slideUp 0.4s ease;
}

.search-results.animate-in .search-result-item {
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==================== INPUT AREA ==================== */
.input-area {
    padding: 20px;
    background: linear-gradient(to top, var(--bg-primary) 80%, transparent);
}

.input-box {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.input-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 15px 0;
}

.attached-file {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
}

.attached-file img {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border-radius: 4px;
}

.attached-file .remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
}

.input-row {
    display: flex;
    align-items: flex-end;
    padding: 12px 15px;
    gap: 10px;
}

.input-tools {
    display: flex;
    gap: 5px;
}

.input-tools button {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.input-tools button:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.input-tools button.recording {
    color: var(--error);
    animation: pulse 1s infinite;
}

.input-row textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    max-height: 150px;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
}

.input-row textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--gradient);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.footer-text {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    opacity: 0;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: var(--shadow);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast i { color: var(--success); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        height: 100%;
        z-index: 100;
    }
    
    .sidebar.open { left: 0; }
    .sidebar-overlay.show { display: block; }
    .close-sidebar { display: block; }
    .menu-btn { display: flex; }
    
    .header-center h1 { font-size: 16px; }
    .online-badge span:last-child { display: none; }
    
    .welcome-hero h1 { font-size: 24px; }
    .features-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .feature-card { padding: 15px 10px; }
    .feature-card i { font-size: 22px; }
    
    .suggestions { gap: 8px; }
    .suggestions button { padding: 8px 14px; font-size: 12px; }
    
    .message.user .message-content,
    .message.assistant .message-content,
    .message-actions,
    .search-results {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .features-grid { grid-template-columns: 1fr 1fr; }
    .input-tools button:first-child { display: none; }
    .web-toggle span { display: none; }
}
