header {
    padding: 10px 20px;
}

.header-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between; 
    padding: 5px 0;
    margin: 0;
    position: relative;
    font-family: 'Poppins', sans-serif;
    width: 100%;
}

.logo-link { 
    display: block;
    width: 14%;
}

/* Mobile menu toggle button */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 14%;
    justify-content: flex-end;
}

.search-icon {
    cursor: pointer;
    font-size: 20px;
    color: #000;
    transition: color 0.3s ease;
    padding: 8px;
}

.search-icon:hover {
    color: #666;
}

.profile-icon {
    cursor: pointer;
    font-size: 20px;
    color: #000;
    transition: color 0.3s ease;
    padding: 8px;
    position: relative;
    display: block;
}

.profile-icon:hover {
    color: #666;
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #000;
    color: white;
    min-width: 180px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    border-radius: 0;
    padding: 0;
    margin-top: 5px;
    width: 200px;
}

.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    display: block;
}

.profile-dropdown-item {
    display: block;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.profile-dropdown-item:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
}

.mobile-menu-toggle {
    display: block;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.mobile-menu-toggle span {
    height: 2px;
    width: 100%;
    background-color: #000;
    transition: all 0.3s ease;
}

.nav-links {
    display: flex;
    gap: 0;
    position: relative;
    justify-content: center;
    flex: 1;
}

.nav-item {
    position: relative;
    padding: 0;
    border-radius: 0;
}

.nav-header {
    display: flex;
    align-items: center;
}

.dropdown-toggle,
.subdropdown-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 18px;
    color: #666;
}

header .nav-link {
    text-decoration: none;
    font-weight: 400;
    font-size: 16px;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.2s;
    padding: 20px 25px;
    display: block;
    position: relative;
    font-family: 'Poppins', sans-serif;
}

.nav-link:hover {
    color: #666;
    text-decoration: none !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: #000;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-item:hover .nav-link::after {
    width: 80%;
}

/* Modern dropdown styles */
.dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    width: auto;
    min-width: unset;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    transform: translateX(-50%) translateY(20px);
    transition: all 0.3s ease;
    z-index: 110;
    border-radius: 0;
    border-top: 1px solid #e5e5e5;
    padding: 30px 30px;
    font-family: 'Poppins', sans-serif;
}

/* Single column dropdown for categories with fewer items */
.dropdown.single-column {
    width: auto;
    min-width: unset;
}

.dropdown-content {
    display: flex;
    align-items: flex-start;
    gap: 60px;
}

.dropdown-section {
    display: flex;
    flex-direction: column;
    width: 200px;
}

.dropdown-header {
    display: none; /* Hide in desktop view */
}

.dropdown-link {
    color: #666;
    padding: 8px 0;
    text-decoration: none;
    display: block;
    font-size: 14px;
    position: relative;
    transition: all 0.2s ease;
    text-transform: capitalize;
    font-weight: 300;
    font-family: 'Poppins', sans-serif;
}

.dropdown-link:hover {
    color: #000;
    text-decoration: none !important;
    padding-left: 10px;
}

header .product-type-link {
    font-weight: 500;
    color: #000;
    margin-top: 0;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 16px;
    letter-spacing: 0.5px;
    font-family: 'Poppins', sans-serif;
}

.product-type-link:first-child {
    margin-top: 0;
}

header .category-link {
    padding-left: 0;
    margin-bottom: 2px;
    color: #666;
    font-size: 16px;
}

.category-link:hover {
    color: #000;
    padding-left: 10px;
}

/* Show dropdown on hover for desktop */
@media (min-width: 769px) {
    /* Hide toggle buttons on desktop */
    .dropdown-toggle,
    .subdropdown-toggle {
        display: none;
    }

    /* Force show dropdowns on hover only */
    .nav-item:hover > .dropdown {
        display: block;
        transform: translateX(-50%) translateY(0);
    }

    /* Desktop search icon positioning */
    .search-icon {
        display: block;
        font-size: 20px;
    }

    .profile-icon {
        display: block;
        font-size: 20px;
    }

    .header-actions {
        position: relative;
        display: flex;
        align-items: center;
        gap: 15px;
    }
}

