/* Base Styles & Variables */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f9fafb;
    --sidebar-bg: #1e1b4b;
    --sidebar-hover: #312e81;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --message-user-bg: #6366f1;
    --message-ai-bg: #ffffff;
    --input-bg: #f3f4f6;
    --border-color: #e5e7eb;
    --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);
}

/* Dark Theme */
.dark {
    --bg-color: #111827;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --message-user-bg: #4338ca;
    --message-ai-bg: #1f2937;
    --input-bg: #1f2937;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-color);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: #9ca3af;
    border-radius: 20px;
}

.dark ::-webkit-scrollbar-thumb {
    background-color: #4b5563;
}

/* Layout */
.flex {
    display: flex;
}

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

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

.justify-between {
    justify-content: space-between;
}

/* Sidebar */
.bg-indigo-900 {
    background-color: var(--sidebar-bg);
    transition: background-color 0.3s;
}

.border-indigo-800 {
    border-color: rgba(99, 102, 241, 0.2);
}

/* Chat Container */
#chat-container {
    scroll-behavior: smooth;
    padding-bottom: 1.5rem;
}

/* Messages */
.message {
    max-width: 85%;
    margin-bottom: 1.5rem;
    animation: messageIn 0.3s ease-out;
}

.message.user {
    margin-left: auto;
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-content {
    background-color: var(--message-user-bg);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.ai .message-content {
    background-color: var(--message-ai-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: var(--message-ai-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    opacity: 0.4;
}

/* Input Area */
#input-area {
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    position: relative;
}

#user-input {
    width: 100%;
    min-height: 44px;
    max-height: 200px;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-primary);
    resize: none;
    outline: none;
    transition: all 0.2s;
    line-height: 1.5;
}

#user-input:focus {
    box-shadow: 0 0 0 2px var(--primary);
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* Animations */
@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .w-64 {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        z-index: 40;
    }
    
    .flex {
        flex-direction: column;
    }
    
    .message {
        max-width: 90%;
    }
}

/* Custom Scrollbar for Webkit */
.scrollbar-thin::-webkit-scrollbar {
    width: 4px;
}

.scrollbar-thin::-webkit-scrollbar-track {
    background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
    background-color: #9ca3af;
    border-radius: 20px;
}

/* Loading Animation */
.loading-dots:after {
    content: '.';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(0,0,0,0);
        text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0);
    }
    40% {
        color: currentColor;
        text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0);
    }
    60% {
        text-shadow: .25em 0 0 currentColor, .5em 0 0 rgba(0,0,0,0);
    }
    80%, 100% {
        text-shadow: .25em 0 0 currentColor, .5em 0 0 currentColor;
    }
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 120px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.75rem;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}
