/* All original CSS from style.css will be preserved */
/* Global box-sizing for consistent layout */
* {
    box-sizing: border-box;
}

:root {
    /* Light Mode Defaults */
    --primary-orange: #f97316;
    --text-dark: #1f2937;
    --text-medium: #4b5563;
    --text-light: #6b7280;
    --border-light: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --glow-color-light: rgba(249, 115, 22, 0.6);
    --bg-page: #fffaf0;
    --bg-card-main: #fff7ed;
    --bg-element-inner: #ffffff;
    --bg-button-outline-hover: #fff7ed;

    /* Chatbot specific colors (light mode) */
    --chat-user-bg: var(--primary-orange);
    --chat-user-text: white;
    --chat-ai-bg: var(--bg-element-inner);
    --chat-ai-text: var(--text-dark);
    --chat-border: var(--border-light);
    --chat-empty-text: var(--text-light);
}

body.dark-mode {
    /* Dark Mode Overrides */
    --primary-orange: #f97316; /* Keeping orange consistent */
    --text-dark: #e0e0e0; /* Lighter text for dark background */
    --text-medium: #a0a0a0;
    --text-light: #707070;
    --border-light: #333333; /* Darker border */
    --shadow-sm: 0 1px 2px 0 rgb(255 255 255 / 0.05); /* Subtle white shadow */
    --bg-page: #1a1a1a; /* Dark background */
    --bg-card-main: #2c2c2c; /* Slightly lighter dark for cards */
    --bg-element-inner: #3a3a3a; /* Even lighter dark for inner elements */
    --bg-button-outline-hover: #4a4a4a;
    --glow-color-dark: #ff8c00; /* Added for dark mode glow */

    /* Chatbot specific colors (dark mode) */
    --chat-user-bg: var(--primary-orange);
    --chat-user-text: white;
    --chat-ai-bg: #4a4a4a; /* Darker background for AI bubbles */
    --chat-ai-text: var(--text-dark);
    --chat-border: #444444; /* Darker border for chat history */
    --chat-empty-text: var(--text-light);
}

/* Animations */
@keyframes pulse-glow-light {
    0% {
        filter: drop-shadow(0 0 5px var(--glow-color-light)) drop-shadow(0 0 10px var(--glow-color-light));
        opacity: 0.8; /* Start slightly faded */
    }
    25% {
        filter: drop-shadow(0 0 15px var(--glow-color-light)) drop-shadow(0 0 30px var(--glow-color-light));
        opacity: 1; /* Brighten as it expands */
    }
    50% {
        filter: drop-shadow(0 0 30px var(--glow-color-light)) drop-shadow(0 0 60px var(--glow-color-light)); /* Max spread */
        opacity: 0.9; /* Slight fade at peak */
    }
    75% {
        filter: drop-shadow(0 0 15px var(--glow-color-light)) drop-shadow(0 0 30px var(--glow-color-light));
        opacity: 1; /* Brighten as it contracts */
    }
    100% {
        filter: drop-shadow(0 0 5px var(--glow-color-light)) drop-shadow(0 0 10px var(--glow-color-light));
        opacity: 0.8; /* Return to start faded */
    }
}

@keyframes pulse-glow-dark {
    0% {
        filter: drop-shadow(0 0 5px var(--glow-color-dark)) drop-shadow(0 0 10px var(--glow-color-dark));
        opacity: 0.8;
    }
    25% {
        filter: drop-shadow(0 0 15px var(--glow-color-dark)) drop-shadow(0 0 30px var(--glow-color-dark));
        opacity: 1;
    }
    50% {
        filter: drop-shadow(0 0 30px var(--glow-color-dark)) drop-shadow(0 0 60px var(--glow-color-dark));
        opacity: 0.9;
    }
    75% {
        filter: drop-shadow(0 0 15px var(--glow-color-dark)) drop-shadow(0 0 30px var(--glow-color-dark));
        opacity: 1;
    }
    100% {
        filter: drop-shadow(0 0 5px var(--glow-color-dark)) drop-shadow(0 0 10px var(--glow-color-dark));
        opacity: 0.8;
    }
}

