:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --user-msg: #6366f1;
    --bot-msg: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-container {
    width: 95%;
    max-width: 900px;
    height: 85vh;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

#chat-history::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.message {
    max-width: 80%;
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out;
}

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

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

.user {
    align-self: flex-end;
    background: var(--user-msg);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot {
    align-self: flex-start;
    background: var(--bot-msg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}

/* Markdown Styling */
.bot p {
    margin-bottom: 12px;
}

.bot p:last-child {
    margin-bottom: 0;
}

.bot code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.bot pre {
    background: rgba(0, 0, 0, 0.4) !important;
    padding: 15px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--glass-border);
}

.bot pre code {
    background: transparent;
    padding: 0;
}

.bot ul,
.bot ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.bot li {
    margin-bottom: 5px;
}

.generated-images {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 15px;
}

.generated-image {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: transform 0.2s;
}

.generated-image:hover {
    transform: scale(1.02);
}

.message-files {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-style: italic;
}

.file-preview-container {
    display: none;
    padding: 10px 30px;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--glass-border);
}

.file-tag {
    background: var(--primary);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-tag button {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    color: white;
    opacity: 0.7;
    cursor: pointer;
}

.file-tag button:hover {
    opacity: 1;
    transform: none;
}

.controls-wrapper {
    padding: 24px 30px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--glass-border);
}

.controls {
    display: flex;
    gap: 12px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    font-size: 1.2rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

select,
input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 18px;
    border-radius: 12px;
    outline: none;
    transition: all 0.2s;
}

select:focus,
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

input {
    flex-grow: 1;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.model-selector-container {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

select {
    font-size: 0.85rem;
    padding: 6px 12px;
}