/* Enhanced ChatGPT-style Design */

/* Custom scrollbar for chat area */
#messagesContainer::-webkit-scrollbar {
    width: 6px;
}

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

#messagesContainer::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#messagesContainer::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Dark mode scrollbar */
.dark #messagesContainer::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark #messagesContainer::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Sidebar scrollbar */
.chat-history::-webkit-scrollbar {
    width: 4px;
}

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

.chat-history::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

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

/* Message animations */
.message {
    animation: fadeInUp 0.3s ease-out;
}

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

/* Enhanced code block styling */
.message pre {
    background-color: #1f2937;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    border: 1px solid #374151;
}

.message code {
    color: #e5e7eb;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Inline code */
.message p code {
    background-color: #f3f4f6;
    color: #1f2937;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.dark .message p code {
    background-color: #374151;
    color: #e5e7eb;
}

/* Enhanced loading animation */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #6b7280;
    animation: pulse 1.4s infinite ease-in-out;
}

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

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

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

/* Chat item hover effects */
.chat-item {
    transition: all 0.15s ease;
    border-radius: 8px;
}

.chat-item:hover {
    transform: translateX(2px);
}

.chat-item.active {
    background-color: #e5e7eb !important;
}

.dark .chat-item.active {
    background-color: #374151 !important;
}

/* Button hover effects */
button {
    transition: all 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
}

/* Prevent hover transform on absolutely positioned buttons */
#clearSearchBtn:hover {
    transform: translateY(-50%) !important;
}

button:active {
    transform: translateY(0);
}

/* Input focus styles */
#messageInput:focus,
#searchInput:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Textarea styles */
#messageInput {
    transition: height 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.5;
}

/* Search input styles */
#searchInput {
    transition: box-shadow 0.15s ease;
}

/* Ensure textarea scrollbar matches design */
#messageInput::-webkit-scrollbar {
    width: 6px;
}

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

#messageInput::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dark #messageInput::-webkit-scrollbar-thumb {
    background: #6b7280;
}

/* Modal animations */
.modal-enter {
    animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Welcome message animation */
#welcomeMessage {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Improved typography */
.prose {
    line-height: 1.6;
}

.prose p {
    margin-bottom: 1rem;
}

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

.prose strong {
    font-weight: 600;
}

.prose em {
    font-style: italic;
}

/* Theme transition */
* {
    transition-property: background-color, border-color, color;
    transition-duration: 200ms;
    transition-timing-function: ease-in-out;
}

/* Responsive design */
@media (max-width: 768px) {
    .w-64 {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        height: 100vh;
    }
    
    .flex-1 {
        margin-left: 0;
    }
}

/* Enhanced sidebar styling */
.sidebar-section {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

.dark .sidebar-section {
    border-bottom-color: #374151;
}

/* Better focus indicators */
button:focus,
input:focus,
select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Smooth icon transitions */
i {
    transition: transform 0.15s ease;
}

button:hover i {
    transform: scale(1.1);
}

/* Message container spacing */
.message + .message {
    border-top: 1px solid #f3f4f6;
}

.dark .message + .message {
    border-top-color: #374151;
}

/* Send button enhancement */
#sendBtn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#sendBtn:not(:disabled):hover {
    transform: scale(1.05);
}

/* Send button with text state */
#sendBtn[data-has-text="true"] {
    background-color: #000000 !important;
    color: #ffffff !important;
}

#sendBtn[data-has-text="true"]:hover {
    background-color: #1f2937 !important;
}

.dark #sendBtn[data-has-text="true"] {
    background-color: #ffffff !important;
    color: #000000 !important;
}

.dark #sendBtn[data-has-text="true"]:hover {
    background-color: #e5e7eb !important;
}

/* Floating Model selector styling */
#modelTrigger {
    min-width: 160px;
    max-width: 200px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

#modelTrigger:hover {
    transform: translateY(-1px);
    shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

/* Floating container animation */
.absolute.top-4 {
    animation: fadeInDown 0.4s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#modelDropdown {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: dropdownSlideIn 0.15s ease-out;
}

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

/* Custom dropdown scrollbar */
#modelsList::-webkit-scrollbar {
    width: 6px;
}

#modelsList::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#modelsList::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dark #modelsList::-webkit-scrollbar-track {
    background: #374151;
}

.dark #modelsList::-webkit-scrollbar-thumb {
    background: #6b7280;
}

/* Model item hover effects */
#modelsList [data-model-id] {
    transition: all 0.1s ease;
}

#modelsList [data-model-id]:hover {
    transform: translateX(2px);
}

/* Search input styling */
#modelSearch:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Arrow rotation animation */
#modelArrow {
    transition: transform 0.2s ease;
}

/* Model badge styling */
.model-badge {
    animation: fadeIn 0.2s ease-out;
}

/* Alert styling improvements */
#apiKeyAlert {
    animation: slideInRight 0.3s ease-out;
}

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

/* Image Preview Overlay Styles */
#imagePreviewOverlay {
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
    cursor: pointer;
}

#imagePreviewOverlay.hidden {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

#imagePreviewOverlay .relative {
    cursor: default;
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#closeImagePreview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#closeImagePreview:hover {
    transform: scale(1.1);
}

#previewImage {
    cursor: default;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Make images in messages clickable */
.message img {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.message img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    #previewImage {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    #closeImagePreview {
        top: 0.5rem;
        right: 0.5rem;
    }
}