/* === kCube Medical AI — Healthcare-Professional Styling === */

:root {
    --blue-dark: #0d2137;
    --blue-mid: #1a3a5c;
    --blue-light: #2c5282;
    --teal: #2b968c;
    --teal-light: #3bbfb2;
    --bg: #f0f4f8;
    --surface: #ffffff;
    --text: #1a202c;
    --text-muted: #64748b;
    --user-bubble: #1a3a5c;
    --user-text: #ffffff;
    --assistant-bubble: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --radius: 12px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app {
    max-width: 900px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* — Header — */
header {
    background: linear-gradient(135deg, var(--blue-dark), var(--blue-mid));
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    height: 40px;
    width: auto;
    background: #ffffff;
    padding: 4px 10px;
    border-radius: 6px;
}

.brand-text h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand .accent {
    color: var(--teal-light);
}

.tagline {
    font-size: 0.8rem;
    opacity: 0.75;
    margin-top: 2px;
}

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

.controls label {
    font-size: 0.8rem;
    opacity: 0.8;
}

#model-select {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

#model-select option {
    background: var(--blue-dark);
    color: #fff;
}

/* — Chat Area — */
main {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    max-width: 80%;
    animation: fadeIn 0.2s ease;
}

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

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

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

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.55;
    font-size: 0.95rem;
    box-shadow: var(--shadow);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .bubble {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background: var(--assistant-bubble);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Markdown-like styling inside bubbles */
.bubble p { margin: 0.5em 0; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 600; }
.bubble em { font-style: italic; }
.bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}
.bubble pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.85em;
}
.bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.bubble ul, .bubble ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}
.bubble li { margin: 0.25em 0; }
.bubble h1, .bubble h2, .bubble h3 {
    margin: 0.6em 0 0.3em;
    font-weight: 600;
}
.bubble h1 { font-size: 1.15em; }
.bubble h2 { font-size: 1.05em; }
.bubble h3 { font-size: 1em; }

/* — Typing Indicator — */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--teal);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* — Footer / Input — */
footer {
    padding: 12px 24px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

#chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#user-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.45;
    resize: none;
    outline: none;
    max-height: 150px;
    overflow-y: auto;
    transition: border-color 0.15s;
}

#user-input:focus {
    border-color: var(--teal);
}

#send-btn {
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: 10px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

#send-btn:hover {
    background: var(--teal-light);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.disclaimer {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
    line-height: 1.4;
}

/* — Error message — */
.bubble.error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* — Responsive — */
@media (max-width: 640px) {
    header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .brand { justify-content: center; }
    .logo { height: 32px; }
    .message { max-width: 90%; }
    main { padding: 14px 12px; }
    footer { padding: 10px 12px 14px; }
}
