/* =========================================================
   CEBU PANTRY - MODERN FRESH GROCERY THEME
   A clean, vibrant design for online grocery shopping
========================================================= */

/* =========================================================
   ROOT VARIABLES - Fresh Market Colors
========================================================= */
:root {
    /* Primary Brand Colors */
    --primary-green: #2D5F4C;
    --accent-green: #4A9B7F;
    --light-green: #E8F5F1;
    --fresh-mint: #A8E6CF;
    
    /* Neutrals */
    --white: #FFFFFF;
    --off-white: #F8FAFB;
    --light-gray: #E5EBE9;
    --medium-gray: #9CA8A4;
    --dark-gray: #4A5856;
    --text-dark: #1E2927;
    
    /* Accent Colors */
    --orange-accent: #FF6B35;
    --yellow-accent: #FFD23F;
    --red-badge: #E63946;
    
    /* Shadows & Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================
   GLOBAL RESET & BASE STYLES
========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--off-white);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================================
   HEADER - Fixed Navigation
========================================================= */
/* Header Main Container */
header {
    background: linear-gradient(135deg, #3d7e60, #549b7a);
    padding: 12px 20px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Row 1: Logo and Cart */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-logo img {
    height: 50px; /* Adjust based on your new logo's aspect ratio */
    width: auto;
    display: block;
}

/* Row 2 Styles */
.header-bottom {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-form {
    flex: 2;
}

.search-wrapper {
    position: relative; /* Essential for positioning the icon */
    width: 100%;
}

#search-input {
    width: 100%;
    padding: 10px 40px 10px 15px; /* Extra right padding for the icon */
    border-radius: 25px;
    border: none;
    font-size: 14px;
    outline: none;
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none; /* Allows clicks to go through to the input */
    color: #888;
    font-size: 16px;
}

/* Category Dropdown Styling */
.category-filter-container {
    flex: 1;
}

#category-filter {
    width: 100%;
    padding: 10px;
    border-radius: 25px;
    border: none;
    background-color: white;
    cursor: pointer;
    font-size: 14px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    main {
        margin-top: 140px; /* Space for the 2-row header */
    }
}

.search-form input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-dark);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.search-form input:focus {
    border-color: var(--white);
    background: var(--white);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-form input::placeholder {
    color: var(--medium-gray);
}

.search-form button {
    padding: 10px 24px;
    border: none;
    border-radius: 24px;
    background: var(--orange-accent);
    color: var(--white);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.search-form button:hover {
    background: #FF5722;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

/* Cart Icon */
#cart-icon-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
    margin-left: auto;
}

#cart-icon-container:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

#cart-icon {
    font-size: 1.5rem;
}

#cart-count {
    background: var(--red-badge);
    color: var(--white);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(230, 57, 70, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

#cart-count.visible {
    display: inline-block;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Category Filter */


.category-filter-container label {
    font-weight: 500;
    white-space: nowrap;
}

.category-dropdown {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-dark);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.category-dropdown:hover,
.category-dropdown:focus {
    border-color: var(--white);
    background: var(--white);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* =========================================================
   MAIN CONTENT AREA
========================================================= */
main {
    flex: 1;
    display: flex;
    gap: 24px;
    padding: 24px;
    margin-top: 120px;
    max-width: 1400px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* =========================================================
   PRODUCT GRID
========================================================= */
.product-list {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    align-content: start;
}

/* Product Card */
.product-item {
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.product-item::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-green), var(--fresh-mint));
    transform: scaleX(0);
    transition: transform 0.3s ease;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.product-item:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-green);
}

.product-item:hover::before {
    transform: scaleX(1);
}

.product-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.product-item:hover img {
    transform: scale(1.05);
}

.product-item h3 {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    margin: 8px 0;
    line-height: 1.4;
    color: var(--text-dark);
    min-height: 48px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-item p {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent-green);
    margin: 8px 0 12px;
}

.product-item button {
    width: 100%;
    margin-top: auto;
    padding: 10px 20px;
    border-radius: 24px;
    border: none;
    background: linear-gradient(135deg, var(--accent-green), var(--primary-green));
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(74, 155, 127, 0.3);
}

.product-item button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 155, 127, 0.4);
}