/* Tablet and small desktop adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .dropdown {
        /* Prevent dropdown from going off-screen on tablets */
        left: 0;
        right: 0;
        transform: none;
        min-width: 500px;
        width: 500px;
    }

    .nav-item:hover > .dropdown {
        transform: none;
    }

    .dropdown.single-column {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .nav-item:hover > .dropdown.single-column {
        transform: translateX(-50%);
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        justify-content: flex-start;
        padding: 15px 0;
        position: relative;
    }

    .mobile-menu-toggle {
        display: flex;
        position: relative;
        width: 30px;
    }

    .header-actions {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        display: flex;
        align-items: center;
        gap: 25px;
        z-index: 2;
        width: auto;
        min-width: 80px;
        justify-content: flex-end;
    }

    .search-icon {
        font-size: 22px;
        display: block;
        flex-shrink: 0;
        width: 30px;
        text-align: center;
    }

    .profile-icon {
        font-size: 22px;
        display: block;
        flex-shrink: 0;
        width: 30px;
        text-align: center;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .logo-link {
        width: fit-content;
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        gap: 0;
        margin-top: 10px;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: white;
        z-index: 1000;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        display: none;
    }

    .nav-links.active {
        max-height: 1000px;
        display: block;
    }

    .nav-item {
        width: 100%;
        padding: 0;
        border-radius: 0;
        border-bottom: 1px solid #eee;
    }

    .nav-link {
        padding: 15px 20px;
        font-size: 16px;
        text-transform: none;
    }

    .nav-link::after {
        display: none;
    }

    .nav-header,
    .dropdown-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0;
    }

    .dropdown-toggle,
    .subdropdown-toggle {
        display: block;
        padding: 15px 20px;
    }

    .dropdown {
        position: static;
        box-shadow: none;
        display: block;
        transform: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        width: 100%;
        min-width: unset;
        padding: 0;
        border: none;
    }

    .dropdown.active {
        max-height: 1000px;
        width: 100%;
    }

    .dropdown-content {
        display: block;
        padding: 0;
        gap: 0;
    }

    .dropdown-section {
        margin-bottom: 0;
        width: 100%;
    }

    .dropdown-item {
        border-top: 1px solid #eee;
    }

    .product-type-link {
        display: none; /* Hide direct product type links on mobile */
    }

    .category-link {
        display: none; /* Hide direct category links on mobile */
    }

    .dropdown-header {
        display: flex !important; /* Show dropdown headers on mobile */
    }

    .dropdown-link {
        padding: 12px 20px;
    }

    .dropdown-link:hover {
        background-color: #f8f9fa;
        padding-left: 20px;
    }

    .dropdown .dropdown {
        left: 0;
        padding-left: 15px;
        background-color: #f8f9fa;
    }

    .featured-product {
        align-items: flex-start;
    }

    .search-icon {
        font-size: 22px;
    }

    .profile-icon {
        font-size: 22px;
        flex-shrink: 0;
    }

    .profile-dropdown {
        right: 0;
        min-width: 160px;
    }
}

/* Search Overlay Styles */
.search-overlay {
    position: fixed;
    top: 0;
    right: -45%;
    width: 40%;
    height: 100vh;
    background: white;
    z-index: 9999;
    transition: right 0.4s ease;
    box-shadow: -5px 0 20px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.search-overlay.active {
    right: 0;
}

.search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.search-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.search-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
}

.search-title {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin: 0;
}

.search-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    line-height: 1;
}

.search-close:hover {
    color: #000;
}

.search-content {
    padding: 30px;
}

.search-form {
    position: relative;
    margin-bottom: 30px;
}

.search-input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e5e5e5;
    border-radius: 0;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: #000;
}

.search-button {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
}

.search-button:hover {
    color: #000;
}

.search-section {
    margin-bottom: 30px;
}

.search-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #000;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.popular-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.category-tag {
    background: #f8f9fa;
    padding: 8px 15px;
    border-radius: 20px;
    text-decoration: none;
    color: #666;
    font-size: 13px;
    transition: all 0.3s ease;
    border: 1px solid #e5e5e5;
}

.category-tag:hover {
    background: #000;
    color: white;
    text-decoration: none;
}

.featured-products {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.featured-product {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    text-decoration: none;
    transition: background 0.3s ease;
    flex-direction: column;
}

.featured-product:hover {
    background: #e9ecef;
    text-decoration: none;
}

.product-image {
    width: 100%;
    height: 200px;
    background: #ddd;
    border-radius: 4px;
    flex-shrink: 0;
}

.product-info {
    flex: 1;
}

.featured-product .product-info {
    min-width: auto !important;
}

.product-title {
    font-size: 14px;
    font-weight: 500;
    color: #000;
    margin: 0 0 5px 0;
    line-height: normal;
}

.product-price {
    font-size: 13px;
    color: #666;
    margin: 0;
    font-weight: 500;
}

.product-price .original-price {
    text-decoration: line-through;
    color: #999;
    margin-right: 8px;
    font-size: 12px;
}

.product-price .current-price {
    color: #3a86ff;
    font-weight: bold;
    font-size: 14px;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
}

.rating-stars {
    display: flex;
    gap: 2px;
}

.rating-star {
    font-size: 12px;
    color: #ffc107;
}

.rating-star.empty {
    color: #e9ecef;
}

.rating-count {
    font-size: 11px;
    color: #999;
    margin-left: 5px;
}

/* Desktop: two-column dropdown with image */
@media (min-width: 1201px) {
    .dropdown-content {
        display: flex;
        gap: 60px;
        align-items: flex-start;
    }
    .dropdown-image {
        display: block;
        width: 220px;
        height: 280px;
        overflow: hidden;
        border-radius: 6px;
        background: #f8f8f8;
    }
    .dropdown-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }
}

@media (max-width: 1200px) {
    .dropdown-image {
        display: none !important;
    }
    .dropdown-content {
        display: flex;
    }
}

