/* ==========================================================================
   AGRISAKTHI NUTRITION - Modern responsive theme
   ========================================================================== */

:root {
    --primary-bg: #f8fafc;
    --content-bg: #ffffff;
    --brand: #0ea5e9;
    --brand-dark: #0284c7;
    --brand-light: #e0f2fe;
    --accent: #10b981;
    --user-msg-bg: #0ea5e9;
    --bot-msg-bg: #f1f5f9;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --text-light: #fff;
    --border-color: #e2e8f0;
    --highlight-color: #dcfce7;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-full: 9999px;
    --tap-min: 44px;
}
/* Backwards compatibility */
:root {
    --brand-blue: var(--brand);
    --brand-blue-hover: var(--brand-dark);
    --text-secondary: var(--text-muted);
    --font-family: var(--font-sans);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background-color: var(--primary-bg);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- Navbar (responsive, touch-friendly) --- */
.navbar-modern {
    background: var(--content-bg) !important;
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 0;
}
.navbar-modern .container { max-width: 1200px; }
.navbar-logo { border-radius: var(--radius-sm); }
.navbar-brand-text { font-weight: 600; font-size: 1.15rem; color: var(--text-dark) !important; }
.navbar-modern .nav-link {
    font-weight: 500;
    color: var(--text-muted) !important;
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem !important;
    min-height: var(--tap-min);
    display: inline-flex;
    align-items: center;
}
.navbar-modern .nav-link:hover { color: var(--brand) !important; background: var(--brand-light) !important; }
.navbar-modern .nav-link.active { color: var(--brand) !important; background: var(--brand-light) !important; }
@media (max-width: 991.98px) {
    .navbar-collapse { padding: 0.5rem 0; }
    .navbar-modern .nav-link { min-height: 48px; }
}

/* --- Home: Hero --- */
.page-home-main { min-height: 60vh; padding-bottom: 3rem; }
.hero-block {
    padding: clamp(2rem, 6vw, 4rem) 0;
    background: linear-gradient(180deg, var(--content-bg) 0%, var(--primary-bg) 100%);
}
.hero-inner { text-align: center; max-width: 640px; margin: 0 auto; }
.hero-badge {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-light);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}
.hero-title {
    font-size: clamp(1.85rem, 5vw, 2.75rem);
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
    margin-bottom: 1rem;
}
.hero-lead {
    font-size: clamp(1rem, 2vw, 1.15rem);
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    line-height: 1.6;
}
.btn-hero-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap-min);
    padding: 0.75rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-light);
    background: var(--brand);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: background 0.2s, transform 0.1s;
}
.btn-hero-cta:hover { background: var(--brand-dark); color: var(--text-light); transform: translateY(-1px); }
.btn-hero-cta:active { transform: translateY(0); }

/* --- Home: Feature cards --- */
.features-block { padding: 2rem 0 3rem; }
.feature-card {
    height: 100%;
    background: var(--content-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.feature-card:hover { box-shadow: var(--shadow-lg); border-color: var(--brand-light); }
.feature-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}
.feature-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-dark); }
.feature-desc { font-size: 0.95rem; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* --- Home: Chat section --- */
.chat-section { padding: 2rem 0 4rem; }
.chat-section.hidden { display: none !important; }
.container-narrow { max-width: 720px; margin: 0 auto; }
.chat-widget {
    background: var(--content-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 380px;
}
.chat-box {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 240px;
}
.chat-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--primary-bg);
}
.image-preview-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: var(--content-bg);
    border-radius: var(--radius-sm);
}
.image-preview-wrapper.hidden { display: none !important; }
.btn-remove-image {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
}
.chat-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.chat-form:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.chat-input {
    flex: 1;
    border: none;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    background: transparent;
    outline: none;
    min-width: 0;
}
.btn-chat-icon {
    width: var(--tap-min);
    height: var(--tap-min);
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.btn-chat-icon:hover { color: var(--brand); background: var(--brand-light); }
.btn-chat-send {
    width: var(--tap-min);
    height: var(--tap-min);
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-chat-send:hover { background: var(--brand-dark); color: #fff; }
.hidden { display: none !important; }

@media (max-width: 575.98px) {
    .hero-block { padding-top: 1.5rem; }
    .feature-card { padding: 1.25rem; }
    .chat-widget { min-height: 320px; }
    .chat-box { min-height: 200px; padding: 1rem; }
}

/* --- 2. GLOBAL NAVIGATION --- */
.main-nav {
    background: var(--content-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 4%;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* --- APPEND THIS TO YOUR public/style.css --- */

/* --- COMPARE PAGE - AUTO-SUGGEST & TAGS --- */
.search-wrapper {
    position: relative;
}

.suggestions-box {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 .25rem .25rem;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
}

.suggestion-item:hover {
    background-color: #f1f3f5;
}

.selected-foods-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.food-tag {
    background-color: #e9ecef;
    padding: 5px 10px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.food-tag span {
    margin-left: 8px;
    cursor: pointer;
    font-weight: bold;
}

/* Styles for the content that will be exported */
.export-header {
    display: none; /* Hidden by default */
}

@media print {
    /* Hide UI elements when printing */
    .main-nav, #foodSearchInput, #selectedFoods, #exportJpgBtn, .footer {
        display: none !important;
    }
}
.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 1.3rem;
    font-weight: 500;
}

.nav-logo {
    height: 40px;
    margin-right: 15px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 15px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.nav-links a.active {
    background-color: var(--brand-blue);
    color: var(--text-light);
}

.nav-links a:not(.active):hover {
    color: var(--brand-blue);
}

/* --- 3. CHATBOT PAGE STYLES --- */
.chatbot-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; /* Prevents scrolling of the whole page */
}

.chatbot-main-container,
.chatbot-card {
    width: 100%;
    max-width: 720px;
    margin: 2rem auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--content-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#chat-box {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 22px;
    word-wrap: break-word;
    line-height: 1.5;
}

.user-message {
    background-color: var(--user-msg-bg);
    color: var(--text-light);
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.bot-message {
    background-color: var(--bot-msg-bg);
    color: var(--text-dark);
    align-self: flex-start;
    border-bottom-left-radius: 6px;
}

#chat-input-area {
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    background-color: var(--content-bg);
}

#chat-form {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 5px 10px;
    transition: box-shadow 0.2s;
}

#chat-form:focus-within {
    box-shadow: 0 0 0 2px var(--brand-blue);
    border-color: var(--brand-blue);
}

#user-input {
    flex-grow: 1;
    border: none;
    padding: 10px;
    font-size: 1rem;
    background: transparent;
    outline: none;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.icon-button:hover {
    color: var(--brand-blue);
}

#mic-btn.is-listening {
    color: #e94235;
}

#image-preview-container {
    text-align: left;
    position: relative;
    display: inline-block;
    margin-bottom: 10px;
}

