/* ==========================================================================
   Variables
   ========================================================================== */
:root {
    --bg-color: #fdfdfd;
    --text-main: #111827;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --black: #000000;
    --white: #ffffff;
    --bot-bg: #f3f4f6;
    --accent: #0d7377;
    --accent-light: #e6f4f4;
}

body[data-theme="dark"] {
    --bg-color: #111827;
    --text-main: #f3f4f6;
    --text-light: #9ca3af;
    --border-color: #374151;
    --black: #f3f4f6;
    --white: #1f2937;
    --bot-bg: #374151;
    --accent: #14b8a6;
    --accent-light: #0f3d3d;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.2s, color 0.2s;
}

/* ==========================================================================
   NAVBAR
   ========================================================================== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 48px;
    background: var(--bg-color);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.2s;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 22px;
    letter-spacing: -1px;
}

.badge-triage {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 12px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
}

.dot-green {
    width: 7px; height: 7px;
    background-color: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.nav-links {
    display: flex;
    gap: 36px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    font-size: 14px;
    transition: color 0.15s;
}

.nav-links a:hover { color: var(--accent); }

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

/* Settings wrapper & dropdown */
.settings-wrapper {
    position: relative;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, color 0.15s;
}

.btn-icon:hover { background: var(--bot-bg); color: var(--text-main); }
.btn-icon svg { width: 17px; height: 17px; }

.settings-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
    min-width: 180px;
    z-index: 200;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.settings-dropdown:not([hidden]) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-list {
    list-style: none;
    padding: 6px;
}

.dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color 0.12s;
    text-align: left;
}

.dropdown-item:hover { background: var(--bot-bg); }
.dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.dropdown-separator {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 4px 8px;
}

.dropdown-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.security-text {
    font-size: 13px;
    color: #059669;
    font-weight: 500;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-black {
    background: var(--black);
    color: var(--white);
    border: none;
    padding: 10px 22px;
    border-radius: 24px;
    font-weight: 500;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.15s, transform 0.1s;
    position: relative;
}

.btn-black:hover { opacity: 0.85; }
.btn-black:active { transform: scale(0.97); }

.btn-outline {
    background: var(--white);
    color: var(--black);
    border: 1px solid var(--border-color);
    padding: 10px 22px;
    border-radius: 24px;
    font-weight: 500;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

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

.btn-large { padding: 16px 32px; font-size: 16px; }

/* Status dot on settings button */
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background-color: #6b7280;
    border: 2px solid var(--black);
    transition: background-color 0.2s;
}

.status-dot.active { background-color: #10b981; }

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

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

.modal {
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.12);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
    transform: scale(0.96) translateY(8px);
    transition: transform 0.2s;
}

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

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

.modal-header h2 { font-size: 1rem; font-weight: 600; }

.modal-close-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.15s;
}

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

.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 12px; }

.modal-hint { font-size: 0.875rem; color: var(--text-light); line-height: 1.5; }

.modal-body input[type="password"] {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-color);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-body input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13,115,119,0.1);
}

.form-hint { font-size: 0.75rem; color: var(--text-light); }

.modal-status { min-height: 18px; font-size: 0.8125rem; }
.modal-status.success { color: #059669; }
.modal-status.error { color: #dc2626; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ==========================================================================
   HERO SECTION
   ========================================================================== */
.hero-section {
    max-width: 1300px;
    margin: 64px auto;
    padding: 0 48px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 64px;
    align-items: center;
}

/* Colonne gauche */
.badge-top {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 6px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    margin-bottom: 28px;
    background: var(--bg-color);
    color: var(--text-main);
}

.dot-black {
    width: 7px; height: 7px;
    background: var(--black);
    border-radius: 50%;
}

.hero-content h1 {
    font-size: 3.6rem;
    line-height: 1.08;
    letter-spacing: -2px;
    margin-bottom: 24px;
    color: var(--text-main);
    font-weight: 800;
}

.hero-content p {
    font-size: 1.1rem;
    color: var(--text-light);
    line-height: 1.65;
    margin-bottom: 40px;
    max-width: 92%;
}

.hero-buttons { display: flex; gap: 14px; margin-bottom: 48px; flex-wrap: wrap; }

/* Stats */
.hero-stats {
    display: flex;
    align-items: center;
    gap: 24px;
}

.stat { display: flex; flex-direction: column; gap: 2px; }

.stat-number {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.stat-label { font-size: 0.75rem; color: var(--text-light); }

.stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border-color);
}

/* ==========================================================================
   CHAT CARD
   ========================================================================== */
.hero-chat {
    position: relative;
}

.chat-card {
    background: var(--white);
    border-radius: 24px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04);
    border: 1px solid var(--border-color);
    overflow: hidden;
    height: 620px;
    display: flex;
    flex-direction: column;
}