.product-item button:active {
    transform: translateY(0);
}

/* No Products Message */
#no-products-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--medium-gray);
    font-size: 1.1rem;
}

/* =========================================================
   CART SIDEBAR
========================================================= */
#cart-content {
    width: 320px;
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 200px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

#cart-content h2 {
    font-size: 1.4rem;
    color: var(--primary-green);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--light-green);
}

#cart-items {
    margin-bottom: 20px;
}

#cart-items p {
    color: var(--medium-gray);
    text-align: center;
    padding: 20px 0;
}

.cart-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background: var(--light-green);
    border-radius: 8px;
}

.cart-item span:first-child {
    font-weight: 500;
    color: var(--text-dark);
}

.cart-item span:nth-child(2) {
    font-weight: 700;
    color: var(--accent-green);
}

.cart-item div {
    display: flex;
    gap: 8px;
}

.cart-item button {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--accent-green);
    color: var(--white);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.cart-item button:hover {
    background: var(--primary-green);
}

.cart-total {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 16px 0;
    border-top: 2px solid var(--light-green);
    border-bottom: 2px solid var(--light-green);
    margin-bottom: 16px;
    color: var(--primary-green);
}

#cart-content > button {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 24px;
    background: var(--orange-accent);
    color: var(--white);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

#cart-content > button:hover {
    background: #FF5722;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

/* =========================================================
   MODALS
========================================================= */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: var(--white);
    margin: 40px auto;
    padding: 32px;
    max-width: 600px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 2rem;
    color: var(--medium-gray);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.close:hover {
    color: var(--red-badge);
    transform: rotate(90deg);
}

.modal h2 {
    color: var(--primary-green);
    margin-bottom: 24px;
    font-size: 1.8rem;
}

.modal h3 {
    color: var(--accent-green);
    margin: 20px 0 12px;
    font-size: 1.2rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--dark-gray);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(74, 155, 127, 0.1);
}

/* Order Items */
.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--light-green);
    border-radius: 8px;
}

.order-item button {
    padding: 4px 12px;
    margin-left: 4px;
    border: none;
    border-radius: 6px;
    background: var(--accent-green);
    color: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.order-item button:hover {
    background: var(--primary-green);
}

/* Payment Info */
.payment-info-display {
    margin-top: 16px;
    padding: 16px;
    background: var(--light-green);
    border-radius: 8px;
    border-left: 4px solid var(--accent-green);
}

.payment-info-display img {
    max-width: 150px;
    margin: 12px 0;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--orange-accent);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.btn-primary:hover {
    background: #FF5722;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--light-gray);
    color: var(--dark-gray);
}

.btn-secondary:hover {
    background: var(--medium-gray);
    color: var(--white);
}

/* Order Footer */
.order-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 2px solid var(--light-gray);
}

.order-footer p {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-green);
    margin-bottom: 16px;
}

#submit-order-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--accent-green), var(--primary-green));
    color: var(--white);
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(74, 155, 127, 0.3);
}

#submit-order-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 155, 127, 0.4);
}

#submit-order-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Success Modal */
.success-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 3000;
    padding: 20px;
}

