/* ========================================
   LUMINA - Chat Page Styles
   ======================================== */

.chat-layout {
    display: flex;
    gap: 1rem;
    height: calc(100vh - 180px);
    min-height: 500px;
}

/* Sidebar - Chat History */
.chat-sidebar {
    width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

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

.sidebar-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.new-chat-btn {
    padding: 8px 14px;
    background: linear-gradient(135deg, #00ff88 0%, #00f0ff 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--bg-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.new-chat-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.chat-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

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

.chat-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.chat-item-delete {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    border-radius: 4px;
}

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

.chat-item-delete:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

/* Main Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.chat-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(135deg, #00ff88 0%, #00f0ff 50%, #8b5cf6 100%);
}

/* Chat header */
.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header h2 svg {
    color: #00ff88;
    width: 20px;
    height: 20px;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.model-select {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
}

.model-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.clear-btn {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.clear-btn:hover {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

/* Message bubbles */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

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

.message.user .message-avatar {
    background: linear-gradient(135deg, #00f0ff, #00ff88);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #00ff88, #8b5cf6);
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    line-height: 1.7;
    font-size: 0.95rem;
}

.message.user .message-content {
    background: rgba(0, 240, 255, 0.15);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--text-primary);
}

.message.assistant .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Markdown Styling */
.message-content p {
    margin: 0 0 0.75rem 0;
}

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

.message-content strong, .message-content b {
    color: #00ff88;
    font-weight: 600;
}

.message-content em, .message-content i {
    color: var(--accent-primary);
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88em;
    color: #00f0ff;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.5);
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    position: relative;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: #e0e0e0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.message-content h1, .message-content h2, .message-content h3, 
.message-content h4, .message-content h5, .message-content h6 {
    color: #00ff88;
    margin: 1.2rem 0 0.6rem 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.4rem; }
.message-content h2 { font-size: 1.25rem; }
.message-content h3 { font-size: 1.1rem; }
.message-content h4 { font-size: 1rem; }

.message-content ul, .message-content ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin: 0.4rem 0;
}

.message-content li::marker {
    color: #00ff88;
}

.message-content blockquote {
    border-left: 3px solid #00ff88;
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: rgba(0, 255, 136, 0.1);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.message-content th, .message-content td {
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: left;
}

.message-content th {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
    font-weight: 600;
}

.message-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.message-content a {
    color: var(--accent-primary);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    gap: 12px;
    max-width: 85%;
}

.typing-indicator.visible {
    display: flex;
}

.typing-dots {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

/* Welcome message */
.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.welcome-message svg {
    width: 60px;
    height: 60px;
    color: #00ff88;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.welcome-message h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome-message p {
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Input area */
.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.chat-input-form {
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    transition: all 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

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

.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00ff88 0%, #00f0ff 100%);
    border: none;
    color: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

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

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

.send-btn svg {
    width: 22px;
    height: 22px;
}

/* Error message */
.chat-error {
    padding: 12px 16px;
    background: rgba(255, 0, 100, 0.1);
    border: 1px solid rgba(255, 0, 100, 0.3);
    border-radius: var(--radius-md);
    color: #ff6b9d;
    margin: 0 1.5rem 1rem;
    display: none;
    font-size: 0.9rem;
}

.chat-error.visible {
    display: block;
}

/* Empty state for sidebar */
.empty-chats {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {
    .chat-layout {
        flex-direction: column;
        height: auto;
    }
    
    .chat-sidebar {
        width: 100%;
        max-height: 200px;
    }
    
    .chat-container {
        height: calc(100vh - 400px);
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .chat-sidebar {
        display: none;
    }
    
    .chat-container {
        height: calc(100vh - 180px);
    }
    
    .message {
        max-width: 95%;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
}
