/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --error: #dc2626;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Nav === */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}
.nav-links a:hover { color: var(--primary); }

/* === Container === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* === Form Card === */
.form-card {
    max-width: 560px;
    margin: 2rem auto;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2.5rem;
    border: 1px solid var(--border);
}
.form-card h1 { margin-bottom: 0.5rem; font-size: 1.5rem; }
.subtitle { color: var(--text-muted); margin-bottom: 2rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}
.form-group input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.checkbox-group label {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
}
.checkbox-group input[type="checkbox"] { margin-top: 0.2rem; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }

/* === Error === */
.error-message {
    background: #fef2f2;
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* === Chat Layout === */
.chat-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    height: calc(100vh - 160px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.chat-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.chat-header h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }

.progress-bar-container {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}
.progress-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: inline-block;
}

/* === Messages === */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.message.user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 2px;
}
.message.assistant {
    align-self: flex-start;
    background: #f1f5f9;
    color: var(--text);
    border-bottom-left-radius: 2px;
}
.message.assistant strong { font-weight: 600; }

/* === Chat Input === */
.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}
.chat-input-area textarea {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-family: inherit;
    resize: none;
}
.chat-input-area textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

/* === Artifacts Panel === */
.artifacts-panel {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    overflow-y: auto;
}
.artifacts-panel h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.artifacts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.empty-state { color: var(--text-muted); font-size: 0.85rem; }

.artifact-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}
.artifact-card h4 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.artifact-type {
    display: inline-block;
    font-size: 0.72rem;
    background: var(--primary);
    color: #fff;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}
.artifact-card pre {
    font-size: 0.75rem;
    background: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    max-height: 200px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.export-buttons { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* === Artifacts Page === */
.artifacts-page { max-width: 900px; margin: 0 auto; }
.artifacts-page code {
    background: #f1f5f9;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 1rem 1.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* === Loading indicator === */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* === Responsive === */
@media (max-width: 768px) {
    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .artifacts-panel { max-height: 300px; }
    .form-row { flex-direction: column; gap: 0; }
}