#image-preview {
    max-height: 60px;
    border-radius: 8px;
}

#remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Explore & Compare (responsive) --- */
.explore-body, .compare-body { display: block; }
.explore-body main, .compare-body main {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}
@media (min-width: 576px) {
    .explore-body main, .compare-body main { padding-left: 1.5rem; padding-right: 1.5rem; }
}

.main-content-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: clamp(1rem, 4vw, 2rem);
    background: var(--content-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.main-content-container h1 {
    margin-top: 0;
    text-align: center;
    font-size: 2rem;
}

.main-content-container p.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-top: -1rem;
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

#search-box {
    max-width: 500px;
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 25px;
}

.primary-btn {
    background-color: var(--brand-blue);
    color: var(--text-light);
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 25px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: var(--brand-blue-hover);
}
.btn-primary {
    background-color: var(--brand);
    border-color: var(--brand);
    min-height: var(--tap-min);
    padding: 0.5rem 1rem;
}
.btn-primary:hover {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
    color: var(--text-light);
}

.table-wrapper {
    overflow-x: auto;
}

#nutrition-table, .compare-container table {
    width: 100%;
    border-collapse: collapse;
}

#nutrition-table th, #nutrition-table td, .compare-container th, .compare-container td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

#nutrition-table th {
    background-color: var(--primary-bg);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

#nutrition-table tbody tr:hover {
    background-color: #f1f3f5;
}

/* --- 5. COMPARE PAGE SPECIFIC STYLES --- */
.compare-container .selection-area {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.food-selector {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.food-selector select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.compare-container table th {
    background-color: var(--primary-bg);
    text-align: center;
    font-size: 1.1rem;
}

.compare-container table td:not(:first-child) {
    text-align: center;
}

.compare-container table .winner {
    font-weight: bold;
    background-color: var(--highlight-color);
}

/* --- 6. PAGINATION & FOOTER --- */
.pagination {
    text-align: center;
    margin-top: 2rem;
    user-select: none;
}

.pagination button {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    margin: 0 4px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
}

.pagination button:hover {
    background-color: var(--bot-msg-bg);
    border-color: #adb5bd;
}

.pagination button.active {
    background: var(--brand-blue);
    color: #fff;
    border-color: var(--brand-blue);
}

#chatbot-footer,
footer {
    text-align: center;
    padding: clamp(1rem, 3vw, 1.5rem) 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    background-color: var(--content-bg);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}
footer a { color: var(--brand); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* --- Responsive: global --- */
@media (max-width: 767.98px) {
    .main-nav { flex-direction: column; padding: 10px; }
    .nav-links { margin-top: 10px; }
    .chatbot-body { min-height: 100vh; height: auto; }
    .chatbot-main-container {
        margin: 0.75rem;
        border-radius: var(--radius);
    }
    .main-content-container { margin: 1rem; padding: 1.25rem; }
    .main-content-container h1 { font-size: 1.5rem; }
    .container { padding-left: 1rem; padding-right: 1rem; }
}
@media (max-width: 575.98px) {
    .hero-inner { padding: 0 0.5rem; }
    .btn-hero-cta { width: 100%; max-width: 280px; }
}

/* Styling for tables generated inside the bot chat message */
.bot-message table {
    width: 100%;
    border-collapse: collapse; 
    margin-top: 10px;
    font-size: 0.95em;
    border: 1px solid #ccc;
    border-radius: 6px; /* Subtle rounded corners */
    overflow: hidden; 
}

/* Styling for table header and data cells */
.bot-message th, 
.bot-message td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

/* Style the table header row */
.bot-message th {
    background-color: #f0f0f0; 
    font-weight: bold;
    color: #333;
    border-bottom: 2px solid #ccc; 
}

/* Remove the border from the last row */
.bot-message tr:last-child td {
    border-bottom: none;
}

/* Ensure the image preview wrapper inside the input bar looks correct */
.image-preview-wrapper {
    position: relative;
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}

.image-preview-wrapper img {
    max-height: 50px; /* Adjust size as needed */
    margin-right: 15px;
    border-radius: 4px;
}

.image-preview-wrapper button {
    position: absolute;
    top: -5px;
    right: 5px;
    /* Add more styling to make the X visible */
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 1;
    cursor: pointer;
    font-weight: bold;
}