/* Chat header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    flex-shrink: 0;
}

.chat-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.bot-avatar-header {
    width: 46px; height: 46px;
    background: var(--black);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.chat-name {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-doctor {
    font-size: 10px;
    background: var(--bot-bg);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.bot-avatar-header svg { width: 22px; height: 22px; stroke: var(--bg-color); }

.avatar-small svg { width: 16px; height: 16px; }

.chat-live {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Chat body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.chat-body::-webkit-scrollbar { width: 4px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* Message rows */
.message-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: slideUp 0.2s ease;
}

.user-row { justify-content: flex-end; }

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

.bubble {
    max-width: 76%;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.6;
}

.bot-bubble {
    background: var(--bot-bg);
    color: var(--text-main);
    border-radius: 16px 16px 16px 4px;
}

.user-bubble {
    background: var(--black);
    color: var(--white);
    border-radius: 16px 16px 4px 16px;
}

.protocol-tag {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    color: #059669;
}

/* Markdown rendering inside bot bubble */
.bot-bubble .md-h1,
.bot-bubble .md-h2,
.bot-bubble .md-h3 {
    font-weight: 700;
    color: var(--text-main);
    margin: 14px 0 6px;
    line-height: 1.3;
}
.bot-bubble .md-h1 { font-size: 15px; }
.bot-bubble .md-h2 { font-size: 14px; }
.bot-bubble .md-h3 { font-size: 13px; }

.bot-bubble .md-p {
    margin: 6px 0;
    line-height: 1.65;
}

.bot-bubble .md-ul {
    margin: 8px 0 8px 6px;
    padding-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bot-bubble .md-ul li {
    line-height: 1.55;
    font-size: 14px;
    list-style: none;
    padding-left: 4px;
    position: relative;
}

.bot-bubble .md-ul li::before {
    content: '–';
    position: absolute;
    left: -14px;
    color: #9ca3af;
}

.bot-bubble strong { font-weight: 600; color: var(--text-main); }
.bot-bubble em { font-style: italic; color: var(--text-light); }

.bot-bubble .md-blockquote {
    border-left: 3px solid #f59e0b;
    background: var(--accent-light);
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    margin: 10px 0;
    font-size: 13px;
    color: var(--text-light);
}

/* First child no top margin */
.bot-bubble > *:first-child { margin-top: 0; }
.bot-bubble > *:last-child:not(.time-stamp) { margin-bottom: 0; }

.time-stamp {
    font-size: 11px;
    margin-top: 10px;
    opacity: 0.5;
    text-align: right;
}

.message-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid rgba(220,38,38,0.15);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    align-self: center;
    max-width: 90%;
    text-align: center;
    animation: slideUp 0.2s ease;
}

/* Suggestions */
.suggestions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 42px;
}

.suggestion-chip {
    padding: 7px 14px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-light);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.4;
}

.suggestion-chip:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px 12px;
    flex-shrink: 0;
    animation: fadeIn 0.15s ease;
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bot-bg);
    border-radius: 16px 16px 16px 4px;
}

.typing-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typingPulse 1.4s infinite ease-in-out;
}

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

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

/* Input area */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-color);
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.chat-input-area input::placeholder { color: var(--text-light); }
.chat-input-area input:disabled { color: var(--text-light); cursor: not-allowed; }

.send-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--black);
    color: var(--bg-color);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
}

.send-btn:hover:not(:disabled) { opacity: 0.8; }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { background: var(--border-color); color: var(--text-light); cursor: not-allowed; }

.chat-disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--text-light);
    padding: 0 20px 14px;
    flex-shrink: 0;
    background: var(--bg-color);
}

/* ==========================================================================
   FEATURES SECTION
   ========================================================================== */
.features-section {
    max-width: 1300px;
    margin: 0 auto 80px;
    padding: 0 48px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.feature-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px 24px;
    transition: box-shadow 0.2s, transform 0.2s;
}

.feature-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.07);
    transform: translateY(-2px);
}

.feature-icon {
    width: 40px; height: 40px;
    background: var(--bot-bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    color: var(--text-main);
}

.feature-icon svg { width: 20px; height: 20px; }

.feature-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.feature-card p {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.6;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .hero-section { grid-template-columns: 1fr; gap: 48px; }
    .hero-content h1 { font-size: 2.8rem; }
    .features-grid { grid-template-columns: repeat(2, 1fr); }
    .chat-card { height: 560px; }
}

@media (max-width: 768px) {
    .navbar { padding: 16px 24px; }
    .nav-links { display: none; }
    .hero-section { padding: 0 24px; margin: 40px auto; }
    .hero-content h1 { font-size: 2.2rem; letter-spacing: -1px; }
    .hero-content p { font-size: 1rem; }
    .hero-stats { flex-wrap: wrap; gap: 16px; }
    .stat-divider { display: none; }
    .features-section { padding: 0 24px; }
    .features-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
    .security-text { display: none; }
}

@media (max-width: 480px) {
    .features-grid { grid-template-columns: 1fr; }
    .hero-buttons { flex-direction: column; }
    .btn-large { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
