/* ==================== Global Styles ==================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@400;600;700&family=Space+Grotesk:wght@400;500;600&display=swap');

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

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --doctor-color: #3b82f6;
    --patient-color: #8b5cf6;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== Landing Page ==================== */

.landing-body {
    font-family: 'Space Grotesk', sans-serif;
    background: radial-gradient(circle at top, #f3f7ff 0%, #fef4e8 45%, #f6f2f8 100%);
    color: #0f172a;
    overflow-x: hidden;
}

.landing-shell {
    position: relative;
    min-height: 100vh;
    padding: 2.5rem clamp(1.5rem, 4vw, 4rem) 3rem;
}

.landing-shell::before,
.landing-shell::after {
    content: '';
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(0px);
    opacity: 0.22;
    z-index: 0;
}

.landing-shell::before {
    background: #f59e0b;
    top: -140px;
    right: 10%;
}

.landing-shell::after {
    background: #0ea5e9;
    bottom: -180px;
    left: 8%;
}

.landing-nav,
.landing-hero,
.landing-features,
.landing-demo,
.landing-footer {
    position: relative;
    z-index: 1;
}

.landing-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3.5rem;
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 1.1rem;
}

.landing-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0ea5e9 0%, #f59e0b 100%);
    display: inline-block;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.2);
}

.landing-nav-actions {
    display: flex;
    gap: 0.75rem;
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: clamp(2rem, 4vw, 4rem);
    align-items: center;
    margin-bottom: 4rem;
}

.landing-hero-text {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: landingRise 0.8s ease-out both;
}

.landing-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.24em;
    font-size: 0.75rem;
    font-weight: 600;
    color: #0f766e;
}

.landing-hero-text h1 {
    font-family: 'Fraunces', serif;
    font-size: clamp(2.6rem, 4vw, 3.6rem);
    line-height: 1.1;
    color: #0f172a;
}

.landing-lede {
    font-size: 1.05rem;
    color: #475569;
    max-width: 560px;
}

.landing-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    animation: landingRise 0.9s ease-out 0.1s both;
}

.landing-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.6rem;
    border-radius: 999px;
    border: 2px solid transparent;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.landing-btn--primary {
    background: #0f766e;
    color: #f8fafc;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.25);
}

.landing-btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 28px rgba(15, 118, 110, 0.3);
}

.landing-btn--outline {
    border-color: #0f766e;
    color: #0f766e;
    background: transparent;
}

.landing-btn--outline:hover {
    background: rgba(15, 118, 110, 0.1);
    transform: translateY(-2px);
}

.landing-btn--ghost {
    border-color: transparent;
    color: #0f172a;
    background: rgba(15, 23, 42, 0.06);
}

.landing-btn--ghost:hover {
    background: rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
}

.landing-meta {
    display: grid;
    gap: 1rem;
    margin-top: 0.5rem;
    color: #475569;
}

.landing-meta-title {
    display: block;
    font-weight: 600;
    color: #0f172a;
}

.landing-meta-text {
    display: block;
    font-size: 0.92rem;
}

.landing-hero-card {
    background: white;
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(15, 23, 42, 0.08);
    animation: landingRise 0.9s ease-out 0.15s both;
}

.landing-card-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 1.5rem;
}

.landing-pill {
    background: rgba(14, 165, 233, 0.12);
    color: #0369a1;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
}

.landing-message {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: #f8fafc;
    margin-bottom: 1rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.landing-message--accent {
    background: #fff7ed;
    border-color: rgba(249, 115, 22, 0.2);
}

.landing-message-role {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.landing-summary {
    background: #0f766e;
    color: #f8fafc;
    padding: 1rem 1.1rem;
    border-radius: 16px;
    font-size: 0.92rem;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.landing-feature {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(15, 23, 42, 0.05);
    animation: landingRise 0.9s ease-out 0.2s both;
}

.landing-feature h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.landing-feature p {
    color: #475569;
}

.landing-demo {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    border-radius: 28px;
    padding: clamp(2rem, 4vw, 3rem);
    margin-bottom: 3rem;
}

.landing-demo h2 {
    font-family: 'Fraunces', serif;
    font-size: clamp(2rem, 3.5vw, 2.6rem);
    margin-bottom: 1rem;
}

.landing-demo-text p {
    color: #e2e8f0;
    margin-bottom: 1.5rem;
}

.landing-demo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.landing-demo .landing-btn--primary {
    background: #f59e0b;
    color: #0f172a;
    box-shadow: none;
}

.landing-demo .landing-btn--ghost {
    color: #f8fafc;
    background: rgba(248, 250, 252, 0.12);
}

.landing-demo-steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.landing-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 16px;
    border: 1px solid rgba(248, 250, 252, 0.12);
}

.landing-step-number {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #f59e0b;
    color: #0f172a;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.landing-step h4 {
    margin-bottom: 0.35rem;
}

.landing-step p {
    color: #cbd5f5;
    font-size: 0.92rem;
}

.landing-footer {
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
    padding-bottom: 1.5rem;
}

.demo-launch {
    display: flex;
    justify-content: center;
    padding: 2rem 0 3rem;
}

.demo-launch-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    padding: clamp(2rem, 4vw, 3rem);
    max-width: 720px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
    border: 1px solid rgba(15, 23, 42, 0.08);
    text-align: center;
}

.demo-launch-card h1 {
    font-family: 'Fraunces', serif;
    font-size: clamp(2rem, 3.2vw, 2.6rem);
    margin-bottom: 1rem;
}

.demo-launch-card p {
    color: #475569;
}

.demo-launch-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 2rem 0 1.25rem;
}