@keyframes circle-pulse-light {
    0% { box-shadow: 0 0 0px 0px rgba(255, 255, 255, 0.7); }
    50% { box-shadow: 0 0 0px 5px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0px 0px rgba(255, 255, 255, 0.7); }
}
@keyframes circle-pulse-dark {
    0% { box-shadow: 0 0 0px 0px rgba(255, 255, 255, 0.7); }
    50% { box-shadow: 0 0 0px 5px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0px 0px rgba(255, 255, 255, 0.7); }
}

@keyframes icon-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Prevent horizontal scrollbar on body */
    transition: background-color 0.3s ease, color 0.3s ease;
}

.header {
    background-color: var(--bg-element-inner);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    height: 60px; /* Fixed height for consistent header */
    box-sizing: border-box; /* Include padding in height */
    position: fixed; /* Make header fixed */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap; /* Prevent text wrapping */
    font-size: 1.1rem; /* Slightly smaller for mobile */
}

.header-logo-svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: var(--primary-orange);
    margin-right: 0.25rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-toggle-button { /* Specific style for theme toggle button */
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-medium);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s, color 0.2s;
}
.theme-toggle-button:hover {
    background-color: var(--bg-page);
}

.main-content { /* This class is crucial for layout and should be used in index.html */
    flex-grow: 1;
    width: 100%;
    max-width: 1200px; /* Adjusted for wider content area */
    margin: 0 auto;
    padding: 1.5rem 1rem;
    /* Adjusted padding to account for fixed header and footer */
    padding-top: calc(60px + 1.5rem); /* Header height + desired margin */
    padding-bottom: calc(60px + 2rem); /* Footer height + desired margin */
    box-sizing: border-box;
}

.section-title {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary-orange);
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 1rem;
}

.welcome-section {
    background-color: var(--bg-card-main);
    border-radius: 1rem;
    padding: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.welcome-section .welcome-cross-svg {
    width: 3rem;
    height: 3rem;
    fill: var(--primary-orange);
    animation: pulse-glow-light 2s infinite alternate;
    margin-bottom: 1rem;
}
body.dark-mode .welcome-section .welcome-cross-svg {
    animation: pulse-glow-dark 2s infinite alternate;
}

.welcome-section h1 {
    font-size: 2.5rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
}
.welcome-section p {
    font-size: 1.125rem;
    color: var(--text-medium);
    max-width: 700px;
    margin: 0 auto 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.stats-card {
    background-color: var(--bg-element-inner);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.stats-card .icon {
    font-size: 2rem;
    color: var(--primary-orange);
    margin-bottom: 0.75rem;
}

.stats-card .number {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.stats-card .label {
    font-size: 0.9rem;
    color: var(--text-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Two Column Grid for Home Page Cards */
.two-column-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background-color: var(--bg-element-inner);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: transform 0.2s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-orange);
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.card p {
    font-size: 0.95rem;
    color: var(--text-dark);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* AI Assistant Card on Home Page and dedicated section */
.ai-assistant-card {
    background-color: var(--bg-element-inner);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 2rem;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.ai-assistant-card h2 {
    font-size: 2rem;
    color: var(--text-dark);
    margin-top: 0;
    margin-bottom: 1rem;
}
.ai-assistant-card .emoji {
    font-size: 1.5rem;
    vertical-align: middle;
}
.ai-assistant-card .form-group {
    margin-bottom: 1rem;
}
.ai-assistant-card .textarea-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background-color: var(--bg-page);
    color: var(--text-dark);
    font-size: 1rem;
    min-height: 80px;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease, color 0.3s ease;
}
.ai-assistant-card .textarea-field:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}
.ai-assistant-card .ask-button-container {
    text-align: right;
}

/* Generic Page Content Sections (Teachings, FAQs, AI Assistant, Saved) */
.page-content-section {
    display: none; /* Hidden by default */
    padding-bottom: 2rem; /* Add some padding to the bottom of each section */
}
.page-content-section.active {
    display: block; /* Shown when active */
}

.page-content-section h2 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary-orange);
    text-align: center;
    margin-bottom: 1rem;
}
.page-content-section .subtitle {
    font-size: 1.125rem;
    color: var(--text-medium);
    text-align: center;
    margin-bottom: 2rem;
}

/* Search Input Container */
.search-input-container {
    position: relative;
    margin-bottom: 1.5rem;
}
.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem; /* Left padding for icon */
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background-color: var(--bg-element-inner);
    color: var(--text-dark);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease, color 0.3s ease;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}
.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-medium);
}

