/* Shared Design System for TrueMedicine */

@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    color-scheme: dark;
    --brand-light: #122a1d;
    --brand: #67b77d;
    --brand-dark: #4a8b5c;
    --accent-light: #2d2107;
    --accent: #f4c76d;
    --accent-dark: #d9a63f;
    --bg-gray: #0b1220;
    --text-main: #e5e7eb;
    --text-muted: #cbd5e1;
    --surface: #111827;
    --surface-alt: #0f172a;
    --surface-soft: #132d21;
    --surface-card: rgba(15, 23, 42, 0.9);
    --border-color: rgba(148, 163, 184, 0.18);
    --shadow-soft: rgba(2, 6, 23, 0.42);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-main);
    transition: background-color 0.25s ease, color 0.25s ease;
}

.heading-font {
    font-family: 'Merriweather', serif;
}

/* Glass Panels */
.glass-panel {
    background: var(--surface-card);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.glass-card {
    background: var(--surface-card);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.03);
}

/* Gradients */
.brand-gradient-text {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-gradient-bg {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
}

/* Ensure smooth scrolling and prevent fixed 10rem navbar from covering section anchors */
html {
    scroll-behavior: smooth;
}

section[id],
footer[id] {
    scroll-margin-top: 10.5rem;
}

/* Theme Toggle Strip (legacy fallback) */
.theme-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(90deg, var(--brand-dark) 0%, var(--brand) 50%, var(--accent-dark) 100%);
    position: relative;
    overflow: hidden;
}

.theme-strip::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        rgba(255,255,255,0.04) 0px,
        rgba(255,255,255,0.04) 1px,
        transparent 1px,
        transparent 40px
    );
    pointer-events: none;
}

.theme-strip__text {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

html[data-theme="dark"] .theme-strip {
    background: linear-gradient(90deg, #0b1a12 0%, #132d21 50%, #2d2107 100%);
}


html[data-theme="dark"] .glass-panel {
    background: rgba(15, 23, 42, 0.85);
    border-color: var(--border-color);
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-gray-50,
html[data-theme="dark"] .bg-gray-100,
html[data-theme="dark"] .bg-slate-50 {
    background-color: var(--surface-alt) !important;
}

html[data-theme="dark"] [class*="bg-brand-light/"] {
    background-color: var(--surface-soft) !important;
}

html[data-theme="dark"] .bg-brand-light {
    background-color: var(--surface-soft) !important;
}

html[data-theme="dark"] .bg-accent-light {
    background-color: var(--accent-light) !important;
}

html[data-theme="dark"] .bg-blue-50,
html[data-theme="dark"] .bg-amber-50 {
    background-color: var(--surface-alt) !important;
}

html[data-theme="dark"] .border-blue-100 {
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .bg-blue-50 .text-blue-900 {
    color: #93c5fd !important;
}

html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800,
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-600,
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-400 {
    color: var(--text-main) !important;
}

html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-600,
html[data-theme="dark"] .text-gray-700 {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .text-brand {
    color: var(--brand) !important;
}

html[data-theme="dark"] .text-accent {
    color: var(--accent) !important;
}

html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .border-brand\/20,
html[data-theme="dark"] .border-brand-20,
html[data-theme="dark"] .border-t,
html[data-theme="dark"] .border-b {
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .shadow-sm,
html[data-theme="dark"] .shadow-md,
html[data-theme="dark"] .shadow-xl,
html[data-theme="dark"] .shadow-2xl {
    box-shadow: 0 10px 25px var(--shadow-soft) !important;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #06130b;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(44, 94, 59, 0.2);
    filter: brightness(1.1);
}

.btn-accent {
    background: var(--accent);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-accent:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
}

.feedback-panel {
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    background: var(--surface);
}

.feedback-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 600;
}

.feedback-label span {
    color: var(--text-muted);
    font-weight: 400;
}

.feedback-input {
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--surface-alt);
    color: var(--text-main);
}

.feedback-input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.feedback-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.feedback-input:disabled,
#feedback-submit:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

#feedback-message {
    min-height: 7rem;
    resize: vertical;
}

#feedback-status[data-state="error"] {
    color: #fca5a5;
}

#feedback-status[data-state="success"] {
    color: #86efac;
}

@media (max-width: 639px) {
    .feedback-panel {
        padding: 1rem;
    }

    .feedback-input {
        font-size: 1rem;
    }

    #feedback-submit {
        padding-inline: 1rem;
    }

    body.feedback-panel-visible #ai-chat-window:not(.active) + #ai-assistant-button {
        visibility: hidden;
    }
}

