/* DoctorFollow AI - Professional Medical Assistant Styles */

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #6d28d9;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --sidebar-width: 280px;
    --references-width: 320px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Login Screen */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1e293b 100%);
}

.login-container {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 1rem;
    color: var(--text-primary);
}

.login-logo p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.version-badge {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form label {
    text-align: left;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.login-form input {
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1.25rem;
    text-align: center;
    letter-spacing: 0.5rem;
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-form button {
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-form button:hover {
    background: var(--primary-dark);
}

.login-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.login-error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 1rem;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logo span {
    font-size: 1.125rem;
    font-weight: 600;
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: var(--primary-dark);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.history-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
}

.chat-history-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: background 0.2s;
}

.chat-history-item:hover {
    background: var(--bg-input);
}

.chat-history-item.active {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid var(--primary);
}

.chat-history-item h4 {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details span:first-child {
    font-weight: 500;
    font-size: 0.875rem;
}

.user-id {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.toggle-sidebar:hover {
    background: var(--bg-input);
}

.chat-header h1 {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.connected {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.welcome-message {
    max-width: 600px;
    margin: 3rem auto;
    text-align: center;
}

.welcome-icon {
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.welcome-message h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.welcome-message > p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.example-questions {
    text-align: left;
}

.example-questions > p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.example-btn {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.example-btn:hover {
    background: var(--bg-input);
    border-color: var(--primary);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

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

.message.assistant .message-avatar {
    background: var(--secondary);
}

.message-content {
    flex: 1;
    max-width: calc(100% - 52px);
}

.message.user .message-content {
    text-align: right;
}

.message-bubble {
    display: inline-block;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    max-width: 100%;
    text-align: left;
}

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

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

.message-bubble p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

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

/* References in message */
.message-references {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.message-references h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.reference-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.reference-item:hover {
    background: var(--bg-dark);
}

.reference-number {
    background: var(--primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.reference-text {
    flex: 1;
    color: var(--text-secondary);
}

.reference-text strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.25rem;
}

/* Message metadata */
.message-meta {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.input-container {
    display: flex;
    gap: 0.75rem;
    max-width: 900px;
    margin: 0 auto;
}

.input-container textarea {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    resize: none;
    min-height: 48px;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
}

.input-container textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.input-container textarea::placeholder {
    color: var(--text-muted);
}

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

.send-btn:hover {
    background: var(--primary-dark);
}

.send-btn:disabled {
    background: var(--bg-input);
    cursor: not-allowed;
}

/* Mode Selector Dropdown */
.mode-dropdown {
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
    flex-shrink: 0;
    min-width: 180px;
}

.mode-dropdown:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

.mode-dropdown:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* References Panel */
.references-panel {
    width: var(--references-width);
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: none;
    flex-direction: column;
}

.references-panel.open {
    display: flex;
}

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

.references-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.close-references {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

.references-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.reference-card {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.reference-card h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reference-card h4 span {
    background: var(--primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.reference-card .page-info {
    font-size: 0.75rem;
    color: var(--primary-light);
    margin-bottom: 0.5rem;
}

.reference-card .excerpt {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 100;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

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

/* V2 Visuals - Figures and Tables */
.message-visuals {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.visual-item {
    background: var(--bg-input);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.visual-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
}

.visual-type-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.figure-badge {
    background: rgba(59, 130, 246, 0.3);
    color: var(--primary-light);
}

.table-badge {
    background: rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.visual-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}

.visual-content {
    padding: 1rem;
}

.visual-content img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.2s;
}

.visual-content img:hover {
    transform: scale(1.02);
}

.visual-meta {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.1);
}

.visual-explanation {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: rgba(59, 130, 246, 0.05);
    border-top: 1px solid var(--border);
    line-height: 1.5;
}

.visual-error {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.table-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.table-link:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Rendered table styles */
.table-container {
    overflow-x: auto;
    max-width: 100%;
}

.rendered-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--bg-main);
    border-radius: 6px;
    overflow: hidden;
}

.rendered-table th,
.rendered-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid var(--border);
    vertical-align: top;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rendered-table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.rendered-table tbody tr:nth-child(even) {
    background: rgba(59, 130, 246, 0.05);
}

.rendered-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
}

.rendered-table .more-rows {
    background: var(--bg-card);
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.table-error {
    padding: 1rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.more-visuals-indicator {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
}

/* Reference link in citations */
.ref-link {
    display: block;
    margin-top: 0.25rem;
    color: var(--primary-light);
    font-size: 0.7rem;
    text-decoration: none;
}

.ref-link:hover {
    text-decoration: underline;
}

.doc-link-btn {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.doc-link-btn:hover {
    background: var(--primary-dark);
}

/* Query type badge */
.query-type-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.query-type-badge.simple {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.query-type-badge.complex {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

/* Visual Modal for enlarged images */
.visual-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.visual-modal.open {
    display: flex;
}

.visual-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.visual-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    background: var(--bg-dark);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}

.visual-modal-close:hover {
    background: var(--error);
}

.visual-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}

.visual-modal-content p {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    background: var(--bg-dark);
}

/* Streaming Status */
.streaming-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.5rem 0;
}

.streaming-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

.streaming-content {
    min-height: 1.5rem;
}

.streaming-content .error {
    color: var(--error);
}

/* V3 Multi-Agent Specific Styles */

/* Follow-up Questions */
.followup-questions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.followup-questions h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.followup-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.followup-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.followup-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Language and Intent Badges */
.lang-badge,
.intent-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.lang-badge {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.intent-badge {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-light);
}

/* Safety Warnings */
.safety-warning {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    border-radius: 8px;
    color: var(--warning);
    font-size: 0.875rem;
}

.safety-warning.blocked {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
    color: var(--error);
}

/* Journal info in references */
.journal-info {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.section-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 50;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .references-panel {
        position: fixed;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 50;
    }

    .followup-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
}

/* =================================================================
   Entities Pills (medical entities identified from query)
   ================================================================= */

.entities-container {
    margin-bottom: 0.75rem;
}

.entities-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.entity-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.entity-pill.entity-disease { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.entity-pill.entity-activeingredient { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.entity-pill.entity-drugproduct { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.entity-pill.entity-procedure { background: rgba(168, 85, 247, 0.15); color: #c4b5fd; border-color: rgba(168, 85, 247, 0.3); }
.entity-pill.entity-diagnostictest { background: rgba(251, 191, 36, 0.15); color: #fde68a; border-color: rgba(251, 191, 36, 0.3); }
.entity-pill.entity-clinicalfinding { background: rgba(236, 72, 153, 0.15); color: #f9a8d4; border-color: rgba(236, 72, 153, 0.3); }
.entity-pill.entity-complication { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

/* =================================================================
   Unified Reasoning Bubble (web sources + MedGemma thinking)
   ================================================================= */

.reasoning-container {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(59, 130, 246, 0.08));
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.reasoning-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(139, 92, 246, 0.12);
    border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}

.reasoning-icon {
    font-size: 1rem;
}

.reasoning-label {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 600;
    color: #a78bfa;
}

.reasoning-toggle {
    background: none;
    border: none;
    color: #a78bfa;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.reasoning-toggle:hover {
    background: rgba(139, 92, 246, 0.2);
}

.reasoning-content {
    padding: 0.75rem 1rem;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Badge shown in message meta after completion */
.reasoning-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Streaming animation — pulsing dot in header */
.reasoning-container.streaming .reasoning-header::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #a78bfa;
    border-radius: 50%;
    margin-left: 0.5rem;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Session limit warnings */
.session-limit-warning {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    text-align: center;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.session-limit-warning p {
    margin-bottom: 0.5rem;
}

.new-chat-btn-inline {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.new-chat-btn-inline:hover {
    background: var(--primary-dark);
}

.session-limit-approaching {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--warning);
    font-size: 0.8125rem;
}

/* =================================================================
   File Upload Components (v3.6.12)
   ================================================================= */

/* Attach button (+) */
.attach-btn {
    width: 48px;
    height: 48px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
}

.attach-btn:active {
    transform: scale(0.95);
}

/* File Upload Modal */
.file-upload-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.file-upload-modal.open {
    display: flex;
}

.file-upload-modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.file-upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.file-upload-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* File Drop Zone */
.file-drop-zone {
    margin: 1.5rem;
    padding: 3rem 2rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.file-drop-zone:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}

.file-drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    border-style: solid;
}

.file-drop-zone svg {
    color: var(--primary);
    margin-bottom: 1rem;
}

.file-drop-zone h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.file-drop-zone > p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0.75rem 0;
}

.browse-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    margin: 0.75rem 0;
}

.browse-btn:hover {
    background: var(--primary-dark);
}

.file-types-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

/* Uploading Status */
.uploading-status {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

.upload-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#uploadStatusText {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Attached Files Preview */
.attached-files-preview {
    display: none;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 0;
    margin-bottom: 0.5rem;
}

.file-preview-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 300px;
}

.file-icon {
    color: var(--primary);
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.file-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.remove-file-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.remove-file-btn:hover {
    background: var(--error);
    color: white;
}

/* Responsive adjustments for file upload */
@media (max-width: 768px) {
    .file-upload-modal-content {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    .file-drop-zone {
        padding: 2rem 1rem;
    }

    .file-preview-card {
        max-width: 100%;
    }
}

/* Image thumbnails in file preview bar */
.file-thumbnail {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

/* Image thumbnails in chat message bubbles */
.message-thumbnails {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.chat-thumbnail {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: opacity 0.2s;
}

.chat-thumbnail:hover {
    opacity: 0.85;
}