/* Category Buttons */
.category-button-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
    justify-content: center;
}
.category-button {
    background-color: var(--bg-element-inner);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    color: var(--text-medium);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.category-button:hover {
    background-color: var(--bg-page);
    color: var(--text-dark);
}
.category-button.active {
    background-color: var(--primary-orange);
    color: white;
    border-color: var(--primary-orange);
}

/* Teachings List Container (Vertical List) */
.teachings-list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Articles List Container (Vertical List) */
.articles-list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* FAQs List Container (Vertical List) */
#faqsList {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Space between FAQ items */
}

/* Base Card Styling for Teachings, Articles, FAQs, Saved */
.teaching-card,
.article-card,
.faq-item,
.saved-item-card {
    background-color: var(--bg-element-inner);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: transform 0.2s ease, background-color 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--border-light);
    width: 100%; /* Ensure they take full width of their flex container */
    max-width: 100%; /* Prevent overflow if content is too wide */
}
.teaching-card:hover,
.article-card:hover,
.faq-item:hover,
.saved-item-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 10px -2px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.teaching-card h3,
.article-card h3,
.saved-item-card h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-orange);
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.teaching-card .category,
.article-card .category,
.saved-item-card .type-label { /* Added type-label for consistency */
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Snippet and Full Content Styling for Teachings and Articles */
.teaching-card .teaching-snippet,
.article-card .article-snippet,
.saved-item-card .saved-item-snippet {
    font-size: 0.9rem;
    color: var(--text-dark);
    line-height: 1.6;
    margin-bottom: 1rem;
    flex-grow: 1;
    display: block; /* Ensure snippet is visible by default */
}

.teaching-card .teaching-full-content,
.article-card .article-full-content,
.saved-item-card .teaching-full-content { /* Used for saved items too */
    max-height: 0; /* Initially hidden with smooth transition */
    overflow: hidden;
    padding-bottom: 0; /* No padding when collapsed */
    transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
    white-space: pre-wrap; /* Preserve formatting for full content */
    font-size: 0.9rem; /* Consistent font size */
    color: var(--text-dark); /* Consistent text color */
    line-height: 1.6; /* Consistent line height */
}

/* When the parent card is expanded, show full content and hide snippet */
.teaching-card.expanded .teaching-full-content,
.article-card.expanded .article-full-content,
.saved-item-card.expanded .teaching-full-content {
    max-height: 5000px; /* Sufficiently large to show any content */
    padding-bottom: 1rem; /* Add some padding when expanded */
}

.teaching-card.expanded .teaching-snippet,
.article-card.expanded .article-snippet,
.saved-item-card.expanded .saved-item-snippet {
    display: none; /* Hide snippet when full content is expanded */
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 0.875rem;
    gap: 0.5rem;
    outline: none;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.1s ease;
}
.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--primary-orange);
    color: var(--bg-element-inner);
}
.btn-primary:hover {
    background-color: #ea580c;
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-orange);
    border-color: var(--primary-orange);
}
.btn-outline:hover {
    background-color: var(--bg-button-outline-hover);
}

