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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --user-bg: #2563eb;
    --bot-bg: #f1f5f9;
    --error: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--surface);
    box-shadow: var(--shadow);
}

/* HEADER */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    z-index: 10;
}

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

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

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: var(--shadow-sm);
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.logo-text p {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: var(--bot-bg);
    color: var(--error);
    border-color: var(--error);
}

/* CHAT */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

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

.messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* MESSAGE */
.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

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

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--bot-bg);
}

.message.user .avatar {
    background: var(--primary-light);
}

.bubble {
    background: var(--bot-bg);
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    border-top-left-radius: 4px;
    max-width: calc(100% - 50px);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .bubble {
    background: var(--user-bg);
    color: white;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: 4px;
}

.bubble p {
    margin-bottom: 8px;
}

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

.bubble ul, .bubble ol {
    margin: 8px 0 8px 20px;
}

.bubble li {
    margin-bottom: 4px;
}

.bubble strong {
    font-weight: 600;
}

.bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, monospace;
    font-size: 0.9em;
}

.message.user .bubble code {
    background: rgba(255, 255, 255, 0.15);
}

/* SOURCES */
.sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 12px;
}

.sources-title {
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.source-item {
    display: inline-block;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 12px;
    margin: 2px 4px 2px 0;
    color: var(--text-light);
    font-size: 11px;
}

.response-time {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* SUGGESTIONS */
.suggestions {
    padding: 0 24px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.suggestions.hidden {
    display: none;
}

/* INPUT */
.input-area {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    background: var(--surface);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--bot-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

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

#questionInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    padding: 6px 0;
    max-height: 150px;
}

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

.send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.disclaimer {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* TYPING */
.typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* RESPONSIVE */
@media (max-width: 640px) {
    .messages { padding: 16px; }
    .input-area { padding: 12px 16px; }
    .header { padding: 12px 16px; }
    .logo-text h1 { font-size: 16px; }
    .logo-text p { font-size: 11px; }
    .suggestions { padding: 0 16px 8px; }
}

.embed-mode {
    height: 100%;
    max-width: 100%;
}
