/* --- GLOBAL FIX --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
}

/* --- PAGE LAYOUT --- */
.page-header {
    background-color: #f9f5f0;
    padding: 40px 20px;
    text-align: center;
    border-bottom: 1px solid #e5e5e5;
}

.page-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    color: #4a0404;
    margin-bottom: 5px;
}

.page-header p {
    color: #777;
    font-size: 0.9rem;
}

.catalog-container {
    display: flex;
    max-width: 1500px;
    margin: 40px auto;
    padding: 0 20px;
    gap: 30px;
}

/* --- LEFT SIDEBAR FILTERS --- */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    padding-right: 20px;
    border-right: 1px solid #eee;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filter-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    margin: 0;
}

.clear-btn {
    font-size: 0.8rem;
    color: #d32f2f;
    text-decoration: underline;
    cursor: pointer;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #333;
}

.divider {
    height: 1px;
    background: #eee;
    margin: 20px 0;
}

/* Custom Checkboxes */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.custom-checkbox {
    display: block;
    position: relative;
    padding-left: 30px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #555;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 2px;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    transition: all 0.2s;
}

.custom-checkbox:hover input~.checkmark {
    background-color: #f5f5f5;
}

.custom-checkbox input:checked~.checkmark {
    background-color: #4a0404;
    border-color: #4a0404;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked~.checkmark:after {
    display: block;
}

.custom-checkbox .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Price Range */
.price-slider-box {
    padding: 0 5px;
}

.slider {
    width: 100%;
    margin-bottom: 10px;
    accent-color: #4a0404;
}

.price-inputs {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #333;
    font-weight: bold;
}

/* Color Circles */
.color-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-circle {
    display: inline-block;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    border: 1px solid #ddd;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.color-circle input {
    display: none;
}

.color-circle:hover {
    transform: scale(1.1);
}

.color-circle input:checked::after {
    content: '\2713';
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.red {
    background-color: #e53935;
}

.green {
    background-color: #43a047;
}

.yellow {
    background-color: #fdd835;
}

.pink {
    background-color: #e91e63;
}

.blue {
    background-color: #1e88e5;
}

.white {
    background-color: #fff;
    border: 1px solid #ccc;
}

.white input:checked::after {
    color: #333;
    text-shadow: none;
}

/* --- PRODUCT GRID AREA --- */
.product-listing {
    flex-grow: 1;
    min-width: 0;
}

.listing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 10px;
}

.result-count {
    color: #777;
    font-size: 0.95rem;
}

.sort-box select {
    padding: 8px 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    max-width: 100%;
}

/* ========================================= */
/* --- PERFECTLY ALIGNED CUTE CARDS --- */
/* ========================================= */

.products-grid-3col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px 20px;
    align-items: stretch;
    width: 100%;
}

a.product-card {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    background: #fff;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 16px;
    /* Cute rounded corners */
    border: 1px solid #f0f0f0;
    cursor: pointer;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

a.product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(74, 4, 4, 0.08);
}

.prod-img-wrapper {
    position: relative;
    width: 100%;
}

/* MAGIC FIX: Removed fixed height, added aspect-ratio */
.prod-img {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    /* FORCES ALL IMAGES TO BE IDENTICAL SIZES */
    background: #fdf5f5;
    overflow: hidden;
}

.prod-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fills the box perfectly without stretching */
    object-position: top center;
    /* Keeps the model's head in the frame */
    transition: transform 0.6s ease;
}

a.product-card:hover .prod-img img {
    transform: scale(1.05);
}

/* Wishlist Button */
.wishlist-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #999;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: 0.3s;
    z-index: 2;
}

.wishlist-btn:hover {
    color: #e53935;
    transform: scale(1.1);
}

/* Product Details Area */
.prod-details {
    padding: 15px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    gap: 8px;
}

h5.product-name {
    font-family: 'Lato', sans-serif;
    font-size: 15px;
    color: #282c3f;
    margin: 0;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
}

.prod-details .price {
    font-size: 15px;
    color: #282c3f;
    font-weight: 700;
    margin: 0;
}

/* --- OUT OF STOCK IMAGE EFFECTS --- */
.product-card[data-stock="outofstock"] .prod-img img {
    filter: grayscale(100%);
    opacity: 0.8;
}

.oos-label {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    color: #cc0000;
    width: 100%;
    text-align: center;
    padding: 15px 0;
    font-family: 'Lato', sans-serif;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 2px;
    z-index: 5;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* --- PAGINATION --- */
.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 50px;
    margin-bottom: 50px;
}

.pagination a {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    transition: 0.3s;
    font-weight: bold;
}

.pagination a.active,
.pagination a:hover {
    background-color: #4a0404;
    color: white;
    border-color: #4a0404;
}

/* ========================================= */
/* --- RESPONSIVE MEDIA QUERIES --- */
/* ========================================= */

@media (max-width: 1200px) {
    .products-grid-3col {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .catalog-container {
        flex-direction: column;
        width: 100%;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #eee;
        margin-bottom: 20px;
        padding-right: 0;
    }

    .products-grid-3col {
        grid-template-columns: repeat(3, 1fr);
    }

    .sidebar-content {
        display: none;
        padding-top: 15px;
    }

    .sidebar-content.active {
        display: block;
    }

    .filter-toggle-btn {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 12px 15px;
        background-color: #f9f9f9;
        border: 1px solid #ddd;
        border-radius: 8px;
        cursor: pointer;
        font-weight: bold;
        color: #333;
        font-family: 'Lato', sans-serif;
    }

    .filter-toggle-btn i {
        transition: transform 0.3s;
    }

    .filter-toggle-btn.active i {
        transform: rotate(180deg);
    }

    .sidebar-content .filter-header {
        display: none;
    }
}

@media (min-width: 993px) {
    .filter-toggle-btn {
        display: none !important;
    }

    .sidebar-content {
        display: block !important;
    }
}

@media (max-width: 768px) {
    .products-grid-3col {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px 12px;
    }

    /* MAGIC FIX: Removed mobile height overrides so aspect-ratio stays perfectly active */

    .prod-details {
        padding: 12px 10px;
        gap: 5px;
    }

    h5.product-name {
        font-size: 13px;
    }

    .prod-details .price {
        font-size: 13px;
    }

    .oos-label {
        font-size: 12px;
        padding: 10px 0;
        letter-spacing: 1px;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .catalog-container {
        padding: 0 10px;
    }

    .products-grid-3col {
        gap: 12px 8px;
    }

    /* MAGIC FIX: Removed mobile height overrides so aspect-ratio stays perfectly active */

    h5.product-name {
        font-size: 12px;
    }

    .prod-details .price {
        font-size: 12px;
    }

    .wishlist-btn {
        width: 30px;
        height: 30px;
        font-size: 13px;
        top: 8px;
        right: 8px;
    }
}