.btn-icon-only {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* FAQs Section (Attractive Expandable List) */
.faq-item {
    background-color: var(--bg-element-inner);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    /* margin-bottom is handled by #faqsList gap */
    overflow: hidden;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    border: 1px solid var(--border-light);
}
.faq-item:hover {
    box-shadow: 0 6px 10px -2px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}
.faq-item.active {
    border-color: var(--primary-orange);
    box-shadow: 0 4px 8px rgba(249, 115, 22, 0.15); /* Slightly more prominent glow */
}


.faq-question-header { /* Renamed from .faq-question to clarify it's the header */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    background-color: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: background-color 0.2s, color 0.2s;
}
.faq-question-header:hover {
    background-color: var(--bg-page);
    color: var(--primary-orange);
}

.faq-question-header .arrow-icon { /* Renamed from .icon to .arrow-icon for clarity */
    font-size: 1.1rem;
    color: var(--primary-orange);
    transition: transform 0.3s ease;
}

.faq-item.active .faq-question-header .arrow-icon {
    transform: rotate(180deg);
}

.faq-answer {
    padding: 0 1.5rem;
    font-size: 0.95rem;
    color: var(--text-medium);
    line-height: 1.6;
    max-height: 0; /* Hidden by default */
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
}
.faq-answer.active {
    max-height: 5000px; /* Sufficiently large to show content */
    padding-bottom: 1.5rem; /* Add bottom padding when active */
}

/* AI Assistant Section - Modern & Attractive Chatbot Design */
.chat-history {
    max-height: 400px; /* Increased height for better chat experience */
    overflow-y: auto;
    border: 1px solid var(--chat-border);
    border-radius: 1rem; /* More rounded corners */
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: var(--bg-page); /* Consistent with page background */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.chat-empty-state {
    text-align: center;
    color: var(--chat-empty-text);
    font-style: italic;
    padding: 2rem;
}

.chat-message {
    display: flex;
    align-items: flex-start; /* Align message bubbles to top */
    gap: 0.75rem;
}
.chat-message.user {
    justify-content: flex-end; /* User messages to the right */
}
.chat-message.ai {
    justify-content: flex-start; /* AI messages to the left */
}

.chat-avatar { /* Placeholder for future avatar images if desired */
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--primary-orange); /* Simple background for now */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
}
.chat-message.user .chat-avatar { display: none; } /* Hide user avatar for cleaner look */
.chat-message.ai .chat-avatar {
    background-color: var(--primary-orange); /* AI avatar color */
}


.chat-bubble {
    max-width: 75%; /* Slightly narrower bubbles */
    padding: 0.85rem 1.2rem; /* More padding */
    border-radius: 1.2rem; /* More rounded */
    font-size: 0.95rem; /* Slightly larger font */
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    word-wrap: break-word; /* Ensure long words break */
}
.chat-message.user .chat-bubble {
    background-color: var(--chat-user-bg);
    color: var(--chat-user-text);
    border-bottom-right-radius: 0.4rem; /* Pointed corner */
}
.chat-message.ai .chat-bubble {
    background-color: var(--chat-ai-bg);
    color: var(--chat-ai-text);
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 0.4rem; /* Pointed corner */
}

.chat-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center; /* Align input and button vertically */
}
.chat-input-group .textarea-field { /* Changed from input to textarea */
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 0.75rem; /* More rounded */
    background-color: var(--bg-element-inner); /* Use inner element background */
    color: var(--text-dark);
    font-size: 1rem;
    min-height: 45px; /* Minimum height for input */
    max-height: 120px; /* Max height before scroll */
    resize: vertical; /* Allow vertical resize */
    overflow-y: auto; /* Enable scrolling if content exceeds max-height */
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease, color 0.3s ease;
}
.chat-input-group .textarea-field:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.3); /* Stronger focus glow */
}
.chat-input-group button {
    background-color: var(--primary-orange);
    color: white;
    border: none;
    border-radius: 0.75rem; /* More rounded */
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0; /* Prevent button from shrinking */
}
.chat-input-group button:hover {
    background-color: #ea580c;
    transform: translateY(-1px); /* Slight lift on hover */
}
.chat-input-group button:active {
    transform: translateY(0);
}

.ai-loading-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-medium);
    margin-top: 1rem;
    font-style: italic;
}
.ai-loading-indicator .fa-spinner {
    animation: spin 1s linear infinite;
}
/* @keyframes spin defined globally */

.ai-response-area { /* This is likely not used if chat history handles responses */
    background-color: var(--bg-page);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
    color: var(--text-dark);
    line-height: 1.6;
    white-space: pre-wrap; /* Preserve whitespace and line breaks */
    overflow-y: auto;
    max-height: 300px; /* Limit height for long responses */
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}


/* Saved Items List (Vertical List) */
.saved-items-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Footer */
.footer {
    background-color: var(--bg-element-inner);
    padding: 0.75rem 1rem;
    box-shadow: 0 -1px 3px 0 rgb(0 0 0 / 0.1), 0 -1px 2px -1px rgb(0 0 0 / 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border-light);
    position: fixed; /* Changed to fixed */
    bottom: 0;
    width: 100%;
    z-index: 998; /* Below ad bar, above other content */
    transition: background-color 0.3s ease, border-color 0.3s ease;
    height: 60px; /* Fixed height for consistent mobile footer */
    box-sizing: border-box;
}