.demo-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 2rem 0 1.5rem;
}

.demo-tab.demo-tab--active {
    background: #0f766e;
    color: #f8fafc;
    border-color: #0f766e;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.2);
}

.demo-frame {
    background: #0f172a;
    border-radius: 18px;
    padding: 0.75rem;
    border: 1px solid rgba(15, 23, 42, 0.15);
}

.demo-frame iframe {
    width: 100%;
    height: min(70vh, 720px);
    border: 0;
    border-radius: 12px;
    background: #fff;
}

.demo-launch-note {
    font-size: 0.9rem;
    color: #64748b;
}

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

@media (max-width: 980px) {
    .landing-hero,
    .landing-demo {
        grid-template-columns: 1fr;
    }

    .landing-nav {
        flex-direction: column;
        align-items: flex-start;
    }

    .landing-nav-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .landing-cta,
    .landing-demo-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .landing-btn {
        width: 100%;
    }
}

/* ==================== Header ==================== */

header {
    background: var(--card-bg);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ==================== Main Container ==================== */

.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    grid-template-rows: auto 1fr;
}

/* ==================== Control Panel ==================== */

.control-panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    height: fit-content;
}

.conversation-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.conversation-selector {
    margin-bottom: 1.5rem;
}

.conversation-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

#conversationList {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--bg-color);
    cursor: pointer;
    transition: border-color 0.2s;
}

#conversationList:focus {
    outline: none;
    border-color: var(--primary-color);
}

.conversation-info {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.conversation-info p {
    margin-bottom: 0.5rem;
}

.conversation-info strong {
    color: var(--text-primary);
}

/* ==================== Buttons ==================== */

.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
    transform: translateY(-1px);
}

.btn-send {
    background: var(--success-color);
    color: white;
    padding: 1rem 2rem;
}

.btn-send:hover:not(:disabled) {
    background: #059669;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
}

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

/* ==================== Chat Area ==================== */

.chat-area {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    height: 700px;
}

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

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ==================== Message Styles ==================== */

.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in;
}

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

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

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

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.message-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
}

.message.doctor .message-badge {
    background: #dbeafe;
    color: var(--doctor-color);
}

.message.patient .message-badge {
    background: #ede9fe;
    color: var(--patient-color);
}

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

.message.doctor .message-content {
    border-left-color: var(--doctor-color);
}

.message.patient .message-content {
    border-left-color: var(--patient-color);
}

.message-text {
    margin-bottom: 0.75rem;
}

.message-text strong {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.message-text p {
    color: var(--text-primary);
}

.message-translation {
    background: white;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.message-translation strong {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.message-translation p {
    color: var(--text-primary);
    font-style: italic;
}

/* ==================== Message Input ==================== */

.message-input-section {
    border-top: 2px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-row {
    display: flex;
    gap: 1rem;
}

.sender-select,
.language-input {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--bg-color);
    transition: border-color 0.2s;
}

.sender-select {
    flex: 0 0 150px;
}

.language-input {
    flex: 1;
}

.sender-select:focus,
.language-input:focus,
.message-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.message-textarea {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    background: var(--bg-color);
    transition: border-color 0.2s;
}

/* ==================== Summary Panel ==================== */

.summary-panel {
    grid-column: 1 / -1;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    animation: slideUp 0.3s ease-out;
}

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

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

.summary-header h3 {
    color: var(--primary-color);
}

.summary-content {
    line-height: 1.8;
    color: var(--text-primary);
}

.summary-content .loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* ==================== Toast Notification ==================== */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
    }
    to {
        transform: translateX(0);
    }
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--error-color);
}

/* ==================== Utility Classes ==================== */

.hidden {
    display: none !important;
}

/* ==================== Footer ==================== */

footer {
    text-align: center;
    padding: 2rem;
    color: white;
    font-size: 0.9rem;
}

/* ==================== Scrollbar Styling ==================== */

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* ==================== Responsive Design ==================== */

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        order: -1;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .chat-area {
        height: 500px;
    }
    
    .input-row {
        flex-direction: column;
    }
    
    .sender-select {
        flex: 1;
    }
    
    .message {
        max-width: 95%;
    }
}
