/* ========================================
   CSS Variables - GitHub-Inspired Theme
   ======================================== */
:root {
    /* GitHub Dark Theme Colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-overlay: #1c2128;
    
    /* Borders */
    --border-primary: #30363d;
    --border-secondary: #21262d;
    
    /* Text Colors */
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    
    /* Accent Colors */
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-purple: #bc8cff;
    --accent-orange: #f0883e;
    
    /* Glow Effects */
    --glow-blue: rgba(88, 166, 255, 0.4);
    --glow-purple: rgba(188, 140, 255, 0.4);
    --glow-green: rgba(63, 185, 80, 0.4);
    
    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ========================================
   Global Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========================================
   Particle Canvas Background
   ======================================== */
#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.6;
}

/* ========================================
   Container
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header
   ======================================== */
.header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    margin-bottom: 20px;
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.1);
    animation: slideDown 0.5s ease-out;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.back-btn:hover {
    background: var(--bg-overlay);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 0 15px var(--glow-blue);
    transform: scale(1.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 600;
}

.glow-text {
    color: var(--accent-blue);
    text-shadow: 0 0 10px var(--glow-blue);
    animation: pulse 2s ease-in-out infinite;
}

.beta-badge {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-green);
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid var(--accent-green);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.settings-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: var(--bg-overlay);
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px var(--glow-blue);
    transform: scale(1.05);
}

/* ========================================
   Settings Panel
   ======================================== */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
}

.settings-panel.active {
    right: 0;
}

.settings-content {
    padding: 24px;
}

.settings-content h2 {
    color: var(--accent-blue);
    margin-bottom: 24px;
    font-size: 20px;
    text-shadow: 0 0 10px var(--glow-blue);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.input-field {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--glow-blue);
}

.input-field::placeholder {
    color: var(--text-tertiary);
}

textarea.input-field {
    resize: vertical;
    min-height: 80px;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary {
    background: var(--accent-blue);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-blue);
    box-shadow: 0 0 20px var(--glow-blue);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
    background: var(--bg-overlay);
    border-color: var(--accent-blue);
}

/* ========================================
   Chat Container
   ======================================== */
.chat-container {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(88, 166, 255, 0.1);
    animation: fadeIn 0.5s ease-out;
}

/* ========================================
   Welcome Message
   ======================================== */
.welcome-message {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    animation: fadeIn 1s ease-out;
}

.welcome-icon {
    color: var(--accent-purple);
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.welcome-icon svg {
    filter: drop-shadow(0 0 15px var(--glow-purple));
}

.welcome-message h2 {
    font-size: 28px;
    color: var(--accent-blue);
    margin-bottom: 12px;
    text-shadow: 0 0 10px var(--glow-blue);
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 32px;
}

.quick-tips {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 24px;
    max-width: 500px;
    text-align: left;
}

.quick-tips h3 {
    color: var(--accent-green);
    font-size: 16px;
    margin-bottom: 12px;
}

.quick-tips ul {
    list-style: none;
}

.quick-tips li {
    color: var(--text-secondary);
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
}

.quick-tips li::before {
    content: '▹';
    position: absolute;
    left: 0;
    color: var(--accent-blue);
    font-size: 18px;
}

/* ========================================
   Messages Area
   ======================================== */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.messages::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

.message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
    max-width: 85%;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    box-shadow: 0 0 15px var(--glow-blue);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
    box-shadow: 0 0 15px var(--glow-green);
}

.message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    flex: 1;
}

.message.user .message-content {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent-blue);
}

.message-text {
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* Loading Animation */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: loadingDot 1.4s infinite ease-in-out;
    box-shadow: 0 0 8px var(--glow-blue);
}

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

/* ========================================
   Input Area
   ======================================== */
.input-container {
    padding: 20px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-primary);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 12px;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--glow-blue);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    background: var(--accent-blue);
    border: none;
    color: var(--bg-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-btn:hover {
    box-shadow: 0 0 20px var(--glow-blue);
    transform: scale(1.05);
}

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

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-tertiary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
}

.status-indicator.connected .status-dot {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--glow-green);
    animation: pulse 2s ease-in-out infinite;
}

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.clear-btn:hover {
    color: var(--accent-orange);
    background: rgba(240, 136, 62, 0.1);
}

/* ========================================
   Animations
   ======================================== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

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

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

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

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

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .settings-panel {
        width: 100%;
        right: -100%;
    }
    
    .message {
        max-width: 90%;
    }
    
    .welcome-message {
        padding: 20px;
    }
    
    .quick-tips {
        padding: 16px;
    }
}

/* ========================================
   Code Blocks (for AI responses)
   ======================================== */
pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
    font-size: 13px;
    color: var(--accent-purple);
}