.success-modal-content {
    background: var(--white);
    margin: 15% auto;
    padding: 48px 32px;
    max-width: 400px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: successPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successPop {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.success-icon svg {
    width: 100%;
    height: 100%;
}

.success-circle {
    stroke: var(--accent-green);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-check {
    stroke: var(--accent-green);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

.success-modal-content h2 {
    color: var(--primary-green);
    margin-bottom: 12px;
}

.success-modal-content p {
    color: var(--dark-gray);
    margin-bottom: 24px;
}

#close-success-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 24px;
    background: var(--accent-green);
    color: var(--white);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

#close-success-btn:hover {
    background: var(--primary-green);
    transform: translateY(-2px);
}

/* Order Summary Modal */
.order-summary-modal .modal-content {
    max-width: 500px;
}

.summary-items {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--light-green);
    border-radius: 8px;
}

.summary-item-name {
    flex: 1;
    font-weight: 500;
}

.summary-qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 12px;
}

.summary-item-qty {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: var(--accent-green);
    color: var(--white);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.qty-btn:hover {
    background: var(--primary-green);
}

.summary-item-price {
    font-weight: 700;
    color: var(--accent-green);
    min-width: 80px;
    text-align: right;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    padding: 16px;
    background: var(--light-green);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-green);
    margin-bottom: 20px;
}

.empty-cart-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--medium-gray);
}

/* Toast Notification */
.add-to-cart-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary-green);
    color: var(--white);
    padding: 16px 24px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(100px);
    transition: var(--transition);
    z-index: 4000;
    font-weight: 600;
}

.add-to-cart-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================================
   FOOTER
========================================================= */
footer {
    background: var(--primary-green);
    color: var(--white);
    text-align: center;
    padding: 24px 20px;
    margin-top: 60px;
}

footer p {
    margin-bottom: 12px;
}

.footer-links a {
    color: var(--white);
    text-decoration: none;
    margin: 0 8px;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--yellow-accent);
}

/* =========================================================
   RESPONSIVE DESIGN
========================================================= */
@media (max-width: 992px) {
    main {
        flex-direction: column;
        margin-top: 120px;
    }

    #cart-content {
        width: 100%;
        position: static;
        max-height: none;
    }

    .product-list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    header {
        padding: 12px 16px;
    }

    .header-logo {
        width: 100%;
        justify-content: space-between;
    }

    .header-logo img {
        height: 40px;
    }

    
    .header-controls {
        width: 100%;
    }

    .search-form {
        max-width: none;
    }

    #cart-icon-container {
        position: absolute;
        right: 16px;
        top: 12px;
    }

    main {
        padding: 16px;
        margin-top: 120px;
    }

    .product-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }

    .modal-content {
        padding: 24px;
        margin: 20px auto;
    }

    .modal-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    main {
        margin-top: 100px;
        padding: 12px;
    }

    .product-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .product-item {
        padding: 12px;
    }

    .product-item img {
        height: 120px;
    }

    .product-item h3 {
        font-size: 0.9rem;
        min-height: 40px;
    }

    .product-item p {
        font-size: 1rem;
    }

    .product-item button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    #cart-content {
        padding: 16px;
    }

    .add-to-cart-toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
        text-align: center;
    }
}

/* =========================================================
   UTILITY CLASSES
========================================================= */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* --- Modified Header Structure --- */

/* Row 1: Logo,  and Cart */
.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0; /* Removed margin to align with cart */
    flex: 1;
}

#cart-icon-container {
    margin-left: 0; /* Reset margin */
    flex-shrink: 0;
}

/* Row 2: Search and Category */
.header-bottom-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-form {
    flex: 2; /* Search takes more space */
    max-width: none; 
}

.category-filter-container {
    flex: 1; /* Category takes less space */
    width: auto;
}

@media (max-width: 768px) {
   

    /* Adjust the top row to fit all three elements */
    .header-top-row {
        gap: 8px;
        flex-wrap: nowrap;      /* Prevent wrapping to keep 1-row layout */
    }

    .header-logo img {
        height: 35px;           /* Slightly smaller logo for better fit */
    }

    /* Stack search and category only on very small screens to maintain 1-row where possible */
    .header-bottom-row {
        gap: 8px;
    }
    
    /* Ensure main content doesn't get hidden under the taller header */
    main {
        margin-top: 120px; 
    }
}