/* CSS Variables for theming */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #ffffff;
    --text-secondary: #b4b4b4;
    --text-muted: #8a8a8a;
    --accent-primary: #10a37f;
    --accent-hover: #0d8a6a;
    --danger: #e74c3c;
    --warning: #f39c12;
    --border: #404040;
    --border-light: #525252;
    --shadow: rgba(0, 0, 0, 0.3);
    --gradient: linear-gradient(135deg, #10a37f, #0d8a6a);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececec;
    --text-primary: #2c2c2c;
    --text-secondary: #5e5e5e;
    --text-muted: #8a8a8a;
    --accent-primary: #10a37f;
    --accent-hover: #0d8a6a;
    --danger: #e74c3c;
    --warning: #f39c12;
    --border: #e5e5e5;
    --border-light: #f0f0f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --gradient: linear-gradient(135deg, #10a37f, #0d8a6a);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Authentication Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px var(--shadow);
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.auth-form input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
}

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

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(16, 163, 127, 0.3);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

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

.btn-danger:hover {
    background-color: #c0392b;
}

/* Main App Layout */
.app {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--accent-primary);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.chat-item:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border);
}

.chat-item.active {
    background-color: var(--accent-primary);
    color: white;
}

.chat-item-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-item.active .chat-item-time {
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
}

.sidebar-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.sidebar-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
}

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

.ai-provider-selector select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 600px;
    color: var(--text-secondary);
}

.welcome-message h2 {
    font-size: 28px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 16px;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 800px;
    width: 100%;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--gradient);
    color: white;
}

.message.assistant .message-avatar {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
}

.message-content {
    background-color: var(--bg-secondary);
    padding: 16px;
    border-radius: 12px;
    line-height: 1.6;
    word-wrap: break-word;
    max-width: 100%;
}

.message.user .message-content {
    background-color: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Chat Input */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: var(--bg-primary);
}

.chat-input-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 800px;
    margin: 0 auto;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    font-family: inherit;
    transition: all 0.3s ease;
}

#message-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

#message-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-send {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--gradient);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(16, 163, 127, 0.3);
}

.btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin-top: 12px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 800px;
    margin-left: 52px;
}

.typing-animation {
    display: flex;
    gap: 4px;
}

.typing-animation span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Settings Modal */
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.setting-section {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.setting-section:last-child {
    border-bottom: none;
}

.setting-section h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.provider-config {
    background-color: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.provider-config h4 {
    margin-bottom: 15px;
    color: var(--accent-primary);
}

.provider-config input,
.provider-config select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.setting-item label {
    color: var(--text-secondary);
}

.setting-item select,
.setting-item input[type="checkbox"] {
    padding: 6px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 16px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    max-width: 300px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.toast.success {
    background-color: var(--accent-primary);
}

.toast.error {
    background-color: var(--danger);
}

.toast.warning {
    background-color: var(--warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .chat-area {
        width: 100%;
    }
    
    .messages-container {
        padding: 10px;
    }
    
    .chat-input-container {
        padding: 15px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .sidebar-header h1 {
        font-size: 20px;
    }
    
    .welcome-message h2 {
        font-size: 24px;
    }
    
    .message {
        gap: 12px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .message-content {
        padding: 12px;
        font-size: 14px;
    }
    
    .typing-indicator {
        margin-left: 44px;
        padding: 10px 12px;
    }
}