@media (max-width: 1023px) {
    .search-overlay.active {
        width: 80%;
    }

    .product-image {
        height: 300px;
    }

    .featured-product {
        align-items: flex-start;
    }
}

@media (max-width: 768px) {

    .dropdown-content {
        display: block;
        padding: 0;
        gap: 0;
    }

    .search-overlay.active {
        width: 90%;
    }

    .product-image { 
        height: 400px;
    }

    .search-icon {
        font-size: 22px !important;
        display: block;
        flex-shrink: 0;
    }
}

/* Additional mobile optimizations */
@media (max-width: 480px) {
    .header-content {
        padding: 10px 0;
        position: relative;
    }

    .header-actions {
        right: 10px;
        gap: 20px;
        min-width: 70px;
    }

    .search-icon {
        font-size: 20px;
        width: 25px;
    }

    .profile-icon {
        font-size: 20px;
        width: 25px;
    }

    .nav-link {
        font-size: 14px;
        padding: 12px 15px;
    }

    .dropdown-link {
        padding: 10px 15px;
        font-size: 13px;
        border: none;
    }

    .search-overlay {
        width: 100%;
        right: -120%;
    }

    .search-content {
        padding: 20px;
    }

    .featured-products {
        grid-template-columns: 1fr;
    }
}

/* Search Results Styles */
.search-results-container {
    margin-top: 20px;
    max-height: fit-content;
    overflow-y: auto;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e5e5;
}

.search-results-count {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.search-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Updated to match the PHP search results structure */
.search-results-container .featured-product {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    flex-direction: column;
}

.search-results-container .featured-product:hover {
    background: #e9ecef;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-results-container .product-image {
    width: 100%;
    height: 200px;
    background: #ddd;
    border-radius: 6px;
    flex-shrink: 0;
    overflow: hidden;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

.search-results-container .product-info {
    flex: 1;
    min-width: 0;
    width: 100%;
    text-align: center;
    padding-top: 10px;
}

.search-results-container .product-title {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    margin: 0 0 8px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-results-container .product-price {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    margin: 0;
}

.search-results-container .product-price.hidden {
    display: none;
}

/* Legacy search result styles for backward compatibility */
.search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.search-result-item:hover {
    background: #e9ecef;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-result-image {
    width: 80px;
    height: 80px;
    background: #ddd;
    border-radius: 6px;
    flex-shrink: 0;
    overflow: hidden;
}

.search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    margin: 0 0 8px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-description {
    font-size: 14px;
    color: #666;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-price {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    margin: 0;
}

.search-result-price.hidden {
    display: none;
}

.search-result-category {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

/* Loading States */
.search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
}

.search-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-loading-text {
    font-size: 14px;
    color: #666;
}

/* No Results State */
.search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.search-no-results-icon {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 15px;
}

.search-no-results-title {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin: 0 0 10px 0;
}

.search-no-results-text {
    font-size: 14px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* Error State */
.search-error {
    text-align: center;
    padding: 40px 20px;
    color: #dc3545;
}

.search-error-icon {
    font-size: 48px;
    color: #dc3545;
    margin-bottom: 15px;
}

.search-error-title {
    font-size: 18px;
    font-weight: 600;
    color: #dc3545;
    margin: 0 0 10px 0;
}

.search-error-text {
    font-size: 14px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* Search Input States */
.search-input.searching {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.search-input.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220,53,69,0.25);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .search-results-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .search-results-container .featured-product {
        padding: 12px;
        flex-direction: column;
        text-align: center;
    }

    .search-results-container .product-image {
        width: 100%;
        height: 150px;
        margin-bottom: 10px;
    }

    .search-results-container .product-info {
        width: 100%;
    }

    .search-results-container .product-title {
        font-size: 14px;
    }

    .search-results-container .product-price {
        font-size: 14px;
    }

    .search-result-item {
        padding: 12px;
        flex-direction: column;
        text-align: center;
    }

    .search-result-image {
        width: 100%;
        height: 150px;
        margin-bottom: 10px;
    }

    .search-result-info {
        width: 100%;
    }

    .search-result-title {
        font-size: 14px;
    }

    .search-result-description {
        font-size: 13px;
    }

    .search-result-price {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .search-results-container {
        max-height: fit-content;
    }

    .search-loading {
        padding: 30px 15px;
    }

    .search-no-results,
    .search-error {
        padding: 30px 15px;
    }

    .search-loading-spinner {
        width: 30px;
        height: 30px;
    }

    .search-no-results-icon,
    .search-error-icon {
        font-size: 36px;
    }
}

/* Specific styling for merchandise search results */
.search-results-container p {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
    margin: 0;
}


/* Ensure proper spacing for search results */
.search-results-container > .featured-product {
    margin-bottom: 0;
}

.search-results-container > .featured-product:not(:last-child) {
    margin-bottom: 15px;
}

/* Handle the case where results are displayed as individual items */
.search-results-container > a.featured-product {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.search-results-container > a.featured-product:last-child {
    margin-bottom: 0;
}