/* Sidebar Menu (Copied from index.html logic) */
#sidebar-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    max-width: 85vw;
    height: 100vh;
    background: #111827;
    color: #e5e7eb;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 25px rgba(0,0,0,0.3);
}

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

.sidebar-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-section {
    border-bottom: 1px solid #1f2937;
}

.sidebar-section-title {
    padding: 1rem 1.5rem;
    font-family: 'Merriweather', serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.sidebar-section-title:hover {
    background: #1f2937;
}

.sidebar-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.sidebar-items.expanded {
    max-height: 5000px;
}

.sidebar-item {
    display: block;
    padding: 0.5rem 1.5rem 0.5rem 2rem;
    font-size: 0.85rem;
    color: #9ca3af;
    text-decoration: none;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    color: white;
    background: #1f2937;
    border-left-color: var(--brand);
}

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

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Back Link */
.back-link {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 100;
    background: var(--surface);
    padding: 0.6rem 1.2rem;
    border-radius: 9999px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--brand);
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid var(--brand-light);
}

.back-link:hover {
    background: var(--brand-light);
    transform: translateX(-4px);
}

/* AI Assistant Styles */
#ai-assistant-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

#ai-assistant-button {
    width: 4rem;
    height: 4rem;
    border-radius: 9999px;
    background-color: var(--brand);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#ai-assistant-button:hover {
    transform: scale(1.1) rotate(5deg);
    background-color: var(--brand-dark);
}

#ai-chat-window {
    position: absolute;
    bottom: 5rem;
    right: 0;
    width: 450px;
    max-width: calc(100vw - 4rem);
    height: 600px;
    max-height: calc(100vh - 10rem);
    background: var(--surface);
    border-radius: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#ai-chat-window.wide {
    width: 800px;
    max-width: calc(100vw - 4rem);
}


#ai-chat-window.active {
    display: flex;
    animation: chatAppear 0.3s ease-out;
}

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

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--surface-alt);
}

