/* ========================================= */
/* THEME COLORS                              */
/* ========================================= */
:root {
    --primary-green: #00A847;
    --primary-green-dark: #00933F;
    --text-dark: #2d3436;
    --text-gray: #636e72;
    --bg-light: #fafafa;
}

/* ========================================= */
/* BASE STYLES                               */
/* ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Inter", sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

a {
    text-decoration: none;
}

/* ========================================= */
/* HEADER & NAVBAR                           */
/* ========================================= */
header {
    background: #fff;
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}

.header-hidden {
    transform: translateY(-100%);
}

.nav-links {
    display: none;
}

@media (min-width: 768px) {
    .nav-links {
        display: flex;
        gap: 30px;
        align-items: center;
    }

    .nav-links a {
        font-weight: 500;
        color: var(--text-dark);
        text-decoration: none;
        position: relative;
        transition: color 0.3s;
    }

    .nav-links a::after {
        content: '';
        position: absolute;
        width: 100%;
        transform: scaleX(0);
        height: 2px;
        bottom: -5px;
        left: 0;
        background-color: var(--primary-green);
        transform-origin: bottom right;
        transition: transform 0.3s ease-out;
    }

    .nav-links a:hover::after {
        transform: scaleX(1);
        transform-origin: bottom left;
    }

    .nav-links a:hover {
        color: var(--primary-green);
    }

    .nav-links a.nav-active {
        color: var(--primary-green);
    }
}

/* -------- Mega Menu Dropdown -------- */
/* Updated for nav-item structure */
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-item a {
    /* Ensures link styling is correct */
    font-weight: 500;
    color: var(--text-dark);
    text-decoration: none;
    position: relative;
    transition: color 0.3s;
}

.dropdown-trigger {
    display: flex; /* Make it clickable area */
    align-items: center;
    padding: 5px 0 5px 5px; /* Add padding for better click area */
    cursor: pointer;
    color: var(--text-dark);
    transition: color 0.3s;
}

.dropdown-trigger:hover {
    color: var(--primary-green);
}

