/* CSS Variables for consistent styling */
:root {
    --primary-color: #3498db;
    --secondary-color: #f8f9fa;
    --accent-color: #e74c3c;
    --text-color: #333;
    --light-text: #777;
    --white: #fff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

/* Basic box-sizing reset for all elements */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* New style for the product card link to make the entire card clickable */
.product-card-link {
    text-decoration: none;
    color: inherit;
}

.product-card {
    display: flex;
    flex-direction: column; /* Stacks children vertically */
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    height: 100%; /* Ensures cards in a grid have equal height */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-image {
    background-color: #f8f9fa; /* Light gray background for consistency */
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px; /* Ensures a consistent height for the image area */
    position: relative;
    border-bottom: 1px solid #eee;
}

.product-image i {
    font-size: 4rem; /* Large icon size */
    color: #007bff;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Prevents image from being stretched */
}

.product-details {
    padding: 15px;
    flex-grow: 1; /* Allows this section to fill remaining space */
}

/* Styles for other elements within product-details */
.product-category {
    font-size: 0.8em;
    color: #6c757d;
    text-transform: uppercase;
}

.product-title {
    font-size: 1.2em;
    font-weight: bold;
    margin: 5px 0;
}

.product-price {
    font-size: 1.1em;
    color: #007bff;
    font-weight: bold;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 10px;
}

/* Main body styling */
body {
    background-color: #f5f5f5;
    color: var(--text-color);
    line-height: 1.6;
}

/* Header and Navbar styling */
/* General Navbar Styles */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #3498db;
    text-decoration: none;
}

.search-bar {
    display: flex;
    flex-grow: 1;
    margin: 0 2rem;
    max-width: 600px;
}

#search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 9999px; /* This makes it pill-shaped */
    outline: none;
}

#search-button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    margin-left: -3rem; /* Overlaps with the input for a cleaner look */
    cursor: pointer;
}

/* Nav links container */
.nav-links-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link,
.btn-register {
    font-weight: 500;
    color: #4b5563;
    text-decoration: none;
    transition: color 0.2s;
}

.nav-link:hover {
    color: #3b82f6;
}

.btn-register {
    background-color: #3b82f6;
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
}

.user-avatar {
    height: 40px;
    width: 40px;
    background-color: #d1d5db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
}

/* Hamburger Menu Icon */
.hamburger-menu {
    display: none; /* Hidden on desktop */
    font-size: 1.5rem;
    background: none;
    border: none;
    color: #4b5563;
    cursor: pointer;
}

/* Responsive Styles for smaller screens (e.g., mobile) */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        padding: 1rem;
    }

    .search-bar {
        order: 3; /* Places search bar on a new line below */
        margin-top: 1rem;
    }

    .nav-links-container {
        display: none; /* Hide the links by default on mobile */
        flex-direction: column;
        width: 100%;
        background-color: #ffffff;
        padding: 1rem;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        position: absolute; /* Positions the menu right under the header */
        top: 6.5rem; /* Adjust this value to match your header's height */
        left: 0;
        z-index: 1000;
        border-radius: 0 0 10px 10px;
    }

    .nav-links-container.active {
        display: flex; /* Show the links when the 'active' class is added */
    }

    .nav-link,
    .btn-register {
        padding: 0.75rem 0;
        border-bottom: 1px solid #e5e7eb;
        width: 100%;
        text-align: center;
    }

    .hamburger-menu {
        display: block; /* Show the hamburger icon on mobile */
    }
}

/* Desktop auth buttons container - initially visible */
.auth-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.7rem 1.2rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
    border: 1px solid transparent;
}

.btn-login {
    background: transparent;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-register {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--white);
}

.btn-login:hover {
    background: var(--primary-color);
    color: var(--white);
}

.btn-register:hover {
    background: #1e6ea0;
}

