:root {
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #0ea5e9;
    --primary-glow: rgba(14, 165, 233, 0.5);
    --secondary: #8b5cf6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --user-msg: rgba(14, 165, 233, 0.15);
    --ai-msg: rgba(30, 41, 59, 0.5);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Ambient Background Glow */
.background-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    top: -200px;
    left: -200px;
    filter: blur(80px);
    z-index: 0;
    animation: float 10s infinite alternate ease-in-out;
}

.background-glow.secondary {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, transparent 70%);
    bottom: -200px;
    right: -200px;
    top: auto;
    left: auto;
    animation: float 15s infinite alternate-reverse ease-in-out;
}

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

/* Main App Container */
.app-container {
    width: 90%;
    max-width: 900px;
    height: 90vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
}

/* Header */
header {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.4);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.glow-icon {
    font-size: 1.5rem;
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

h1 span {
    color: var(--primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.glass-select {
    background: rgba(15, 23, 42, 0.6);
    color: var(--primary);
    border: 1px solid var(--primary-glow);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.glass-select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.pulse {
    width: 8px;
    height: 8px;
    background-color: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 10px #4ade80;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Chat Area */
#chat-container {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

#chat-container::-webkit-scrollbar {
    width: 6px;
}

#chat-container::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

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

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

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.system .avatar, .ai .avatar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.user .avatar {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.content {
    padding: 16px 20px;
    border-radius: 16px;
    font-size: 1.05rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.system .content, .ai .content {
    background: var(--ai-msg);
    border: 1px solid var(--glass-border);
    border-top-left-radius: 4px;
}

.user .content {
    background: var(--user-msg);
    border: 1px solid rgba(14, 165, 233, 0.3);
    border-top-right-radius: 4px;
}

/* Markdown Styles inside content */
.content p {
    margin-bottom: 10px;
}
.content p:last-child {
    margin-bottom: 0;
}
.content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid var(--glass-border);
}
.content code {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e2e8f0;
}
.content pre code {
    background: transparent;
    padding: 0;
}
.content ul, .content ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

/* Thinking State */
.thinking-text {
    color: var(--primary);
    font-style: italic;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Blinking inline cursor for streaming */
.inline-cursor {
    color: var(--primary);
    animation: blink-cursor 1s step-start infinite;
    margin-left: 2px;
    display: inline-block;
}

@keyframes blink-cursor {
    50% { opacity: 0; }
}

/* Input Area */
.input-area {
    padding: 24px 30px;
    background: rgba(15, 23, 42, 0.6);
    border-top: 1px solid var(--glass-border);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 8px 16px;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.2);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.05rem;
    padding: 12px 0;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
}

textarea::placeholder {
    color: var(--text-muted);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    align-self: flex-end;
    margin-bottom: 4px;
}

button:hover {
    background: #0284c7;
    transform: scale(1.05);
}

button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

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

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

.modal-header {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.modal-header i {
    font-size: 2.5rem;
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 25px;
    font-size: 0.95rem;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1rem;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.primary-btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0;
    height: auto;
}

.error-msg {
    color: #ef4444;
    margin-top: 15px;
    font-size: 0.85rem;
    min-height: 20px;
}
