/* --- CSS VARIABLES AND BASE STYLES --- */
:root {
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --text-primary: #f1f1f1;
    --text-secondary: #b0b0b0;
    --accent-color: #0084ff;
    --user-msg-accent: #0084ff; /* Using this for the new tint */

    --header-height: 60px;
    --menu-width: 280px;

    --header-bg: rgba(46, 125, 50, 0.75);
    --header-text-color: #ffffff;
    --menu-blur: 16px;

    --blur-radius: 25px;
    --glass-tint: rgba(18, 18, 18, 0.45);

    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    --transition-smooth: ease-in-out 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: #dbe9ff; /* Fallback color */
    background-image: url('image.png'); /* Your background image */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--glass-tint);
    backdrop-filter: blur(var(--blur-radius));
    -webkit-backdrop-filter: blur(var(--blur-radius));
    z-index: -1;
}

body.no-scroll { overflow: hidden; }

/* --- ICON BUTTON BASE STYLE --- */
.icon-button { background: none; border: none; padding: 8px; cursor: pointer; border-radius: 50%; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: background-color 0.2s ease; }
.icon-button:hover { background-color: rgba(255, 255, 255, 0.1); }
.icon-button svg { width: 24px; height: 24px; }

/* --- SIDE MENU & OVERLAY --- */
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--menu-width);
    height: 100%;
    background: linear-gradient(180deg, rgba(46, 125, 50, 0.3), rgba(27, 94, 32, 0.325)); /* Transparency increased by 50% */
    backdrop-filter: blur(52.5px); /* Blur increased by 50% */
    -webkit-backdrop-filter: blur(52.5px); /* Blur increased by 50% */
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateX(-100%);
    transition: transform var(--transition-smooth);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}
.side-menu.open { transform: translateX(0); }
.menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 0 16px;
    height: var(--header-height);
    padding-top: var(--safe-area-top);
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}
.menu-logo {
    height: 32px;
    width: 32px;
}
.menu-title { font-size: 1.2rem; font-weight: 700; flex-grow: 1; }
.menu-header .icon-button { color: #fff; }
.side-menu ul { list-style: none; padding: 8px; }
.menu-link { display: flex; align-items: center; gap: 16px; padding: 12px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 1rem; color: #fff; transition: background-color 0.2s ease; }
.menu-link:hover { background-color: rgba(255, 255, 255, 0.1); }
.menu-link.active { background-color: rgba(255, 255, 255, 0.2); }
.menu-link svg {
    width: 20px;
    height: 20px;
    color: #fff;
}
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.3); backdrop-filter: blur(2px); opacity: 0; visibility: hidden; transition: opacity var(--transition-smooth), visibility 0s 0.3s; z-index: 999; }
.overlay.active { opacity: 1; visibility: visible; transition-delay: 0s; }

/* --- APP CONTAINER & HEADER --- */
.app-container { height: 100vh; height: -webkit-fill-available; display: flex; flex-direction: column; }
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    padding-top: var(--safe-area-top);
    z-index: 100;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.app-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--header-text-color);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.app-header .icon-button { color: var(--header-text-color); }

/* --- CHAT PAGE STYLES --- */
.chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.chat-content { flex-grow: 1; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    padding-top: calc(var(--header-height) + var(--safe-area-top) + 16px);
    padding-bottom: 100px;
}