.chat-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.chat-msg.user {
    align-self: flex-end;
    background-color: var(--brand);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-msg.bot {
    align-self: flex-start;
    background-color: var(--surface);
    color: var(--text-main);
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.chat-msg.bot strong {
    font-weight: 700;
    color: var(--text-main);
}

.chat-msg.bot em {
    font-style: italic;
    color: var(--text-muted);
}

.chat-msg.bot li {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.chat-msg.typing {
    background-color: var(--surface-alt);
    color: var(--text-muted);
    font-style: italic;
}

.chat-input-area {
    padding: 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.5rem 1.25rem;
    background: var(--surface-alt);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.chat-input-area input:focus {
    border-color: var(--brand);
}

.chat-input-area button {
    background-color: var(--brand);
    color: white;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.chat-input-area button:hover {
    background-color: var(--brand-dark);
}

/* Mobile navigation menu dark mode styling */
html[data-theme="dark"] #mobile-menu {
    background-color: var(--surface) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] #navbar #mobile-menu .navbar-link {
    color: var(--text-main) !important;
    background-color: var(--surface-alt);
    border-color: #64748b;
}

html[data-theme="dark"] #navbar #mobile-menu .navbar-link:hover {
    background-color: var(--surface-soft) !important;
    color: #fff !important;
    border-color: var(--brand);
}

html[data-theme="dark"] #navbar #mobile-menu .navbar-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Dark mode: surfaces and text colours missing from the base overrides */
html[data-theme="dark"] .glass-card {
    background: var(--surface-card);
    border-color: var(--border-color);
}

html[data-theme="dark"] [class*="bg-white/5"],
html[data-theme="dark"] [class*="bg-white/6"],
html[data-theme="dark"] [class*="bg-white/7"],
html[data-theme="dark"] [class*="bg-white/8"],
html[data-theme="dark"] [class*="bg-white/9"],
html[data-theme="dark"] [class*="bg-gray-50/"],
html[data-theme="dark"] [class*="bg-slate-50/"],
html[data-theme="dark"] .bg-slate-100,
html[data-theme="dark"] .bg-slate-200 {
    background-color: var(--surface-alt) !important;
}

html[data-theme="dark"] [class*="bg-red-50"] {
    background-color: rgba(127, 29, 29, 0.3) !important;
}

html[data-theme="dark"] .text-red-600,
html[data-theme="dark"] .text-red-700 {
    color: #fca5a5 !important;
}

html[data-theme="dark"] .text-slate-900,
html[data-theme="dark"] .text-slate-800,
html[data-theme="dark"] .text-slate-700 {
    color: var(--text-main) !important;
}

html[data-theme="dark"] .text-slate-600,
html[data-theme="dark"] .text-slate-500 {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .text-blue-700,
html[data-theme="dark"] .text-blue-800,
html[data-theme="dark"] .text-blue-900 {
    color: #93c5fd !important;
}

html[data-theme="dark"] .text-brand-dark {
    color: var(--brand) !important;
}

html[data-theme="dark"] .text-accent-dark {
    color: var(--accent) !important;
}

html[data-theme="dark"] .bg-accent {
    color: #1a1200 !important;
}

html[data-theme="dark"] .bg-white.text-blue-900 {
    background-color: var(--surface-alt) !important;
}

html[data-theme="dark"] .back-link {
    background: var(--surface);
    border-color: var(--border-color);
}

html[data-theme="dark"] .back-link:hover {
    background: var(--surface-soft);
}

html[data-theme="dark"] .sidebar-link.active {
    background-color: var(--surface-soft);
    color: #93c5fd;
}

html[data-theme="dark"] .bg-red-100 {
    background-color: rgba(127, 29, 29, 0.45) !important;
}

html[data-theme="dark"] .bg-blue-100 {
    background-color: rgba(30, 58, 138, 0.45) !important;
}

html[data-theme="dark"] .text-blue-600 { color: #93c5fd !important; }
html[data-theme="dark"] .text-indigo-800 { color: #a5b4fc !important; }
html[data-theme="dark"] .text-emerald-800,
html[data-theme="dark"] .text-green-600,
html[data-theme="dark"] .text-green-700,
html[data-theme="dark"] .text-green-800 { color: #86efac !important; }
html[data-theme="dark"] .text-orange-600 { color: #fdba74 !important; }
html[data-theme="dark"] .text-purple-600 { color: #d8b4fe !important; }
html[data-theme="dark"] .text-red-800,
html[data-theme="dark"] .text-red-900 { color: #fca5a5 !important; }
html[data-theme="dark"] .text-yellow-800,
html[data-theme="dark"] .text-yellow-900,
html[data-theme="dark"] .text-amber-700 { color: #fde68a !important; }

html[data-theme="dark"] .bg-green-50,
html[data-theme="dark"] .bg-green-100 { background-color: rgba(20, 83, 45, 0.45) !important; }
html[data-theme="dark"] .bg-yellow-50,
html[data-theme="dark"] .bg-amber-100 { background-color: rgba(120, 53, 15, 0.45) !important; }
html[data-theme="dark"] .bg-purple-100 { background-color: rgba(88, 28, 135, 0.45) !important; }
html[data-theme="dark"] .bg-orange-100 { background-color: rgba(124, 45, 18, 0.45) !important; }

html[data-theme="dark"] .bg-gradient-to-br.from-brand-light {
    background-image: linear-gradient(to bottom right, var(--surface-soft), var(--surface-alt)) !important;
}
