/*=============================================
=            General & Typography             =
=============================================*/
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: #f9f9f9;
    color: #1d1d1f;
}
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}
.section-title {
    font-size: 1.8em;
    font-weight: 600;
    margin-top: 40px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    color: #111;
    border-bottom: 1px solid #ddd;
}
h1, h2, h3, h4 {
    color: #111;
}

/*=============================================
=            Header & Navigation              =
=============================================*/
header {
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}
header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-nav a {
    text-decoration: none;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 20px;
    transition: all 0.2s ease;
}
.cart-link {
    background-color: #0071e3;
    color: #fff;
    border: 1px solid #0071e3;
}
.back-link {
    background: none;
    color: #0071e3;
    font-weight: 500;
    text-decoration: none;
    padding: 0;
}
.back-link:hover {
    text-decoration: underline;
}
.header-nav .btn-secondary, .header-nav .home-button {
    background-color: #fff;
    color: #0071e3;
    border: 1px solid #0071e3;
}
.header-nav .btn-secondary:hover {
    background-color: #f0f8ff;
}
.hamburger-menu, .mobile-nav { display: none; }

/*=============================================
=         Pixel-Perfect Filter Section        =
=============================================*/
.filter-section {
    background-color: #fff;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.filter-form {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: auto auto;
}
.form-group { margin: 0; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 1em;
}
.form-group select, .form-group input {
    width: 100%;
    padding: 12px 15px;
    box-sizing: border-box;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    font-size: 1em;
    background-color: #fff;
}
.search-bar-group {
    grid-column: 1 / -1; /* Full width on mobile */
}
.filter-buttons {
    grid-column: 1 / -1; /* Full width on mobile */
    display: flex;
    justify-content: flex-start;
}
@media (min-width: 1200px) {
    .filter-form {
        grid-template-columns: repeat(5, 1fr);
    }
    .search-bar-group {
        grid-column: 5 / 6; /* Last column */
        grid-row: 1 / 2;
    }
    .filter-buttons {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
        margin-top: 10px;
    }
}
.apply-filters-btn, .clear-filters-btn {
    padding: 12px 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
}
.apply-filters-btn {
    background-color: #28a745;
    color: white;
}
.clear-filters-btn {
    background-color: #6c757d;
    color: white;
}