.welcome-container {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 0 1rem;
    pointer-events: none;
}
.chat-main.chat-active .welcome-container {
    display: none;
}
.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* --- Chat Messages & Input Area --- */
.message-wrapper { max-width: 80%; display: flex; margin-bottom: 16px; animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message-wrapper.user { align-self: flex-end; }
.message-wrapper.bot { align-self: flex-start; }

/* UPDATED: User message style for frosted glass effect */
.message-wrapper.user .message-content {
    background-color: rgba(0, 132, 255, 0.4); /* 40% blue tint from accent color */
    color: #ffffff;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 132, 255, 0.3);
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Bot message style for premium frosted glass effect */
.message-wrapper.bot .message-content {
    background-color: rgba(0, 0, 0, 0.3); /* 30% black tint */
    color: #f1f1f1; /* Light text for contrast */
    backdrop-filter: blur(20px); /* Premium blur effect */
    -webkit-backdrop-filter: blur(20px); /* For Safari */
    border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle border for definition */
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    text-align: left;
}

/* --- STYLING FOR CONTENT INSIDE BOT MESSAGE --- */
.message-wrapper.bot .message-content h2,
.message-wrapper.bot .message-content h3 {
    color: #ffffff;
    margin-top: 16px;
    margin-bottom: 8px;
}
.message-wrapper.bot .message-content h2 {
    font-size: 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 4px;
}
.message-wrapper.bot .message-content h3 {
    font-size: 1.05rem;
}
.message-wrapper.bot .message-content p {
    margin-bottom: 12px;
}
.message-wrapper.bot .message-content > *:first-child {
    margin-top: 0;
}
.message-wrapper.bot .message-content > *:last-child {
    margin-bottom: 0;
}
.message-wrapper.bot .message-content ul,
.message-wrapper.bot .message-content ol {
    padding-left: 20px;
    margin-bottom: 12px;
}
.message-wrapper.bot .message-content li {
    margin-bottom: 6px;
    padding-left: 4px;
}
.message-wrapper.bot .message-content strong,
.message-wrapper.bot .message-content b {
    color: #ffffff;
    font-weight: 600;
}
.message-wrapper.bot .message-content a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}
.message-wrapper.bot .message-content a:hover {
    text-decoration: underline;
}

.typing-indicator span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background-color: var(--text-secondary); margin: 0 2px; animation: bounce 1.2s infinite ease-in-out; }
.typing-indicator span:nth-child(2) { animation-delay: -0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: -0.4s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }
.chat-input-area-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: transparent;
    transition: transform 0.3s ease-in-out;
}
.chat-input-area { padding: 8px 16px; padding-bottom: calc(8px + var(--safe-area-bottom)); width: 100%; max-width: 800px; margin: 0 auto; }
.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(45, 45, 45, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    padding: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
#user-input { flex-grow: 1; border: none; background: none; padding: 10px; font-family: var(--font-primary); font-size: 1rem; resize: none; max-height: 120px; overflow-y: auto; color: #f0f0f0; }
#user-input::placeholder { color: rgba(255, 255, 255, 0.8); }
#user-input:focus { outline: none; }
#send-button { background: linear-gradient(180deg, #2ECC71, #28B463); color: #fff; width: 40px; height: 40px; transition: opacity 0.2s ease, transform 0.2s ease; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
#send-button:disabled { background: #a0a0a0; color: #f0f0f0; opacity: 0.6; cursor: not-allowed; transform: scale(0.9); box-shadow: none; }

/* --- ABOUT PAGE STYLES --- */
.page-main { padding: calc(var(--header-height) + var(--safe-area-top) + 24px) 24px; overflow-y: auto; flex-grow: 1; }
.page-content { max-width: 700px; margin: 0 auto; background-color: transparent; padding-bottom: 24px; }
.about-section {
    background-color: rgba(28, 28, 28, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.about-section h2 {
    margin-bottom: 16px;
    font-size: 1.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 8px;
}
.about-section p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    line-height: 1.7;
}
.author-list { list-style: none; padding: 0; margin: 0; }
.author-list li {
    padding: 8px 0;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- RESPONSIVE DESIGN --- */
@media (min-width: 1024px) {
    .app-header {
        position: absolute;
        background: none;
        border: none;
        box-shadow: none;
    }
    .chat-messages, .page-main {
        padding-top: 16px;
    }
}
@media (max-width: 1023px) {
    :root {
        --header-height: 78px; /* Original 60px + 30% */
        --menu-blur: 24px; /* Blur increased by 50% for mobile header */
        --header-bg: rgba(46, 125, 50, 0.375); /* Transparency increased by 50% for mobile header */
    }
    .app-header {
        background-color: var(--header-bg);
        backdrop-filter: blur(var(--menu-blur)) saturate(180%);
        -webkit-backdrop-filter: blur(var(--menu-blur)) saturate(180%);
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
}
@media (max-width: 767px) {
    .chat-input-area-container.keyboard-visible {
        transform: translateY(-45vh);
    }
}