/* ===== CSS Variables Override for Chat ===== */
:root {
    --primary-color: #ffffff;
    --primary-dark: #e5e5e5;
    --primary-light: #f5f5f5;
    --secondary-color: #ffffff;
    --accent-color: #ffffff;
    
    --bg-dark: #000000;
    --bg-darker: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-card-hover: #252525;
    
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --border-color: #333333;
    --border-light: #555555;
    
    --gradient-primary: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    --gradient-secondary: linear-gradient(135deg, #ffffff 0%, #e5e5e5 100%);
}

/* ===== Chat Page Layout ===== */
.chat-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Chat Sidebar ===== */
.chat-sidebar {
    width: 280px;
    background: var(--bg-darker);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.chat-sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.sidebar-logo i {
    font-size: 1.4rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 20px;
    background: #ffffff;
    color: #000000;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.new-chat-btn:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.sidebar-search {
    padding: 15px 20px;
    position: relative;
}

.sidebar-search i {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.sidebar-search input {
    width: 100%;
    padding: 10px 15px 10px 35px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.sidebar-search input:focus {
    border-color: var(--primary-color);
}

.sidebar-search input::placeholder {
    color: var(--text-muted);
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
}

.chat-history::-webkit-scrollbar {
    width: 5px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

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

.history-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 15px 10px 5px;
    letter-spacing: 0.5px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
}

.history-item:hover {
    background: var(--bg-card);
}

.history-item.active {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.history-item i {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-item span {
    flex: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-chat {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    transition: var(--transition);
}

.history-item:hover .delete-chat {
    opacity: 1;
}

.delete-chat:hover {
    color: #ef4444;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 35px;
    height: 35px;
    background: var(--gradient-secondary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.user-info span {
    font-size: 0.9rem;
    font-weight: 500;
}

.settings-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

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

/* ===== Main Chat Area ===== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    min-width: 0;
}

/* Chat Header */
.chat-header {
    padding: 15px 20px;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

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

.chat-title {
    flex: 1;
}

.chat-title h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-title .status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status.online i {
    color: #22c55e;
    font-size: 0.5rem;
}

.chat-actions {
    display: flex;
    gap: 5px;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

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

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

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    animation: pulse 2s ease-in-out infinite;
}

.welcome-icon i {
    font-size: 2.5rem;
    color: white;
}

.welcome-screen h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.welcome-screen p {
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 30px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 600px;
}

.chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.chip:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.chip i {
    color: var(--primary-light);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 15px;
    max-width: 800px;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    background: var(--gradient-primary);
}

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

.message-avatar i {
    color: white;
    font-size: 1rem;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message.user .message-content {
    text-align: right;
}

.message-bubble {
    display: inline-block;
    padding: 15px 20px;
    border-radius: var(--radius-lg);
    max-width: 100%;
    word-wrap: break-word;
}

.message.assistant .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    text-align: left;
}

.message.user .message-bubble {
    background: #ffffff;
    color: #000000;
}

.message-bubble p {
    margin-bottom: 10px;
}

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

.message-bubble pre {
    background: var(--bg-darker);
    border-radius: var(--radius-md);
    padding: 15px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid var(--border-color);
}

.message-bubble code {
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 0.9rem;
}

.message-bubble code:not(pre code) {
    background: var(--bg-darker);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.message-bubble ul,
.message-bubble ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin-bottom: 5px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-actions {
    display: flex;
    gap: 5px;
}

.input-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.input-action-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 200px;
    padding: 8px 0;
    line-height: 1.5;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-submit {
    display: flex;
}

.send-btn {
    width: 40px;
    height: 40px;
    background: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    color: #000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.send-btn:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

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

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ===== Settings Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.active .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.setting-item input[type="text"],
.setting-item input[type="password"],
.setting-item input[type="url"],
.setting-item select {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.setting-item input:focus,
.setting-item select:focus {
    border-color: var(--primary-color);
}

.setting-item small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

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

.toggle-item label {
    margin-bottom: 0;
}

.toggle-item input[type="checkbox"] {
    width: 40px;
    height: 22px;
    appearance: none;
    background: var(--border-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.toggle-item input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition);
}

.toggle-item input[type="checkbox"]:checked {
    background: var(--primary-color);
}

.toggle-item input[type="checkbox"]:checked::before {
    left: 20px;
}

.theme-options {
    display: flex;
    gap: 10px;
}

.theme-btn {
    flex: 1;
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.theme-btn:hover {
    border-color: var(--border-light);
}

.theme-btn.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    padding: 10px 20px;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .chat-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .chat-sidebar.active {
        transform: translateX(0);
    }
    
    .welcome-screen h2 {
        font-size: 1.4rem;
    }
    
    .suggestion-chips {
        flex-direction: column;
    }
    
    .message {
        max-width: 95%;
    }
    
    .message-bubble {
        padding: 12px 15px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 10px 15px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .chat-input-container {
        padding: 10px 15px 15px;
    }
    
    .input-wrapper {
        padding: 5px;
    }
    
    .input-wrapper textarea {
        font-size: 0.95rem;
    }
}