/*=============================================
=          Product Grids & Cards              =
=============================================*/
.product-grid, .dashboard-grid, .favorites-grid { display: grid; gap: 20px; }
.product-grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.product-card, .featured-card { position: relative; }
.product-card { background: #fff; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); text-align: center; padding: 15px; display: flex; flex-direction: column; }
.product-card form { margin-top: auto; }
.card-image-container { max-width: 100%; height: 180px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.card-image-container img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.product-card h2, .featured-card h3 { font-size: 1em; font-weight: 600; margin: 0 0 5px 0; min-height: 40px; display: flex; align-items: center; justify-content: center; }
.product-card .price, .featured-card .price { font-size: 1.3em; font-weight: 600; color: #111; margin: 10px 0 15px 0; }
.product-card .details { font-size: 0.9em; color: #6e6e73; margin-bottom: 10px; height: 1.2em; overflow: hidden; }
.product-meta { display: flex; justify-content: center; gap: 8px; margin: 5px 0 10px 0; flex-wrap: wrap; }
.meta-item { font-size: 0.75em; font-weight: 500; padding: 3px 8px; border-radius: 12px; text-transform: uppercase; }
.category-tag { background-color: #e0e7ff; color: #4338ca; }
.brand-tag { background-color: #d1fae5; color: #047857; }
.featured-products-section { background: none; box-shadow: none; padding: 0; }
.featured-card { display: flex; flex-direction: column; height: 100%; background: #fff; border: 1px solid #eee; border-radius: 12px; padding: 15px; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

/* Favorite Button */
.favorite-btn { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(2px); border: 1px solid #ddd; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; z-index: 2; }
.favorite-btn svg { width: 20px; height: 20px; fill: #aaa; stroke: #888; stroke-width: 1.5; }
.favorite-btn.favorited svg { fill: #e53935; stroke: #e53935; }

/*=============================================
=       Final Add to Cart Button Style        =
=============================================*/
.quantity-add-to-cart { display: flex; align-items: center; background-color: #0071e3; border-radius: 8px; overflow: hidden; }
.quantity-add-to-cart .add-btn { flex-grow: 1; text-align: center; background: none; border: none; color: white; font-size: 1em; cursor: pointer; padding: 10px 15px; font-weight: 500; }
.quantity-controls { display: flex; align-items: center; border-left: 1px solid rgba(255, 255, 255, 0.4); flex-shrink: 0; }
.quantity-btn { background: none; border: none; color: white; font-size: 1.5em; cursor: pointer; width: 35px; height: 35px; }
.quantity-input { width: 40px; text-align: center; border: none; background: none; color: white; font-size: 1.1em; -moz-appearance: textfield; }
.quantity-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.loader { text-align: center; padding: 20px; font-size: 1.2em; display: none; }

/*=============================================
=            Shopping Cart Page               =
=============================================*/
.cart-container { display: flex; gap: 30px; align-items: flex-start; }
.cart-items-form { flex: 3; min-width: 0; }
.cart-summary { flex: 1; background-color: #fff; padding: 25px; border-radius: 12px; position: sticky; top: 100px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.cart-items-list { display: flex; flex-direction: column; gap: 15px; }
.cart-item-card { display: grid; grid-template-columns: auto 1fr auto auto auto auto; align-items: center; gap: 15px; background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.cart-item-image { width: 80px; height: 80px; object-fit: contain; border-radius: 6px; background: #f9f9f9; }
.cart-item-details strong { display: block; margin-bottom: 4px; font-weight: 600; }
.cart-item-details span { color: #666; font-size: 0.9em; }
.cart-item-price, .cart-item-subtotal { font-weight: 600; text-align: right; }
.cart-item-quantity-wrapper { position: relative; }
.cart-favorite-btn { position: absolute; top: 50%; left: 8px; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; background: none; border: none; }
.cart-favorite-btn svg { width: 16px; height: 16px; fill: #aaa; }
.cart-favorite-btn.favorited svg { fill: #e53935; }
.quantity-input-cart { width: 100px; padding: 8px; text-align: center; border: 1px solid #ccc; border-radius: 5px; padding-left: 38px; }
.cart-item-remove { font-size: 1.8em; color: #dc3545; text-decoration: none; font-weight: bold; }
.cart-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.update-cart-btn { background-color: #ffc107; color: #000; }
.clear-cart-btn { background-color: #6c757d; color: white; }
.update-cart-btn, .clear-cart-btn { border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 500; }

/*=============================================
=         Authentication & Dashboard          =
=============================================*/
.auth-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; background-color: #f0f2f5; padding: 20px; }
.auth-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.1); width: 100%; max-width: 420px; }
.auth-box h2 { text-align: center; margin-top: 0; margin-bottom: 10px; font-size: 2em; }
.auth-box p { text-align: center; color: #666; margin-bottom: 30px; }
.auth-btn { width: 100%; padding: 12px; background-color: #0071e3; color: white; border-radius: 8px; border: none; font-size: 1.1em; cursor: pointer; }
.auth-switch { margin-top: 25px; text-align: center; color: #666; }
.error-message { color: #dc3545; background: #f8d7da; border: 1px solid #f5c6cb; padding: 10px; border-radius: 5px; margin-bottom: 15px; }
.welcome-heading { margin-bottom: 20px; font-weight: 600; font-size: 2.5em; }
.dashboard-content { background-color: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); margin-bottom: 30px; }
.dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); margin-top: 20px; }
.favorites-grid .product-card { min-height: auto; }
.order-card { background: #fff; border-radius: 12px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08); display: flex; flex-direction: column; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; }
.order-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12); }
.order-card-header { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid #eee; }
.order-card-id { font-weight: bold; font-size: 1.1em; }
.order-card-date { font-size: 0.9em; color: #666; }
.order-card-image-section { padding: 15px; background-color: #f9f9f9; border-bottom: 1px solid #eee; }
.order-card-images { display: flex; justify-content: center; gap: 8px; min-height: 62px; align-items: center; }
.order-card-images img { width: 60px; height: 60px; object-fit: contain; border-radius: 6px; border: 1px solid #ddd; background-color: #fff; }
.no-images-text { font-size: 0.9em; color: #888; }
.order-card-info { padding: 15px; display: flex; flex-direction: column; gap: 12px; flex-grow: 1; }
.info-row { display: flex; justify-content: space-between; align-items: center; font-size: 1.1em; }
.info-label { color: #666; font-size: 0.9em; }
.info-value { font-weight: 600; }
.status-badges-group { justify-content: flex-end; gap: 8px; }
.order-card-actions { display: flex; justify-content: space-between; gap: 10px; padding: 15px; border-top: 1px solid #eee; background-color: #f9f9f9; }
.status-badge { padding: 4px 10px; border-radius: 15px; font-size: 0.8em; font-weight: bold; color: #fff; text-transform: capitalize; }
.status-pending, .status-unpaid { background-color: #ffc107; color: #000; }
.status-shipped { background-color: #17a2b8; }
.status-delivered, .status-paid { background-color: #28a745; }

/*=============================================
=            Modals & Overlays                =
=============================================*/
.modal { display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); }
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 25px; border-radius: 8px; width: 80%; max-width: 700px; animation: modal-fade-in 0.3s; }
@keyframes modal-fade-in { from {transform: translateY(-50px); opacity: 0;} to {transform: translateY(0); opacity: 1;} }
.modal-close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
#modal-body h3 { margin-top: 0; }
.summary-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.summary-table th, .summary-table td { padding: 10px; border-bottom: 1px solid #ddd; text-align: left; vertical-align: middle; }
.summary-table tfoot td { font-weight: bold; font-size: 1.1em; }
#floating-cart-icon { position: fixed; bottom: 20px; right: 20px; background-color: #0071e3; color: white; padding: 15px 20px; border-radius: 50px; text-decoration: none; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 1000; display: flex; align-items: center; gap: 10px; transform: translateY(150%); opacity: 0; transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out; }
#floating-cart-icon.show { transform: translateY(0); opacity: 1; }
#floating-cart-icon span { font-size: 1.5em; }

/*=============================================
=            Responsive Design                =
=============================================*/
@media (max-width: 992px) {
    body { font-size: 16px; }
    .container { padding: 15px; }
    h1 { font-size: 1.5em; }
    .desktop-nav { display: none; }
    .hamburger-menu { display: flex; flex-direction: column; justify-content: space-around; width: 30px; height: 25px; background: transparent; border: none; cursor: pointer; padding: 0; z-index: 1001; }
    .hamburger-menu span { width: 30px; height: 3px; background-color: #333; border-radius: 10px; transition: all 0.3s linear; position: relative; transform-origin: 1px; }
    .hamburger-menu.active span:nth-child(1) { transform: rotate(45deg); }
    .hamburger-menu.active span:nth-child(2) { opacity: 0; transform: translateX(20px); }
    .hamburger-menu.active span:nth-child(3) { transform: rotate(-45deg); }
    .mobile-nav { display: flex; flex-direction: column; background-color: #fff; position: absolute; top: 100%; left: 0; width: 100%; box-shadow: 0 4px 8px rgba(0,0,0,0.1); max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
    .mobile-nav.active { max-height: 300px; }
    .mobile-nav a { padding: 15px 20px; border-bottom: 1px solid #f0f0f0; text-align: center; }
    .cart-container { flex-direction: column; }
    .cart-summary { width: 100%; position: static; box-sizing: border-box; }
}
@media (max-width: 768px) { .product-grid, .dashboard-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 576px) { .product-grid, .dashboard-grid { grid-template-columns: 1fr; } .filter-form { grid-template-columns: 1fr; } }