/* Chat Sidebar Styles */
.chat-sidebar {
    width: 280px;
    background-color: white;
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: fixed;
    left: var(--sidebar-width);
    top: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
}

.chat-sidebar.visible {
    transform: translateX(0);
}

.main-content.chat-open {
    margin-left: calc(var(--sidebar-width) + 280px);
    width: calc(100% - var(--sidebar-width) - 280px);
}

.chat-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, rgba(79, 70, 229, 0.05), rgba(139, 92, 246, 0.05));
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-title h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.new-chat-btn {
    background-color: var(--primary-light);
    color: var(--primary-color);
    border: none;
    border-radius: var(--radius-md);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

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

.chat-sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-options {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #f9fafc;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-option-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-option-item label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Smaller dropdowns for chat sidebar */
.chat-sidebar .compact-select {
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
    height: 28px;
}

.chat-sidebar .select-selected {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    min-height: 28px;
}

.chat-sidebar .select-items div {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

.chat-list {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Explicitly add scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--text-tertiary) transparent;
}

/* Scrollbar styling for chat list */
.chat-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

.chat-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

.chat-tab {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-md);
    background-color: #f1f5f9;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.chat-tab:hover {
    background-color: var(--primary-light);
}

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

.chat-tab.active svg {
    stroke: white;
}

.chat-tab-icon {
    margin-right: 0.5rem;
    display: flex;
    align-items: center;
}

.chat-tab-name {
    flex: 1;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-tab-close {
    background: none;
    border: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: var(--transition);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 50%;
}

.chat-tab:hover .chat-tab-close {
    opacity: 1;
}

.chat-tab .chat-tab-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #f9fafc;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Add scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--text-tertiary) transparent;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin-bottom: 0.5rem;
    position: relative;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.bot {
    align-items: flex-start;
}

.chat-message-content {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    max-width: 85%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.chat-message.user .chat-message-content {
    background-color: var(--primary-color);
    color: white;
    border-radius: 1.2rem 1.2rem 0.3rem 1.2rem;
}

.chat-message.user .chat-message-content::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 16px;
    height: 16px;
    background-color: var(--primary-color);
    border-radius: 0 0 0 16px;
    transform: translateY(8px);
    display: none; /* Optional: enable for more pronounced bubble tail */
}

.chat-message.bot .chat-message-content {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 1.2rem 1.2rem 1.2rem 0.3rem;
}

.chat-message.bot .chat-message-content::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 0 0 16px 0;
    border-left: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transform: translateY(8px);
    display: none; /* Optional: enable for more pronounced bubble tail */
}

.chat-message.system .chat-message-content {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    font-style: italic;
    margin: 0.5rem auto;
    max-width: 90%;
    text-align: center;
}

.chat-message-content p {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

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

/* Updated code block styling */
.chat-message-content pre {
    margin: 0.75rem 0;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    overflow-x: auto;
    max-width: 100%;
    font-size: 0.82rem;
    line-height: 1.4;
    max-height: 300px;
    overflow-y: auto;
    /* Add visible scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

.chat-message-content pre::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.chat-message-content pre::-webkit-scrollbar-track {
    background: transparent;
}

.chat-message-content pre::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

.chat-message-content pre::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

.chat-message-content code {
    font-family: 'Fira Code', 'Roboto Mono', monospace;
    font-size: 0.85rem;
    color: #abb2bf;
    white-space: pre;
    word-break: normal;
    word-wrap: normal;
}

.chat-message.user .chat-message-content code:not(pre code) {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: var(--radius-sm);
}

.chat-message.bot .chat-message-content code:not(pre code) {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
    padding: 0.1rem 0.3rem;
    border-radius: var(--radius-sm);
}

.chat-input-container {
    padding: 0.75rem;
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    resize: none;
    font-size: 0.9rem;
    line-height: 1.5;
    transition: var(--transition);
    overflow-y: auto;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.send-message-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    align-self: center;
}

.send-message-btn:hover {
    background-color: var(--primary-hover);
}

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

.chat-typing {
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-tertiary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
    display: inline-block;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

.chat-mode-selector {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    background-color: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    width: 80%;
    max-width: 400px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.chat-mode-selector.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.chat-mode-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-primary);
}

.chat-mode-options {
    display: flex;
    gap: 1rem;
}

.chat-mode-option {
    flex: 1;
    background-color: #f1f5f9;
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.chat-mode-option:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
}

.chat-mode-option-icon {
    background-color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.chat-mode-option-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.chat-mode-option-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.use-in-generator-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem;
    background-color: var(--primary-light);
    color: var(--primary-color);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.use-in-generator-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Code highlighting in chat */
.chat-message-content .hljs {
    background: transparent;
    padding: 0;
}

.dark-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dark-overlay.visible {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .chat-sidebar {
        width: 250px;
    }
    
    .main-content.chat-open {
        margin-left: calc(var(--sidebar-width) + 250px);
        width: calc(100% - var(--sidebar-width) - 250px);
    }
}

@media (max-width: 992px) {
    .chat-sidebar {
        left: 0;
        z-index: 110;
        width: 300px;
    }
    
    .main-content.chat-open {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
    
    .sidebar {
        z-index: 120;
    }
}

@media (max-width: 768px) {
    .chat-sidebar {
        width: 100%;
    }
}