.footer .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-medium);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: color 0.2s, background-color 0.2s;
}
.footer .nav-item:hover {
    color: var(--primary-orange);
    background-color: var(--bg-page);
}
.footer .nav-item.active {
    color: var(--primary-orange);
}
.footer .nav-item .icon {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

/* Ad Banner */
.bottom-ad-bar {
    background-color: var(--primary-orange);
    color: white;
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    position: fixed;
    bottom: 0; /* Start at the bottom, will be pushed up by transform */
    left: 0;
    width: 100%;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
    z-index: 1000; /* Above footer */
    /* Initial state: off-screen and invisible */
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none; /* Not clickable when hidden */
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.6s ease-in; /* Fancy slide-in animation */
    min-height: 80px; /* Ensure it has enough height */
    box-sizing: border-box;
}
/* State when visible */
.bottom-ad-bar.is-visible {
    transform: translateY(-60px); /* Move up by footer height */
    opacity: 1;
    pointer-events: auto; /* Make clickable */
}

.bottom-ad-bar .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: auto;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}
.bottom-ad-bar .close-btn:hover {
    opacity: 1;
}
.bottom-ad-bar .ad-icon-circle {
    background-color: rgba(255,255,255,0.2);
    border-radius: 50%;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bottom-ad-bar .ad-icon {
    font-size: 1.5rem;
}
.bottom-ad-bar .ad-content {
    flex-grow: 1;
    text-align: left;
}
.bottom-ad-bar .ad-content h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}
.bottom-ad-bar .ad-content p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.9;
}
.bottom-ad-bar .ad-buttons {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0; /* Prevent buttons from shrinking on smaller screens */
}
.bottom-ad-bar .ad-btn {
    background-color: white;
    color: var(--primary-orange);
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s, opacity 0.2s;
    text-decoration: none; /* Ensure link looks like a button */
}
.bottom-ad-bar .ad-btn:hover {
    opacity: 0.9;
}
.bottom-ad-bar .ad-btn .fab {
    font-size: 1rem;
}


/* Message Box */
.message-box {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: #f0f0f0;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 10000;
    font-size: 0.9rem;
    font-weight: 500;
    display: none; /* Hidden by default */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}
.message-box.active {
    opacity: 1;
    display: block; /* Show when active */
}
.message-box.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.message-box.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.message-box.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    display: none;
}