/* Main content styling */
.main-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.filter-section {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group h3 {
    margin-bottom: 0.8rem;
    font-size: 1rem;
    color: var(--light-text);
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-chip {
    padding: 0.5rem 1rem;
    background-color: #f0f8ff;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-chip:hover,
.filter-chip.active {
    background-color: var(--primary-color);
    color: var(--white);
}

/* Price Slider Styling */
.price-range-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-container {
    position: relative;
    width: 100%;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
}

.slider-track {
    position: absolute;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 2px;
}

.range-slider {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    width: 100%;
    height: 4px;
    background: transparent;
    pointer-events: none;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border: 2px solid var(--white);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-top: -8px; /* Adjust to center the thumb vertically */
}

.range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border: 2px solid var(--white);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-top: -8px;
}

.price-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-display span {
    font-weight: 600;
    color: var(--text-color);
}

.price-range-container button {
    width: 100%;
    padding: 0.7rem 1.2rem;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.price-range-container button:hover {
    background-color: #1e6ea0;
}

.products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}



.products-count {
    color: var(--light-text);
}

.products-count.loading {
    color: var(--primary-color);
}

.sort-options select {
    padding: 0.5rem;
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    min-height: 200px; /* Min height to show loading message */
}

/* Loading and error message styling */
.loading-message, .error-message {
    text-align: center;
    grid-column: 1 / -1;
    font-size: 1.2rem;
    color: var(--light-text);
    margin-top: 2rem;
}

.error-message {
    color: var(--accent-color);
}

.product-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}
.nav-link {
    display: inline-block;
    padding: 8px 15px;
    font-size: 16px;
    font-weight: 500;
    color: white; /* Or your desired text color */
    background-color: #2a7fba; /* Or your desired button color */
    border-radius: 8px; /* Rounded corners */
    text-decoration: none; /* Removes the underline */
    transition: background-color 0.2s ease-in-out;
}

.nav-link:hover {
    background-color: var(--primary-dark); /* Darker shade on hover */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.product-image {
    height: 180px;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--light-text);
    position: relative;
}

.product-image i {
    font-size: 3.5rem;
}

.product-image .icon-tablet { color: #3498db; }
.product-image .icon-capsule { color: #e74c3c; }
.product-image .icon-syrup { color: #2ecc71; }
.product-image .icon-injection { color: #f1c40f; }
.product-image .icon-cream { color: #9b59b6; }
.product-image .icon-powder { color: #f39c12; }
.product-image .icon-drops { color: #34495e; }
.product-image .icon-inhaler { color: #1abc9c; }
.product-image .icon-patch { color: #e67e22; }
.product-image .icon-default { color: #555; }

.product-details {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-category {
    color: var(--light-text);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.product-title {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.product-price {
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.8rem 0;
    font-size: 1.2rem;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--light-text);
    margin-bottom: 1rem;
}

.product-stock {
    color: #27ae60;
    font-weight: 600;
}

.product-stock.low {
    color: #e67e22;
}

.product-stock.out-of-stock {
    color: var(--accent-color);
}

.pagination {
    display: flex;
    justify-content: center;
    margin: 3rem 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pagination a {
    color: var(--text-color);
    padding: 0.5rem 1rem;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s;
}

.pagination a.active,
.pagination a:hover {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

/* Footer styling */
footer {
    background-color: #222;
    color: var(--white);
    padding: 3rem 2rem;
    margin-top: 2rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--white);
}

.footer-about p {
    color: #bbb;
    font-size: 0.9rem;
}

.footer-links h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--white);
}

.footer-links ul {
    list-style: none;
}

.footer-links ul li a {
    color: #bbb;
    text-decoration: none;
    transition: color 0.3s;
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.footer-links ul li a:hover {
    color: var(--primary-color);
}

.copyright {
    text-align: center;
    padding-top: 2rem;
    margin-top: 2rem;
    border-top: 1px solid #444;
    color: #bbb;
    font-size: 0.9rem;
}

/* Responsive Styles */
@media (max-width: 992px) {
    .navbar {
        flex-direction: column;
        align-items: stretch;
        position: relative;
    }
    
    .logo {
        text-align: center;
        margin-bottom: 1rem;
    }

    .search-bar {
        margin-right: 0;
        margin-bottom: 1rem;
    }

    .hamburger-menu {
        cursor: pointer;
        font-size: 1.5rem;
        color: var(--primary-color);
        position: absolute;
        top: 1rem;
        right: 2rem;
    }

    .auth-buttons {
        display: none;
    }

    .mobile-menu {
        display: none;
        flex-direction: column;
        gap: 0.5rem;
        position: absolute;
        top: 70px;
        right: 2rem;
        background-color: var(--white);
        box-shadow: var(--shadow);
        border-radius: var(--border-radius);
        padding: 1rem;
        z-index: 99;
        width: 150px;
    }

    .mobile-menu.active {
        display: flex;
    }
    
    .filter-section {
        flex-direction: column;
    }

    .products-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sort-options {
        width: 100%;
    }
    
    .sort-options select {
        width: 100%;
    }
}
