/* ===============================
   CHATGPT-STYLE CSS FOR YOUR STRUCTURE
   =============================== */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

:root {
    /* Light theme colors (ChatGPT style) */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #f4f4f4;
    --text-primary: #374151;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --accent-primary: #10a37f;
    --accent-hover: #0d8168;
    --user-message-bg: #f9f9f9;
    --assistant-message-bg: #ffffff;
    --hover-bg: #f3f4f6;
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius-sm: 0px;
    --radius-md: 0px;
    --radius-lg: 0px;
    --sidebar-width: 280px;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #1f2937;
    --bg-secondary: #374151;
    --bg-tertiary: #4b5563;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-light: #4b5563;
    --border-medium: #6b7280;
    --assistant-message-bg: #374151;
    --hover-bg: #4b5563;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===============================
   MAIN CONTAINER
   =============================== */

.chat-ai-botui {
    display: flex;
    height: 100vh;
    background-color: var(--bg-primary);
    font-family: inherit;
    position: relative;
}

/* ===============================
   SIDEBAR
   =============================== */

.conversations {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    z-index: 10;
}

.chat-ai-botui:not(.sidebar-open) .conversations {
    margin-left: calc(-1 * var(--sidebar-width));
}

/* New Conversation Button */
.new-conversation {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid var(--border-light);
    margin: 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
}

.new-conversation:hover {
    background-color: var(--hover-bg);
    transform: translateY(-1px);
}

.new-conversation i {
    font-size: 14px;
}

/* Conversations List */
.conversations .list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
}

.conversation-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease;
}

.conversation-wrapper:hover {
    background-color: var(--hover-bg);
}

.conversation-wrapper.selected {
    background-color: var(--accent-primary);
}

.conversation-wrapper.selected .conversation {
    color: white;
}

.conversation {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
    border-radius: var(--radius-sm);
}

.conversation i {
    font-size: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.delete-icon {
    padding: 8px;
    color: #ef4444;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0;
    font-size: 14px;
}

.conversation-wrapper:hover .delete-icon {
    opacity: 1;
}

.delete-icon:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* Sidebar Footer */
.conversations .footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-tertiary);
}

.close-sidebar {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: inline-block;
}

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

/* Open Sidebar Button */
.open-sidebar {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-light);
}

.chat-ai-botui.sidebar-open .open-sidebar {
    display: none;
}

.open-sidebar:hover {
    background-color: var(--hover-bg);
    transform: translateY(-1px);
}

/* ===============================
   MAIN CONTENT
   =============================== */

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    min-width: 0;
}

/* Conversation Header */
.conversation-title-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    background-color: var(--bg-primary);
}

.conversation-title-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.conversation-title-header h2 .edit {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    transition: color 0.2s ease;
}

.conversation-title-header h2 .edit:hover {
    color: var(--accent-primary);
}

/* ===============================
   CHAT INTERFACE
   =============================== */

.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* BotUI Container */
.botui-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    overflow: hidden;
}

.botui {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.botui-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    background-color: var(--bg-primary);
}

/* BotUI Messages */
.botui-message {
    margin-bottom: 20px;
    opacity: 0;
    animation: messageSlideIn 0.3s ease forwards;
}

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

.botui-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.botui-message-content.human {
    background-color: var(--user-message-bg);
    color: #000;
    margin-left: auto;
    border-bottom-right-radius: var(--radius-sm);
    float: left;
    border: 1px solid #000;
}

.botui-message-content:not(.human) {
    background-color: var(--assistant-message-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: var(--radius-sm);
}

/* Code blocks in messages */
.botui-message-content pre {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

.botui-message-content code {
    background-color: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

.botui-message-content pre code {
    background: transparent;
    padding: 0;
}

/* ===============================
   INPUT CONTAINER
   =============================== */

.chat-input-container {
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-primary);
    padding: 16px 24px 24px;
}

.input-wrapper {
    max-width: 768px;
    margin: 0 auto;
}

/* Image Preview */
.image-preview-container {
    margin-bottom: 12px;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-light);
}

.image-preview {
    max-width: 120px;
    max-height: 120px;
    display: block;
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: -13px;
    right: -25px;
    border: none;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    background: transparent;
}

.remove-image-btn:hover {
    transform: scale(1.1);
    background: transparent;
    color: red;
}

/* Input Controls */
.input-controls {
    display: flex;
    align-items: flex-end;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
}

.input-controls:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    margin-right: 8px;
}

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

.text-input-area {
    display: flex;
    align-items: flex-end;
    flex: 1;
    gap: 8px;
}

#chat-text-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.4;
    min-height: 24px;
    max-height: 120px;
    resize: none;
    font-family: inherit;
    padding: 4px 0;
}

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

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background-color: var(--text-muted);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

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

.send-btn:not(:disabled) {
    background-color: var(--accent-primary);
}

.send-btn:not(:disabled):hover {
    background-color: var(--accent-hover);
    transform: scale(1.05);
}

/* Upload Status */
.upload-status {
    font-size: 12px;
    margin-top: 8px;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.upload-status.success {
    color: var(--accent-primary);
    background-color: rgba(16, 163, 127, 0.1);
}

.upload-status.error {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.upload-status.uploading {
    color: var(--text-secondary);
}

/* ===============================
   RESPONSIVE DESIGN
   =============================== */

@media (max-width: 768px) {
    .chat-ai-botui {
        height: 100vh;
    }
    
    .conversations {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .chat-ai-botui.sidebar-open .conversations {
        left: 0;
    }
    
    .conversation-title-header {
        padding: 16px 20px;
    }
    
    .chat-input-container {
        padding: 12px 16px 16px;
    }
    
    .botui-messages-container {
        padding: 16px;
    }
    
    .botui-message-content {
        max-width: 95%;
        font-size: 14px;
    }
    
    #chat-text-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ===============================
   UTILITIES
   =============================== */

.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Scrollbar Styling */
.botui-messages-container::-webkit-scrollbar,
.conversations .list::-webkit-scrollbar {
    width: 6px;
}

.botui-messages-container::-webkit-scrollbar-track,
.conversations .list::-webkit-scrollbar-track {
    background: transparent;
}

.botui-messages-container::-webkit-scrollbar-thumb,
.conversations .list::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.botui-messages-container::-webkit-scrollbar-thumb:hover,
.conversations .list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Focus styles for accessibility */
.file-upload-btn:focus,
.send-btn:focus,
#chat-text-input:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
.message-actions{
    display: none;
}