/* ==========================================================================
   CSS VARIABLES & RESET
   ========================================================================== */
:root {
    --bg-dark: #05050A;
    --primary: #8B5CF6;
    --primary-light: #A855F7;
    --primary-dark: #6D28D9;
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(139, 92, 246, 0.2);
    --ai-bubble-bg: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(109, 40, 217, 0.15));
    --user-bubble-bg: #05050A;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ==========================================================================
   BACKGROUND & EFFECTS
   ========================================================================== */
.background-aurora {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
                radial-gradient(circle at 80% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 30%);
    animation: rotateAurora 30s linear infinite;
    z-index: -3;
    pointer-events: none;
}

.background-noise {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    z-index: -2;
    pointer-events: none;
}

#star-canvas {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}

.cursor-glow {
    position: fixed;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 9999;
    mix-blend-mode: screen;
    transition: opacity 0.3s;
}

@keyframes rotateAurora {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: 280px;
    background: rgba(5, 5, 10, 0.7);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-history-item {
    padding: 12px 15px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
    border: 1px solid transparent;
}

.chat-history-item:hover {
    background: var(--glass-bg);
    color: var(--text-main);
}

.chat-history-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.sidebar-footer {
    padding: 20px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--glass-border);
}

.btn-secondary {
    flex: 1;
    padding: 10px;
    background: var(--glass-bg);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-secondary:hover {
    background: rgba(139, 92, 246, 0.2);
    color: var(--text-main);
}

/* ==========================================================================
   MAIN CONTENT & NAVBAR
   ========================================================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: calc(100% - 280px);
}

.navbar {
    height: 70px;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(5, 5, 10, 0.5);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand .subtitle {
    font-size: 0.7rem;
    color: var(--primary-light);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 8px;
    border-radius: 8px;
}

.icon-btn:hover {
    color: var(--text-main);
    background: var(--glass-bg);
}

/* ==========================================================================
   CHAT AREA
   ========================================================================== */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.welcome-screen {
    margin: auto;
    text-align: center;
    animation: fadeIn 1s ease-out;
}

.glow-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 20px var(--primary));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

/* Chat Bubbles */
.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes slideUp {
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
}

.message.ai {
    align-self: flex-start;
}

.bubble {
    padding: 15px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .bubble {
    background: var(--user-bubble-bg);
    border: 1px solid var(--primary);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.message.ai .bubble {
    background: var(--ai-bubble-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.1);
}

/* Formatting inside chat */
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: var(--primary-light); }
.bubble code {
    background: rgba(0,0,0,0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #f87171;
}

/* Code Blocks */
.code-wrapper {
    position: relative;
    margin: 15px 0;
    border-radius: 12px;
    overflow: hidden;
    background: #1e1e24;
    border: 1px solid var(--glass-border);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: rgba(0,0,0,0.3);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.copy-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.copy-btn:hover { color: var(--text-main); }

.code-wrapper pre {
    margin: 0;
    padding: 15px;
    overflow-x: auto;
}
.code-wrapper pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.85rem;
}

/* Thinking Animation */
.thinking-dots {
    display: flex;
    gap: 5px;
    padding: 5px;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); box-shadow: 0 0 10px var(--primary-light); }
}

/* ==========================================================================
   INPUT AREA & FOOTER
   ========================================================================== */
.input-container {
    padding: 20px;
    background: linear-gradient(to top, rgba(5,5,10,0.9) 50%, transparent);
}

.input-wrapper {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 10px 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    padding: 8px 0;
    resize: none;
    max-height: 200px;
    outline: none;
    line-height: 1.5;
}

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

.send-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    margin-left: 10px;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--primary-light);
}

.send-btn:disabled {
    background: #333;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.footer {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 15px;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   SCROLLBAR
   ========================================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.6); }

/* ==========================================================================
   RESPONSIVE (MOBILE)
   ========================================================================== */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        box-shadow: 5px 0 25px rgba(0,0,0,0.5);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .main-content {
        width: 100%;
    }
    
    .mobile-only { display: block; }
    
    .message { max-width: 95%; }
    
    .cursor-glow { display: none; } /* Disable custom cursor on mobile */
}
