/* Component Styles */

/* Logo */
#logo {
    cursor: pointer;
    transition: transform var(--transition-speed) ease-in-out;
    height: 3rem;
    width: auto;
    display: block;
    margin: 0 auto 1rem;
}

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

/* New Chat Button */
#new-chat-btn {
    background: var(--primary-color);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed) ease-in-out;
    width: 100%;
    margin-bottom: 1rem;
}

#new-chat-btn:hover {
    background-color: darken(var(--primary-color), 10%);
}

#new-chat-btn i {
    margin-right: 0.5rem;
}

/* Model Selector */
#model-selector-container {
    position: relative;
    margin-bottom: 1rem;
}

#model-selector {
    background-color: rgba(0, 0, 0, 0.2);
    border: none;
    padding: 0.5rem 2rem 0.5rem 0.5rem;
    border-radius: 20px;
    color: var(--text-light);
    width: 100%;
    appearance: none;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease-in-out;
}

#model-selector:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

#model-selector:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

#model-selector-container::after {
    content: '\f0d7';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-light);
}

#model-selector option {
    background-color: #34495e;
    color: var(--text-light);
    padding: 0.5rem;
}

/* Conversation List */
#conversation-list .conversation-item {
    background-color: transparent;
    color: var(--text-light);
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color var(--transition-speed) ease-in-out;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}

#conversation-list .conversation-item:hover {
    background-color: var(--hover-color);
}

#conversation-list .conversation-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

#conversation-list .conversation-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 0.5rem;
}

#conversation-list .conversation-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity var(--transition-speed) ease-in-out;
}

#conversation-list .conversation-item:hover .conversation-actions {
    opacity: 1;
}

#conversation-list .delete-icon,
#conversation-list .rename-icon {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color var(--transition-speed) ease-in-out;
}

#conversation-list .delete-icon:hover,
#conversation-list .rename-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Clear All Conversations Button */
#clear-all-conversations-btn {
    background: var(--primary-color);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed) ease-in-out;
    width: 100%;
}

#clear-all-conversations-btn:hover {
    background-color: darken(var(--primary-color), 10%);
}

#clear-all-conversations-btn i {
    margin-right: 0.5rem;
}

/* Toggle Sidebar Button */
#toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    transition: color var(--transition-speed) ease-in-out;
}

#toggle-sidebar:hover {
    color: var(--primary-color);
}

/* Message Input */
#message-input {
    min-height: 44px;
    max-height: 200px;
    border-radius: 20px;
    padding: 0.75rem;
    padding-right: 5.5rem;
    width: 100%;
    border: 1px solid var(--border-color);
    resize: none;
    transition: border-color var(--transition-speed) ease-in-out, height var(--transition-speed) ease-in-out;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Send and Clear Buttons */
#send-button, #clear-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 1.5rem;
    width: 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color var(--transition-speed) ease-in-out, transform var(--transition-speed) ease-in-out;
    margin-left: 0.1rem;
}

#send-button {
    background-color: var(--primary-color);
    color: var(--text-light);
}

#clear-button {
    background-color: var(--secondary-color);
    color: var(--text-light);
}

#send-button:hover, #clear-button:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 1rem;
    position: relative;
    animation: fadeIn 0.3s ease-in-out;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.user-message {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: var(--text-light);
}

.ai-message {
    align-self: flex-start;
    background-color: #ffffff;
    color: var(--text-color);
}

/* Message Actions */
.message-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity var(--transition-speed) ease-in-out;
}

.message:hover .message-actions {
    opacity: 1;
}

.delete-message,
.copy-message {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color var(--transition-speed) ease-in-out;
}

.user-message .delete-message,
.user-message .copy-message {
    color: var(--text-light);
}

.delete-message:hover,
.copy-message:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.user-message .delete-message:hover,
.user-message .copy-message:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Copy Code Button */
.copy-code-button {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 8px 12px;
    font-size: 0.8em;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-5px);
}

pre:hover .copy-code-button {
    opacity: 1;
    transform: translateY(0);
}

.copy-code-button:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.copy-code-button:active {
    transform: scale(0.95);
}

.copy-code-button::after {
    content: "Copy";
}

.copy-code-button.copied::after {
    content: "Copied!";
}

.copy-code-button.copied {
    background-color: #4CAF50;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    z-index: 1000;
}

/* Ensure buttons stay within textarea on smaller screens */
@media (max-width: 640px) {
    #message-input {
        padding-right: 5rem;
    }
    
    #send-button, #clear-button {
        width: 32px;
        height: 32px;
    }
}

#sidebar-collapse-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    display: none; /* Hidden by default */
}

@media (max-width: 768px) {
    #sidebar-collapse-btn {
        display: block; /* Visible on mobile */
    }
}