:root {
    /* Dark Theme Colors (Default) */
    --bg-main: #0B0F19;
    --bg-sidebar: #13192B;
    --bg-panel: #1E2538;
    --bg-input: #1A2234;
    
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    --accent-primary: #6366F1;
    --accent-secondary: #8B5CF6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    --accent-hover: #4F46E5;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --message-bot-bg: #1A2234;
    --message-user-bg: var(--accent-gradient);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-main: #F4F7FB;
    --bg-sidebar: #FFFFFF;
    --bg-panel: #FFFFFF;
    --bg-input: #F1F5F9;
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --message-bot-bg: #FFFFFF;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: all 0.3s ease;
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 24px;
}

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

.logo-icon {
    font-size: 24px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    margin-bottom: 32px;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.history-title {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 8px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background-color: var(--bg-panel);
    color: var(--text-primary);
}

.history-item.active {
    background-color: var(--bg-panel);
    color: var(--text-primary);
    font-weight: 500;
    border-left: 3px solid var(--accent-primary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-profile:hover {
    background-color: var(--bg-panel);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-input);
}

.profile-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-status {
    font-size: 12px;
    color: var(--text-muted);
}

.settings-icon {
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.user-profile:hover .settings-icon {
    color: var(--text-primary);
}

/* Main Chat Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-main);
}

.chat-header {
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
}

[data-theme="light"] .chat-header {
    background-color: rgba(244, 247, 251, 0.8);
}

.chat-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.chat-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-panel);
    color: var(--text-primary);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 20px;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.4s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.bot-message .avatar {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

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

.user-message .avatar {
    background-color: #334155;
    color: white;
}

[data-theme="light"] .user-message .avatar {
    background-color: #94A3B8;
}

.message-content {
    flex: 1;
    padding: 18px 24px;
    border-radius: var(--border-radius-lg);
    font-size: 15px;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

.bot-message .message-content {
    background-color: var(--message-bot-bg);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

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

/* Bullet points and formatting in bot messages */
.bot-message .message-content ul {
    margin-left: 20px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.bot-message .message-content li {
    margin-bottom: 6px;
}

.bot-message .message-content strong {
    color: var(--accent-primary);
    font-weight: 600;
}

[data-theme="light"] .bot-message .message-content strong {
    color: var(--accent-hover);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    background-color: var(--message-bot-bg);
    border-radius: 16px;
    width: max-content;
    border: 1px solid var(--border-color);
}

.pill {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.pill:nth-child(1) { animation-delay: -0.32s; }
.pill:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.input-area {
    padding: 20px 40px 30px;
    background: linear-gradient(180deg, transparent 0%, var(--bg-main) 30%);
    position: relative;
    z-index: 10;
}

.input-wrapper {
    max-width: 850px;
    margin: 0 auto;
    position: relative;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xl);
    display: flex;
    align-items: flex-end;
    padding: 8px 12px 8px 24px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow-md);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2), var(--shadow-md);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    resize: none;
    padding: 12px 0;
    max-height: 200px;
    outline: none;
    line-height: 1.5;
}

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

#send-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 12px;
    flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

#send-btn:disabled {
    background: var(--bg-panel);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 16px;
    max-width: 850px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Responsive Design */
@media (max-width: 900px) {
    .sidebar {
        position: absolute;
        transform: translateX(-100%);
        height: 100%;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .chat-header, .chat-messages, .input-area {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* Auth Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xl);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    position: relative;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay:not(.hidden) .modal-content {
    transform: translateY(0) scale(1);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    font-size: 32px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.auth-submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    margin-top: 10px;
}

.auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.auth-toggle {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.text-btn {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
}

.text-btn:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Auth specific profile additions */
.sign-out-btn {
    font-size: 12px;
    color: #EF4444;
    cursor: pointer;
    display: none; /* Shown via JS */
}
.sign-out-btn:hover {
    text-decoration: underline;
}

/* Image Upload UI Additions */
#upload-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    transition: color 0.2s ease;
}

#upload-btn:hover {
    color: var(--text-primary);
}

.message-image {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
    display: block;
}

/* Questionnaire Modal Specific Styles */
.questionnaire-content {
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
}

.q-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.q-section.active {
    display: block;
}

.q-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 18px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.radio-group, .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.radio-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.radio-group label, .checkbox-group label, .radio-group-vertical label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    user-select: none;
}

.radio-group label:hover, .checkbox-group label:hover, .radio-group-vertical label:hover {
    border-color: var(--accent-primary);
}

.radio-group input, .checkbox-group input {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Diagnosis Structured Response */
.bot-structured-response {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bot-structured-response p {
    margin: 0;
}

.user-context {
    font-size: 13px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

[data-theme="light"] .user-context {
    background: rgba(99, 102, 241, 0.05);
}

.diagnoses-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diagnosis-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.diagnosis-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.diagnosis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.match-percentage {
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 1s ease-out;
    animation: fillBar 1.2s ease-out forwards;
}

@keyframes fillBar {
    from { width: 0; }
}

.diagnosis-details {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diagnosis-details strong {
    color: var(--text-primary);
}

.diagnosis-result {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 16px;
    border-radius: var(--border-radius-md);
    margin-top: 8px;
}

.result-icon {
    font-size: 24px;
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.1);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

[data-theme="light"] .result-icon {
    background: white;
    box-shadow: var(--shadow-sm);
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-content strong {
    font-size: 16px;
    color: var(--accent-primary);
}

.result-content p {
    font-size: 14px;
    color: var(--text-secondary);
}

.diagnosis-outro {
    font-size: 14px;
    font-style: italic;
    color: var(--text-muted);
}

.form-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 16px;
}

.q-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.q-btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.q-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.q-btn-outline:hover {
    background: var(--bg-input);
    border-color: var(--text-secondary);
}

.step-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.step {
    width: 30px;
    height: 6px;
    background: var(--bg-input);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.step.active {
    background: var(--accent-gradient);
}
