@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    
    /* Sleek Dark Mode Palette with Cyan/Indigo Revision Accents */
    --bg-base: #080d1a;
    --bg-surface: rgba(15, 23, 42, 0.7);
    --bg-surface-elevated: rgba(30, 41, 59, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Branding & Accent Colors */
    --accent-cyan: #06b6d4;
    --accent-indigo: #6366f1;
    --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
    
    /* Status Colors */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    
    /* Transitions & Shadows */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 1px 1px 0 rgba(255, 255, 255, 0.05) inset;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1.5rem;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 90vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.system-status {
    display: flex;
    gap: 1rem;
}

.dashboard-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    margin-bottom: 0.75rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.dashboard-link:hover,
.dashboard-link:focus-visible {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
    outline: none;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--status-warning);
    box-shadow: 0 0 10px var(--status-warning);
}

.status-indicator.connected {
    background-color: var(--status-success);
    box-shadow: 0 0 10px var(--status-success);
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.chat-container {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-history {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-history::-webkit-scrollbar {
    width: 8px;
}
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.message {
    display: flex;
    max-width: 80%;
}

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

.message.system-msg {
    align-self: flex-start;
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-msg .message-content {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 2px;
}

.system-msg .message-content {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

/* Markdown styling */
.system-msg .message-content p { margin-bottom: 0.75rem; }
.system-msg .message-content p:last-child { margin-bottom: 0; }
.system-msg .message-content ul, .system-msg .message-content ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.system-msg .message-content strong { color: #38bdf8; }
.system-msg .message-content code { background: rgba(0,0,0,0.3); padding: 0.2rem 0.4rem; border-radius: 4px; }

/* ANIMATED FLASHING & MOVING THINKING INDICATOR */
.processing-indicator {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 1.5rem 0;
    padding: 0.8rem 1.1rem;
    border: 1px solid rgba(6, 182, 212, 0.4);
    border-radius: 12px;
    background: rgba(6, 182, 212, 0.1);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.25);
    animation: indicator-pulse-border 2s ease-in-out infinite;
}

.processing-indicator[hidden] { display: none; }

.thinking-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.thinking-pulse-dot {
    width: 0.75rem;
    height: 0.75rem;
    flex: 0 0 0.75rem;
    border-radius: 50%;
    background: #06b6d4;
    box-shadow: 0 0 12px #06b6d4;
    animation: dot-pulsate 1s ease-in-out infinite alternate;
}

.flashing-text {
    font-weight: 500;
    letter-spacing: 0.01em;
    animation: text-flash 1.5s ease-in-out infinite;
}

.thinking-progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.thinking-progress-bar {
    width: 45%;
    height: 100%;
    background: linear-gradient(90deg, #06b6d4 0%, #6366f1 50%, #38bdf8 100%);
    border-radius: 2px;
    position: absolute;
    top: 0;
    left: -45%;
    box-shadow: 0 0 8px #06b6d4;
    animation: moving-bar 1.5s ease-in-out infinite;
}

/* KEYFRAME ANIMATIONS FOR FLASHING/MOVING INDICATOR */
@keyframes dot-pulsate {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
        box-shadow: 0 0 4px #06b6d4;
    }
    100% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 14px #06b6d4, 0 0 20px #6366f1;
    }
}

@keyframes text-flash {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(6, 182, 212, 0.5); }
    50% { opacity: 0.45; text-shadow: none; }
}

@keyframes moving-bar {
    0% { left: -45%; }
    100% { left: 100%; }
}

@keyframes indicator-pulse-border {
    0%, 100% { border-color: rgba(6, 182, 212, 0.4); box-shadow: 0 0 15px rgba(6, 182, 212, 0.2); }
    50% { border-color: rgba(99, 102, 241, 0.7); box-shadow: 0 0 25px rgba(99, 102, 241, 0.4); }
}

.chat-input-area {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

textarea {
    flex-grow: 1;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 1rem;
    font-size: 1rem;
    font-family: var(--font-primary);
    transition: var(--transition-smooth);
    resize: none;
}

textarea:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
    background-color: rgba(255, 255, 255, 0.05);
    outline: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-primary);
    padding: 0 1rem;
}

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

.privacy-notice {
    padding: 0.5rem 1.5rem 1rem 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.tip-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}