.dropdown-arrow {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

/* Mega menu appears only on hovering the entire nav-item OR the dropdown trigger */
.nav-item:hover .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-item:hover .dropdown-arrow,
.dropdown-trigger:hover .dropdown-arrow {
    transform: rotate(180deg);
}


.mega-menu {
    position: absolute;
    top: calc(100% + 15px);
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    /* Changed translateY(-10px) to translateY(10px) to match common.css fix later */
    transform: translateY(10px); 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    margin-top: -5px; /* Adjust positioning */
}

/* FIX: Prevent hover during scroll */
.nav-item.no-hover .mega-menu {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: none !important;
    transform: translateY(10px) !important;
}

.mega-menu.force-hide {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: none !important;
}

.mega-menu-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mega-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.mega-menu-item:hover {
    background: var(--primary-green);
    color: white;
    transform: translateX(5px);
}

.mega-menu-item:hover span,
.mega-menu-item:hover i {
    color: white;
}

.mega-icon {
    font-size: 1.5rem;
}

.about-link {
    scroll-behavior: smooth;
}

/* -------- Logo Section -------- */
.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-name {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(90deg, #006400, #00a83a, #4CFF89);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Header Icons */
.header-icons {
    display: flex;
    gap: 20px;
    align-items: center;
}

.icon-btn {
    font-size: 1.2rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.3s;
}

.icon-btn:hover {
    color: var(--primary-green);
}

/* Search */
.search-wrapper {
    position: relative;
}

.search-trigger {
    cursor: pointer;
    transition: color 0.3s;
}

.search-trigger:hover {
    color: var(--primary-green);
}

.search-expand {
    display: none;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 2px solid var(--primary-green);
    border-radius: 50px;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(0,168,71,0.15);
}

.search-expand.active {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.search-expand input {
    border: none;
    outline: none;
    padding: 5px;
    width: 200px;
    font-size: 0.95rem;
}

.search-close {
    cursor: pointer;
    color: var(--text-gray);
    transition: color 0.3s;
}

.search-close:hover {
    color: var(--primary-green);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.cart-count {
    background: #ff6b6b;
    position: absolute;
    top: -8px;
    right: -8px;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    font-weight: bold;
}

/* ---------------- Modals ---------------- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    padding-top: 60px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation: modalopen 0.4s;
}

@keyframes modalopen {
    from { opacity: 0; transform: translateY(-50px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-modal:hover,
.close-modal:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    font-family: 'Poppins', sans-serif;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    border-color: var(--primary-green);
    outline: none;
}

.btn-primary {
    width: 100%;
    background: var(--primary-green);
    color: white;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: var(--primary-green-dark);
}

.auth-switch {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--primary-green);
    font-weight: 500;
}

/* Cart Modal */
.cart-modal {
    max-width: 500px;
}

.cart-items {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.cart-item:last-child {
    border-bottom: none;
}

.item-details {
    display: flex;
    align-items: center;
    gap: 15px;
}

.item-details img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.item-name {
    font-weight: 500;
}

.item-quantity-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-quantity-control button {
    background: #f3f3f3;
    border: 1px solid #ccc;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.item-quantity-control button:hover {
    background: #e0e0e0;
}

.item-price {
    font-weight: 600;
    color: var(--primary-green);
}

.cart-total {
    text-align: right;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

.checkout-btn {
    margin-top: 0.5rem;
}

/* ========================================= */
/* GROCERIES PAGE                            */
/* ========================================= */

/* Hero Section */
.hero-grocery {
    background:
        linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)),
        url('https://images.pexels.com/photos/3962294/pexels-photo-3962294.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2')
        no-repeat center/cover;
    padding: 8rem 5%;
    text-align: center;
    color: #fff;
}

.hero-grocery h1 {
    font-size: 3.2rem;
    font-family: "Poppins", sans-serif;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-grocery p {
    font-size: 1.3rem;
    max-width: 700px;
    margin: auto;
}

/* NEW LOCAL SEARCH BAR STYLES */
.local-search-section {
    padding: 1rem 5%;
    background: var(--bg-light); /* Matches body background */
}

/* Container for search input and dropdown, used for positioning */
.local-search-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative; /* Crucial for positioning the dropdown */
}

.local-search-wrapper {
    display: flex;
    align-items: center;
    background: white;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 2px solid transparent;
    transition: border-color 0.3s;
    z-index: 10; /* Keep wrapper above dropdown */
    position: relative;
}

.local-search-wrapper:focus-within {
    border-color: var(--primary-green);
    box-shadow: 0 4px 20px rgba(0,168,71,0.2);
    border-bottom-left-radius: 8px; /* Square off bottom corners when active */
    border-bottom-right-radius: 8px;
}

.local-search-icon {
    color: var(--text-gray);
    font-size: 1.1rem;
    margin-right: 10px;
}

#productSearchInput {
    flex-grow: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    padding: 5px 0;
    color: var(--text-dark);
}

#productSearchInput::placeholder {
    color: var(--text-gray);
}

/* VOICE BUTTON STYLES */
.voice-search-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
    font-size: 1.1rem;
    margin-left: 10px;
    padding: 0 5px;
    transition: color 0.3s;
}

.voice-search-btn:hover {
    color: var(--primary-green);
}

.voice-search-btn.listening {
    color: #ff3838; /* Red dot for listening state */
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* AUTOCOMPLETE STYLES */
.product-suggestions {
    position: absolute;
    top: 100%; /* Position below the wrapper */
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--primary-green);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 5;
    display: none; /* Hidden by default */
}

.product-suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-item:hover {
    background: #f3f3f3;
}

.suggestion-item .category-tag {
    font-size: 0.75rem;
    color: var(--primary-green);
    font-weight: 500;
}
/* END AUTOCOMPLETE STYLES */


/* Filters */
.filter-section {
    background: white;
    padding: 2rem 5%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.filter-btn {
    padding: 0.7rem 1.8rem;
    border-radius: 50px;
    background: #f3f3f3;
    border: 2px solid transparent;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.filter-btn.active,
.filter-btn:hover {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
}

/* Product Cards */
.products-section {
    padding: 4rem 5%;
    max-width: 1400px;
    margin: auto;
    scroll-margin-top: 100px; /* For anchor links */
}

.section-title {
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-title h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    color: var(--text-dark);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.product-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: .3s;
    border: 1px solid #f0f0f0;
}

.product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #f0f0f0;
}

.product-info {
    padding: 1.5rem;
}

.product-category {
    color: var(--primary-green);
    font-size: 0.8rem;
    margin-bottom: .5rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.product-description {
    color: var(--text-gray);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.product-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-dark);
}

.add-to-cart {
    background: var(--primary-green);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    transition: background 0.3s;
    font-size: 0.9rem;
}

.add-to-cart:hover {
    background: var(--primary-green-dark);
    transform: translateY(-2px);
}

/* NEW: Added State for Button */
.add-to-cart.added {
    background-color: #27ae60; /* Success Green */
    cursor: default;
    pointer-events: none; /* Disable clicks */
    box-shadow: none;
    transform: none; /* Prevent hover transform */
}

/* Features */
.features-section {
    background: white;
    padding: 4rem 5%;
    margin: 4rem auto;
    border-radius: 20px;
    max-width: 1400px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 2.5rem;
    text-align: center;
}

.feature-item {
    padding: 1rem;
}

.feature-item i {
    font-size: 3rem;
    color: var(--primary-green);
    margin-bottom: 1rem;
}

.feature-item h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.feature-item p {
    color: var(--text-gray);
}

/* ========================================= */
/* FOOTER                                    */
/* ========================================= */
footer {
    background-color: #0b1120;
    color: #94a3b8;
    padding: 4rem 5% 1.5rem;
    margin-top: 4rem;
    scroll-margin-top: 80px;
}

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

.footer-col h4 {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.5px;
}

.footer-col p {
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-col ul li {
    margin-bottom: 0.8rem;
}

.footer-col ul li a {
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    display: inline-block;
}

.footer-col ul li a:hover {
    color: #3498db;
    transform: translateX(10px);
}

.footer-col.contact-col ul li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: #cbd5e1;
    font-size: 0.95rem;
}

.footer-col.contact-col i {
    margin-top: 4px;
    color: #cbd5e1;
    width: 16px;
}

.social-links {
    display: flex;
    gap: 12px;
}

.social-links a {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    text-decoration: none;
    font-size: 0.9rem;
}

.social-links a:hover {
    background: #3498db;
    border-color: #3498db;
    transform: translateY(-3px);
}

.copyright {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: #64748b;
}

/* --- Media Queries --- */
@media (max-width: 768px) {
    .hero-grocery h1 {
        font-size: 2.5rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }

    .nav-links {
        display: none;
    }

    .mega-menu {
        left: 50%;
        transform: translateX(-50%) translateY(10px); 
    }

    .nav-item:hover .mega-menu {
        transform: translateX(-50%) translateY(0);
    }
}
/* ========================================= */
/* SCROLL FIXES                              */
/* ========================================= */
html {
    scroll-behavior: smooth;
}

/* Header height compensation for anchor links */
section[id] {
    scroll-margin-top: 100px;
}

/* ==================== CHATBOT STYLES ==================== */

/* Floating Button */
.chatbot-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #007BFF;
    color: white;
    border-radius: 50%;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 9999;
    /* Smooth transition for hover effects */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hover Effect: Scale up and tilt slightly */
.chatbot-trigger:hover {
    transform: scale(1.1) rotate(-10deg);
    background-color: #0056b3;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* The Icon Element itself */
.chatbot-trigger i {
    transition: transform 0.3s ease;
}

/* ==================== WAVING ANIMATION ==================== */
/* Define the waving motion */
@keyframes wave-hand {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(15deg); }
    50% { transform: rotate(-5deg); }
    75% { transform: rotate(15deg); }
    100% { transform: rotate(0deg); }
}

/* Class to apply the animation (added via JS) */
.icon-waving {
    animation: wave-hand 2s infinite ease-in-out;
}

/* ... Keep your existing Window/Message styles below ... */
.chatbot-window { 
    /* ... existing styles ... */
    display: none;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 450px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    z-index: 9999;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid #007BFF;
    font-family: 'Inter', sans-serif;
}
/* ... rest of your CSS ... */

.chatbot-window.active {
    display: flex;
}

/* Header */
.chatbot-header {
    background: #007BFF; /* Primary Blue */
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

#closeChatbot {
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #e9ecef; /* Lighter background for messages */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Dark bubble for the USER so it stands out */
.user-message {
    background-color: #333; /* Dark Grey background */
    color: #fff;            /* White text */
    align-self: flex-end;   /* Pushes to the right */
    text-align: right;
    padding: 10px 15px;
    border-radius: 15px 15px 0 15px;
    max-width: 80%;
    margin-bottom: 5px;     /* Small gap between messages */
    display: block;         /* Ensures it takes up space */
}

/* Light bubble for the BOT */
.bot-message {
    background-color: #e5e7eb; /* Light Grey/Blue background */
    color: #1f2937;            /* Dark text */
    align-self: flex-start;    /* Pushes to the left */
    text-align: left;
    padding: 10px 15px;
    border-radius: 15px 15px 15px 0;
    max-width: 80%;
    margin-bottom: 5px;
    display: block;
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ced4da;
    background: white;
    align-items: center;
}

#chatbotInput {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 20px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

#chatbotInput:focus {
    border-color: #007BFF;
}

#sendChatbotMsg {
    background: none;
    border: none;
    color: #007BFF; /* Blue Send Icon */
    font-size: 20px;
    margin-left: 10px;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

#sendChatbotMsg:hover {
    color: #0056b3;
}