//public/ai.css
/* --- RESET & BASICS --- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body { 
    margin: 0; padding: 0; 
    height: 100dvh; 
    width: 100vw;
    overflow: hidden; 
    background: #0a0e27; 
    font-family: system-ui, -apple-system, sans-serif; 
    color: white;
    display: flex;
    flex-direction: column;
}

/* Background Animation */
.bg-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; overflow: hidden; pointer-events: none;
}
/* Blob styles are inherited from style.css usually, but we keep basics here just in case */

/* --- MAIN LAYOUT STRUCTURE --- */
.app-layout {
    flex: 1;
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* --- MOBILE HEADER (Fixed Visibility) --- */
.mobile-header {
    display: none; 
    height: 60px;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(10, 14, 39, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0; 
    z-index: 50;
    padding-top: env(safe-area-inset-top); 
    box-sizing: content-box; 
}

.icon-btn {
    background: transparent; border: none; color: white; font-size: 24px; cursor: pointer;
}

/* --- SIDEBAR --- */
.sidebar-panel {
    width: 300px;
    height: 100%;
    background: rgba(10, 14, 39, 0.6);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-content { padding: 20px; height: 100%; display: flex; flex-direction: column; }
.sidebar-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.sidebar-title { font-size: 20px; font-weight: 800; color: #a6c1ee; }
.close-btn-mobile { display: none; background: none; border: none; color: white; font-size: 28px; }

.nav-item {
    width: 100%; margin-bottom: 10px; text-align: left; padding: 12px 15px; font-size: 13px;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    color: white; border-radius: 12px; cursor: pointer; transition: 0.2s;
}
.btn-primary { background: linear-gradient(135deg, rgba(79, 172, 254, 0.2), rgba(0, 242, 254, 0.2)); border-color: #4facfe; }

.history-scroll { flex: 1; overflow-y: auto; margin: 15px 0; padding-right: 5px; }
.history-item {
    padding: 12px; border-radius: 10px; font-size: 13px; color: rgba(255,255,255,0.7);
    margin-bottom: 5px; cursor: pointer; background: rgba(0,0,0,0.2); 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item.active { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); }

.user-profile-box { padding: 15px; background: rgba(0,0,0,0.4); border-radius: 15px; border: 1px solid rgba(255,255,255,0.1); }

/* --- CHAT AREA --- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden; 
}

.chat-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    padding-bottom: 10px; 
}

/* --- INPUT SECTION --- */
.input-container {
    flex-shrink: 0;
    width: 100%;
    min-height: 90px;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.15);
    display: flex; 
    gap: 12px; 
    align-items: center; 
    padding: 15px 20px;
    padding-bottom: max(30px, calc(20px + env(safe-area-inset-bottom))); 
}

#prompt-input {
    flex: 1;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 25px;
    padding: 12px 20px; 
    color: white; font-size: 16px; 
    max-height: 120px; outline: none; resize: none;
    line-height: 1.4;
}

#send-btn {
    width: 50px; height: 50px;
    border-radius: 50%; border: none;
    background: linear-gradient(135deg, #a6c1ee, #fbc2eb);
    color: #0a0e27; font-size: 22px; cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}

/* --- MESSAGES --- */
.msg-row { display: flex; width: 100%; animation: fadeIn 0.3s ease; }
.msg-row.user { justify-content: flex-end; }
.msg-row.ai { justify-content: flex-start; }

.bubble {
    max-width: 85%; padding: 12px 18px; border-radius: 18px;
    font-size: 15px; line-height: 1.5; word-wrap: break-word;
}
.user .bubble { background: linear-gradient(135deg, #4facfe, #00f2fe); color: #000; border-bottom-right-radius: 4px; }
.ai .bubble { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); color: #fff; border-bottom-left-radius: 4px; }
.system-msg { text-align: center; font-size: 11px; color: #a6c1ee; opacity: 0.7; margin: 20px 0; }

/* ERROR BUBBLE STYLE (NEW) */
.bubble.error-bubble {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: #ffcccb;
}

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

/* --- MARKDOWN STYLES --- */
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: #fff; font-weight: 700; }
.bubble code { background: rgba(0,0,0,0.3); padding: 2px 4px; border-radius: 4px; font-family: monospace; color: #a6c1ee; }
.bubble pre { background: rgba(0,0,0,0.5); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
.bubble ul, .bubble ol { padding-left: 20px; margin-bottom: 10px; }
.bubble li { margin-bottom: 5px; }

/* --- COPY BUTTONS --- */
.bubble { position: relative; }

/* Code Block Copy Button */
.code-wrapper { position: relative; margin-top: 10px; }
.copy-code-btn {
    position: absolute; top: 5px; right: 5px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #a6c1ee; font-size: 10px; padding: 4px 8px;
    border-radius: 6px; cursor: pointer; z-index: 5; transition: 0.2s;
}
.copy-code-btn:hover { background: rgba(255, 255, 255, 0.2); color: white; }

/* Full Response Copy Button */
.msg-footer {
    display: flex; justify-content: flex-end; margin-top: 5px;
    opacity: 0; transition: opacity 0.3s;
}
.msg-row:hover .msg-footer { opacity: 1; } 
.copy-full-btn {
    background: none; border: none; color: rgba(255, 255, 255, 0.4);
    font-size: 11px; cursor: pointer; display: flex; align-items: center; gap: 4px;
}
.copy-full-btn:hover { color: #fbc2eb; }

/* --- MODEL SWITCHER --- */
.model-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.model-btn {
    padding: 12px; background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px;
    text-align: left; cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden;
}
.model-btn:hover { background: rgba(255, 255, 255, 0.08); }
.model-btn.active {
    background: linear-gradient(90deg, rgba(79, 172, 254, 0.1), rgba(0, 242, 254, 0.1));
    border-color: #4facfe; box-shadow: 0 0 15px rgba(79, 172, 254, 0.15);
}
.model-name { font-size: 13px; font-weight: 700; color: #fff; display: block; margin-bottom: 2px; }
.model-tag { font-size: 10px; color: rgba(255, 255, 255, 0.5); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- CONTEXT & PROJECTS --- */
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: rgba(255,255,255,0.5); margin: 15px 0 5px 0;
    text-transform: uppercase; letter-spacing: 1px;
}
.add-mini-btn { background: none; border: none; color: #4facfe; cursor: pointer; font-weight: bold; font-size: 14px; }
.project-item {
    padding: 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05); margin-bottom: 5px;
    cursor: pointer; transition: 0.2s; font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.project-item.active { background: rgba(79, 172, 254, 0.15); border-color: #4facfe; color: white; }

.context-tag {
    display: inline-flex; align-items: center;
    background: rgba(251, 194, 235, 0.15); border: 1px solid rgba(251, 194, 235, 0.3);
    color: #fbc2eb; font-size: 10px; padding: 2px 8px; border-radius: 10px;
    margin-right: 5px; margin-bottom: 5px;
}
.context-area { padding: 0 20px; display: flex; flex-wrap: wrap; gap: 5px; }

/* --- MODALS --- */
.ai-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(5px);
}
.ai-modal-box {
    background: #0f142e; border: 1px solid rgba(255,255,255,0.1);
    padding: 20px; border-radius: 15px; width: 90%; max-width: 400px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .mobile-header { display: flex; }
    .sidebar-panel {
        position: fixed; top: 0; left: 0; 
        height: 100%; width: 85%; max-width: 320px;
        background: #0a0e27;
        transform: translateX(-100%);
        box-shadow: 10px 0 50px rgba(0,0,0,0.8);
        border-right: 1px solid rgba(255,255,255,0.2);
    }
    .sidebar-panel.active { transform: translateX(0); }
    .close-btn-mobile { display: block; }
}