.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--primary-orange);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .header {
        flex-direction: row; /* Keep items in a row */
        justify-content: space-between; /* Space out logo and theme toggle */
        align-items: center; /* Vertically align */
        padding: 0.75rem 1rem; /* Adjusted padding for mobile */
        height: 50px; /* Slightly smaller fixed height for mobile header */
    }
    .header-left {
        font-size: 1rem; /* Smaller font size for mobile header title */
        gap: 0.25rem;
    }
    .header-logo-svg {
        width: 1rem; /* Smaller logo */
        height: 1rem;
    }
    .theme-toggle-button {
        font-size: 1rem; /* Smaller toggle button */
        padding: 0.3rem;
    }

    .main-content {
        /* Mobile: Header height ~50px, Footer height ~50px, Ad Bar height ~70px (when visible) */
        padding-top: calc(50px + 1rem); /* Matches mobile header height + margin */
        padding-bottom: calc(50px + 2rem); /* Mobile Footer height + desired margin */
    }
    .welcome-section {
        padding: 1.5rem;
    }
    .welcome-section h1 {
        font-size: 2rem;
    }
    .section-title {
        font-size: 1.8rem;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    .two-column-grid {
        grid-template-columns: 1fr;
    }
    .ai-assistant-card {
        padding: 1.5rem;
    }
    .ai-assistant-card h2 {
        font-size: 1.8rem;
    }
    .search-input {
        padding: 0.75rem 1rem 0.75rem 2.5rem;
    }
    .category-button {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    /* No specific grid for list containers on mobile, they should naturally stack */
    .teaching-card, .faq-item, .saved-item-card, .article-card { /* Ensure all cards are full width */
        padding: 1rem;
        width: 100%;
    }
    .teaching-card h3, .saved-item-card h3, .article-card h3 {
        font-size: 1.3rem;
    }
    .faq-question-header { /* Updated class name */
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
    .faq-answer {
        padding: 0 1rem 1rem;
    }
    .footer {
        padding: 0.5rem;
        height: 50px; /* Match header height for consistency */
    }
    .footer .nav-item {
        font-size: 0.65rem;
        padding: 0.3rem;
    }
    .footer .nav-item .icon {
        font-size: 1.25rem;
    }
    .bottom-ad-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
        text-align: center;
        bottom: 0; /* Start at the bottom */
        min-height: 70px; /* Adjusted min-height for mobile ad bar */
    }
    .bottom-ad-bar.is-visible {
        transform: translateY(-50px); /* Move up by mobile footer height */
    }
    .bottom-ad-bar .ad-content {
        text-align: center;
    }
    .bottom-ad-bar .ad-buttons {
        flex-direction: column;
        width: 100%;
    }
    .bottom-ad-bar .ad-btn {
        width: 100%;
        justify-content: center;
    }
    .bottom-ad-bar .close-btn {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* --- Language Toggle Styling --- */
.language-toggle-container {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--bg-element-inner); /* Use existing card background variable */
    border: 1px solid var(--border-light); /* Use existing border color variable */
    border-radius: 9999px; /* Fully rounded */
    padding: 0.5rem 0.75rem; /* Adjust padding as needed */
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    margin-right: 0.5rem; /* Space from theme toggle */
    box-shadow: var(--shadow-sm); /* Use existing shadow variable */
    color: var(--text-medium); /* Inherit text color */
}

.language-toggle-container:hover {
    background-color: var(--bg-page); /* Use existing hover background variable */
    border-color: var(--primary-orange); /* Highlight on hover */
    box-shadow: var(--shadow-md); /* Slightly more prominent shadow on hover */
}

.language-icon {
    font-size: 1rem; /* Adjust icon size */
    margin-right: 0.5rem;
    color: var(--primary-orange); /* Use primary color for icon */
}

.language-toggle {
    appearance: none; /* Remove default select styles */
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem; /* Match other text elements */
    color: var(--text-dark); /* Use primary text color */
    cursor: pointer;
    outline: none; /* Remove focus outline */
    -webkit-appearance: none; /* For Safari */
    -moz-appearance: none; /* For Firefox */
    position: relative; /* For custom arrow */
    padding-right: 1.5rem; /* Space for custom arrow */
    z-index: 1; /* Ensure it's above the pseudo-element if needed */
}

/* Custom arrow for select */
.language-toggle::after {
    content: '\f0d7'; /* Font Awesome chevron-down icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none; /* Allow clicks to pass through to the select */
    color: var(--text-medium);
}

/* Hide default arrow in IE/Edge */
.language-toggle::-ms-expand {
    display: none;
}

/* --- Floating AI Button Style --- */
.floating-ai-button {
    position: fixed;
    bottom: calc(60px + 1.5rem); /* Adjust based on footer height + margin */
    right: 1.5rem;
    background-color: var(--primary-orange); /* Use primary orange for visibility */
    color: white; /* White icon */
    width: 55px; /* Size of the button */
    height: 55px;
    border-radius: 50%; /* Circular shape */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem; /* Icon size */
    border: none;
    box-shadow: var(--shadow-lg); /* Prominent shadow */
    cursor: pointer;
    z-index: 999; /* Below ad bar, above other content */
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-ai-button:hover {
    background-color: #ea580c; /* Slightly darker orange on hover */
    transform: translateY(-5px); /* Lift effect */
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.2); /* More pronounced shadow */
}

.floating-ai-button:active {
    transform: translateY(-2px); /* Press effect */
    box-shadow: var(--shadow-md);
}

/* Adjustments for ad bar visibility */
.bottom-ad-bar.is-visible + .floating-ai-button {
    bottom: calc(60px + 80px + 1.5rem); /* Footer height + Ad bar height + margin */
}

/* Responsive adjustments for floating button */
@media (max-width: 768px) {
    .floating-ai-button {
        bottom: calc(50px + 1rem); /* Adjust for smaller footer and margin */
        right: 1rem;
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    .bottom-ad-bar.is-visible + .floating-ai-button {
        bottom: calc(50px + 70px + 1rem); /* Adjust for smaller footer + ad bar height on mobile */
    }
}
