/* ParaGuru — Aviometrics Design System */

:root {
    --cyan: #00B8CC;
    --cyan-dark: #008A99;
    --cyan-light: #E0F7FA;
    --ink: #1A2332;
    --ink-mid: #374151;
    --muted: #6B7280;
    --surface: #F8FAFB;
    --border: #E5E7EB;
    --white: #FFFFFF;
    --danger: #EF4444;
    --success: #10B981;
}

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

html, body {
    height: 100%;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: var(--surface);
}

body {
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--ink);
    color: var(--white);
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.brand {
    font-family: 'Exo 2', sans-serif;
    font-weight: 800;
    font-size: 1.8rem;
    color: var(--cyan);
    letter-spacing: -0.5px;
}

.subtitle {
    font-family: 'Exo 2', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

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

/* Messages */
.message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.assistant-message {
    align-self: flex-start;
}

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

.message-content {
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    line-height: 1.55;
    font-size: 0.93rem;
}

.assistant-message .message-content {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px 12px 12px 2px;
}

.user-message .message-content {
    background: var(--cyan);
    color: var(--white);
    border-radius: 12px 12px 2px 12px;
}

.message-content p {
    margin-bottom: 0.5rem;
}

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

.message-content strong {
    font-weight: 700;
}

.hint {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

/* Answer body markdown rendering */
.answer-body h3 {
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
    margin: 1rem 0 0.4rem 0;
}

.answer-body h4 {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--ink-mid);
    margin: 0.8rem 0 0.3rem 0;
}

.answer-body ul {
    margin: 0.3rem 0 0.5rem 1.2rem;
    padding: 0;
}

.answer-body li {
    margin-bottom: 0.2rem;
    line-height: 1.5;
}

.answer-body p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Sources */
.sources {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.sources-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.source-item {
    font-size: 0.78rem;
    color: var(--muted);
    padding: 0.15rem 0;
}

.source-item .domain-badge {
    display: inline-block;
    background: var(--cyan-light);
    color: var(--cyan-dark);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 0.3rem;
}

.relevance {
    color: var(--success);
    font-weight: 500;
}

/* Loading indicator */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 0.85rem 1.1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px 12px 12px 2px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cyan);
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--white);
    flex-shrink: 0;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.93rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0, 184, 204, 0.1);
}

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

.send-button:hover {
    background: var(--cyan-dark);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
.footer {
    text-align: center;
    padding: 0.75rem;
    font-size: 0.78rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: var(--white);
    flex-shrink: 0;
}

.footer a {
    color: var(--cyan-dark);
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 640px) {
    .header { padding: 0.75rem 1rem; }
    .brand { font-size: 1.4rem; }
    .chat-messages { padding: 1rem; }
    .chat-input-area { padding: 0.75rem 1rem; }
    .message { max-width: 92%; }
}

/* Admin Dashboard Styles */
.admin-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-family: 'Exo 2', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--cyan);
    margin-top: 0.3rem;
}

.section-title {
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ink);
    margin-bottom: 1rem;
}

.domain-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.domain-table th, .domain-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.domain-table th {
    background: var(--surface);
    font-weight: 500;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bot-run {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
}

.bot-run .status {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.bot-run .status.completed {
    background: #D1FAE5;
    color: #065F46;
}

.bot-run .status.running {
    background: #FEF3C7;
    color: #92400E;
}

.bot-run .status.failed {
    background: #FEE2E2;
    color: #991B1B;
}
