/**
 * PPStore Custom Overrides
 * Tasks: header-top-bar mobile, single product styling, square images
 *
 * @package ppstore
 */

/* ==========================================================================
   Task 5: header-top-bar visible on ALL resolutions
   Fix: convert fixed/absolute header to normal document flow
   ========================================================================== */

/* Force the header wrapper into normal flow */
header.header-with-topbar {
    position: relative !important;
    z-index: 99;
}

/* Top bar: normal flow, not fixed/absolute */
header .header-top-bar {
    display: block !important;
    height: auto !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
}

/* Navbar: normal flow, not fixed/absolute */
header .header-top-bar + .navbar,
header .navbar,
header .navbar.disable-fixed,
header .header-top-bar + .navbar.disable-fixed {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
}

/* Remove top-space-margin/padding compensation - no longer needed */
.header-with-topbar + .top-space-margin,
.top-space-margin {
    margin-top: 0 !important;
}
.header-with-topbar + .top-space-padding,
.top-space-padding {
    padding-top: 0 !important;
}

/* Homepage: header overlays the hero section */
.ppstore-front-page header.header-with-topbar {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 99;
}
.ppstore-front-page header .header-top-bar {
    position: relative !important;
}
.ppstore-front-page header .navbar,
.ppstore-front-page header .navbar.disable-fixed {
    position: relative !important;
}

/* Homepage hero slider: on mobile/tablet, stop overlaying the header on the hero.
   The header flows normally so the slider starts right below it. */
@media (max-width: 991px) {
    .ppstore-front-page header.header-with-topbar {
        position: relative !important;
    }
    /* Ensure slider is tall enough for its content on small screens */
    .ppstore-front-page section.top-space-margin.sm-h-500px {
        height: auto !important;
        min-height: 500px;
    }
    .ppstore-front-page section.top-space-margin .swiper,
    .ppstore-front-page section.top-space-margin .swiper-slide {
        height: auto !important;
        min-height: 500px;
    }
    .ppstore-front-page section.top-space-margin .swiper-slide .container {
        padding-top: 30px;
        padding-bottom: 30px;
    }
}

/* On very small screens, reduce font size and padding for top bar */
@media (max-width: 575px) {
    header .header-top-bar .row {
        height: auto !important;
        min-height: 35px;
    }
    header .header-top-bar .fs-13 {
        font-size: 11px !important;
    }
    header .header-top-bar .col-lg-7 {
        padding: 5px 0;
    }
}

/* Extra small screens: shrink top bar links further to stay on one line */
@media (max-width: 374px) {
    .header-top-bar .col-lg-5 .widget,
    .header-top-bar .col-lg-5 a.widget,
    .header-top-bar .col-lg-5 > a,
    .header-top-bar .col-lg-5 > div,
    .header-top-bar .col-lg-5 .header-language-icon,
    .header-top-bar .col-lg-5 .header-language-icon .header-language a {
        font-size: 10px !important;
    }
    .header-top-bar .col-lg-5 {
        gap: 5px;
    }
}

/* ==========================================================================
   Task 6a: Single product - variation selects, quantity inputs, buttons
   ========================================================================== */

/* Variation select dropdowns */
.ppstore-single-product .variations select,
.ppstore-single-product table.variations select,
.ppstore-single-product .variations .value select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--extra-medium-gray, #e4e4e4);
    border-radius: 0;
    background-color: #fff;
    color: var(--dark-gray, #232323);
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23232323'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 10px;
    transition: border-color 0.3s ease;
}

.ppstore-single-product .variations select:focus,
.ppstore-single-product table.variations select:focus {
    outline: none;
    border-color: var(--base-color, #c89965);
}

/* Variation label styling */
.ppstore-single-product .variations .label label,
.ppstore-single-product table.variations .label label {
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-weight: 600;
    font-size: 14px;
    color: var(--dark-gray, #232323);
    text-transform: capitalize;
}

/* Variation table rows */
.ppstore-single-product .variations td,
.ppstore-single-product table.variations td {
    padding: 8px 0;
    vertical-align: middle;
}

.ppstore-single-product .variations tr,
.ppstore-single-product table.variations tr {
    border: none;
}

.ppstore-single-product table.variations {
    border: none;
    margin-bottom: 15px;
}

/* Reset variation link */
.ppstore-single-product .reset_variations {
    display: inline-block;
    margin-top: 8px;
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 13px;
    font-weight: 500;
    color: var(--base-color, #c89965);
    text-decoration: underline;
    visibility: visible !important;
}

/* Quantity input */
.ppstore-single-product .quantity input[type="number"],
.ppstore-single-product .quantity .qty {
    width: 80px;
    height: 50px;
    padding: 8px 10px;
    border: 1px solid var(--extra-medium-gray, #e4e4e4);
    border-radius: 0;
    background-color: #fff;
    color: var(--dark-gray, #232323);
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    -moz-appearance: textfield;
}

.ppstore-single-product .quantity input[type="number"]::-webkit-inner-spin-button,
.ppstore-single-product .quantity input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ppstore-single-product .quantity input[type="number"]:focus {
    outline: none;
    border-color: var(--base-color, #c89965);
}

/* Add to cart button */
.ppstore-single-product .single_add_to_cart_button,
.ppstore-single-product button.single_add_to_cart_button,
.ppstore-single-product .cart button[type="submit"] {
    display: inline-block;
    padding: 14px 35px;
    background-color: var(--dark-gray, #232323);
    color: #fff !important;
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid var(--dark-gray, #232323);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1.2;
}

.ppstore-single-product .single_add_to_cart_button:hover,
.ppstore-single-product button.single_add_to_cart_button:hover,
.ppstore-single-product .cart button[type="submit"]:hover {
    background-color: transparent;
    color: var(--dark-gray, #232323) !important;
}

/* Variation add to cart form layout */
.ppstore-single-product .woocommerce-variation-add-to-cart {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

/* Variation price */
.ppstore-single-product .woocommerce-variation-price .price {
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 24px;
    font-weight: 700;
    color: var(--dark-gray, #232323);
    margin-bottom: 10px;
}

/* General WC buttons on single product */
.ppstore-single-product .button,
.ppstore-single-product button.button,
.ppstore-single-product input.button,
.ppstore-single-product a.button {
    display: inline-block;
    padding: 12px 28px;
    background-color: var(--dark-gray, #232323);
    color: #fff;
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid var(--dark-gray, #232323);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.ppstore-single-product .button:hover,
.ppstore-single-product button.button:hover,
.ppstore-single-product input.button:hover,
.ppstore-single-product a.button:hover {
    background-color: transparent;
    color: var(--dark-gray, #232323);
}

/* ==========================================================================
   Task 6b: Gallery thumbnails aligned LEFT of main image (vertical)
   ========================================================================== */

/* Product image container: flex row with thumbs on left, main on right */
.ppstore-single-product .col-lg-6 > .row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
}

/* Thumbnail column - vertical strip on the left */
.ppstore-single-product .ppstore-thumb-col {
    flex: 0 0 100px;
    max-width: 100px;
    width: 100px;
    padding-right: 10px;
    padding-left: 0;
    order: -1;
}

/* Main image column - takes remaining space */
.ppstore-single-product .ppstore-main-image-col {
    flex: 1;
    min-width: 0;
    padding-left: 0;
}

/* Swiper thumb container: vertical direction */
.ppstore-single-product .ppstore-vertical-thumbs {
    height: 100% !important;
    overflow: hidden;
}

.ppstore-single-product .ppstore-vertical-thumbs .swiper-wrapper {
    flex-direction: column;
}

.ppstore-single-product .ppstore-vertical-thumbs .swiper-slide {
    width: 100% !important;
    height: auto !important;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    box-sizing: border-box;
}

.ppstore-single-product .ppstore-vertical-thumbs .swiper-slide-thumb-active,
.ppstore-single-product .ppstore-vertical-thumbs .swiper-slide:hover {
    opacity: 1;
    border: 2px solid var(--base-color, #c89965);
}

.ppstore-single-product .ppstore-vertical-thumbs .swiper-slide img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    width: 100%;
    display: block;
}

/* Responsive: on small screens thumbnails go below horizontally */
@media (max-width: 767px) {
    .ppstore-single-product .col-lg-6 > .row {
        flex-direction: column;
        flex-wrap: wrap;
    }
    .ppstore-single-product .ppstore-thumb-col {
        flex: 0 0 auto;
        max-width: 100%;
        width: 100%;
        padding-right: 15px;
        padding-left: 15px;
        order: 1;
        margin-top: 10px;
    }
    .ppstore-single-product .ppstore-main-image-col {
        padding-left: 15px;
        padding-right: 15px;
    }
    .ppstore-single-product .ppstore-vertical-thumbs .swiper-wrapper {
        flex-direction: row;
    }
    .ppstore-single-product .ppstore-vertical-thumbs .swiper-slide {
        width: 80px !important;
        margin-right: 10px;
    }
}

/* ==========================================================================
   Task 7: Square product images and thumbnails, zoom at max 1000px
   ========================================================================== */

/* Product images in shop grid/loop - square crop */
.shop-box .shop-image img,
.shop-boxed .shop-image img,
.grid-item .shop-image img,
.product-image-slider .swiper-slide img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    width: 100%;
    height: auto;
}

/* Category images - square */
.categories-box .icon-box img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* Single product main image - square */
.ppstore-single-product .product-image-slider .swiper-slide img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    width: 100%;
}

/* WooCommerce default image sizes - square */
.woocommerce ul.products li.product a img,
.woocommerce-page ul.products li.product a img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    width: 100%;
    height: auto;
}

/* Gallery lightbox / zoom - max 1000px width, maintain proportions */
.mfp-img,
.mfp-figure img,
img.zoomImg,
.woocommerce-product-gallery__image img.wp-post-image,
.gallery-box a img.mfp-open {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
}

/* Magnific Popup max width */
.mfp-container .mfp-content {
    max-width: 1000px;
}

.mfp-figure::after {
    max-width: 1000px;
}

/* Mini cart thumbnails - square */
.cart-item .product-image img,
.header-cart .cart-item img.cart-thumb {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* ==========================================================================
   Shop toolbar: storefront-sorting layout (flex row)
   ========================================================================== */

/* Flex row: result-count left, ordering select right */
.storefront-sorting {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 15px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--extra-medium-gray, #e4e4e4);
}

/* Result count stays left */
.storefront-sorting .woocommerce-result-count {
    margin: 0;
    order: 1;
    font-size: 14px;
    color: var(--medium-gray, #888e95);
}

/* Ordering select goes right */
.storefront-sorting .woocommerce-ordering {
    margin: 0;
    order: 2;
}

.storefront-sorting .woocommerce-ordering select.orderby {
    padding: 10px 36px 10px 15px;
    border: 1px solid var(--extra-medium-gray, #e4e4e4);
    border-radius: 0;
    background-color: #fff;
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 14px;
    font-weight: 500;
    color: var(--dark-gray, #232323);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23232323'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 10px;
    cursor: pointer;
    transition: border-color 0.3s ease;
    min-width: 220px;
}

.storefront-sorting .woocommerce-ordering select.orderby:focus {
    outline: none;
    border-color: var(--base-color, #c89965);
}

/* Notices wrapper: full-width row above the flex items */
.storefront-sorting .woocommerce-notices-wrapper {
    flex: 0 0 100%;
    width: 100%;
    order: 0;
}

/* ==========================================================================
   WooCommerce notices: preserve classic colored styles
   ========================================================================== */

.woocommerce-message,
.woocommerce-info,
.woocommerce-error,
.woocommerce-notices-wrapper .woocommerce-message,
.woocommerce-notices-wrapper .woocommerce-info,
.woocommerce-notices-wrapper .woocommerce-error {
    padding: 1em 1.5em;
    margin-bottom: 1.5em;
    border-top: 3px solid;
    background-color: #f8f8f8;
    font-size: 14px;
    line-height: 1.6;
    list-style: none;
    overflow: hidden;
}

/* Success (green) */
.woocommerce-message,
.woocommerce-notices-wrapper .woocommerce-message {
    border-top-color: #0f834d;
    background-color: #edf7f1;
    color: #0f834d;
}

.woocommerce-message a,
.woocommerce-message .button {
    color: #0f834d;
    font-weight: 600;
}

/* Info (blue) */
.woocommerce-info,
.woocommerce-notices-wrapper .woocommerce-info {
    border-top-color: #1e85be;
    background-color: #eaf4fa;
    color: #1e85be;
}

.woocommerce-info a,
.woocommerce-info .button {
    color: #1e85be;
    font-weight: 600;
}

/* Error (red) */
.woocommerce-error,
.woocommerce-notices-wrapper .woocommerce-error {
    border-top-color: #cc1818;
    background-color: #fbeaea;
    color: #cc1818;
}

.woocommerce-error a,
.woocommerce-error .button {
    color: #cc1818;
    font-weight: 600;
}

/* WC Block-based notice banners (newer WooCommerce) */
.wc-block-components-notice-banner.is-success {
    background-color: #edf7f1 !important;
    color: #0f834d !important;
    border-left: 4px solid #0f834d;
}

.wc-block-components-notice-banner.is-info {
    background-color: #eaf4fa !important;
    color: #1e85be !important;
    border-left: 4px solid #1e85be;
}

.wc-block-components-notice-banner.is-error {
    background-color: #fbeaea !important;
    color: #cc1818 !important;
    border-left: 4px solid #cc1818;
}

.wc-block-components-notice-banner.is-warning {
    background-color: #fff8e5 !important;
    color: #856404 !important;
    border-left: 4px solid #dba617;
}

/* Notice button styling (e.g. "Visualizza carrello") */
.woocommerce-message .button,
.woocommerce-info .button,
.woocommerce-error .button {
    float: right;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    text-decoration: underline;
    font-size: 14px;
}

/* ==========================================================================
   Breadcrumb: override Storefront's enormous separator padding
   (icons.css sets .woocommerce-breadcrumb .breadcrumb-separator padding ~6.85em)
   ========================================================================== */

.woocommerce-breadcrumb .breadcrumb-separator {
    padding: 0 6px !important;
}

/* ==========================================================================
   Fix 1: Lightbox (Magnific Popup) – keep image within viewport on all devices
   ========================================================================== */

.mfp-container {
    padding: 10px !important;
    box-sizing: border-box;
}

.mfp-content {
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100vh - 20px) !important;
    overflow: hidden;
}

.mfp-figure {
    max-width: 100% !important;
    overflow: hidden;
}

.mfp-figure figure {
    max-width: 100% !important;
    margin: 0;
}

.mfp-img {
    max-width: 100% !important;
    max-height: 90vh !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.mfp-figure::after {
    max-width: 100%;
}

.mfp-bottom-bar {
    max-width: 100% !important;
}

/* WooCommerce inline zoom overlay – constrain to image container */
img.zoomImg {
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Ensure the gallery wrapper doesn't overflow */
.woocommerce-product-gallery {
    overflow: hidden;
}

/* ==========================================================================
   Fix 2: header-top-bar mobile – both columns visible, compact, border
   ========================================================================== */

@media (max-width: 767px) {
    .header-top-bar .row {
        flex-direction: column;
        height: auto !important;
        padding: 6px 0;
    }
    .header-top-bar .col-lg-7 {
        line-height: 1.3;
        font-size: 12px !important;
        padding-bottom: 6px;
    }
    .header-top-bar .col-lg-7 .fs-13 {
        font-size: 12px !important;
    }
    /* Show the second column on mobile – single line */
    .header-top-bar .col-lg-5 {
        display: flex !important;
        justify-content: center;
        flex-wrap: nowrap;
        gap: 8px;
        padding-top: 6px;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        text-align: center !important;
        white-space: nowrap;
        overflow: hidden;
    }
    .header-top-bar .col-lg-5 .widget,
    .header-top-bar .col-lg-5 a.widget,
    .header-top-bar .col-lg-5 > a,
    .header-top-bar .col-lg-5 > div {
        font-size: 11px !important;
        margin-right: 0 !important;
        white-space: nowrap;
    }
    /* Override Crafto me-25px / md-me-15px utility margins */
    .header-top-bar .col-lg-5 .me-25px,
    .header-top-bar .col-lg-5 .md-me-15px {
        margin-right: 0 !important;
    }
    .header-top-bar .col-lg-5 .header-language-icon {
        font-size: 11px !important;
    }
    .header-top-bar .col-lg-5 .header-language-icon .header-language a {
        font-size: 11px !important;
    }
}

/* ==========================================================================
   Fix 3: Minicart – mobile: hide dropdown, go directly to cart page
   ========================================================================== */

@media (max-width: 991px) {
    /* On mobile, prevent the minicart dropdown from showing */
    .header-cart-icon .header-cart.open .cart-item-list,
    .header-cart-icon .header-cart .cart-item-list {
        display: none !important;
    }
}

/* ==========================================================================
   Fix 4: Variations table – clean aligned label + select layout
   WooCommerce uses <th class="label"> and <td class="value">
   ========================================================================== */

.ppstore-single-product table.variations {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: none;
    margin-bottom: 15px;
    table-layout: fixed;
}

.ppstore-single-product table.variations tr {
    border: none;
}

.ppstore-single-product table.variations td,
.ppstore-single-product table.variations th {
    padding: 8px 0;
    vertical-align: middle;
    border: none;
}

.ppstore-single-product table.variations th.label,
.ppstore-single-product table.variations td.label {
    width: 80px;
    white-space: nowrap;
    padding-right: 15px;
    text-align: left;
    font-weight: normal;
}

.ppstore-single-product table.variations th.label label,
.ppstore-single-product table.variations td.label label {
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-weight: 600;
    font-size: 14px;
    color: var(--dark-gray, #232323);
    text-transform: capitalize;
    margin: 0;
}

.ppstore-single-product table.variations td.value {
    width: auto;
}

.ppstore-single-product table.variations td.value select {
    width: 100%;
    max-width: 100%;
}

/* Reset variations link: moved outside table via JS, sits on its own row */
.ppstore-single-product .reset_variations {
    display: block;
    margin-top: 10px;
    font-family: var(--alt-font, 'Plus Jakarta Sans', sans-serif);
    font-size: 13px;
    font-weight: 500;
    color: var(--base-color, #c89965);
    text-decoration: underline;
}

@media (max-width: 575px) {
    .ppstore-single-product table.variations th.label,
    .ppstore-single-product table.variations td.label {
        width: 65px;
        padding-right: 10px;
    }
}

/* Responsive: stack on small screens */
@media (max-width: 575px) {
    .storefront-sorting {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .storefront-sorting .woocommerce-ordering {
        width: 100%;
    }
    .storefront-sorting .woocommerce-ordering select.orderby {
        width: 100%;
    }
}

/* ==========================================================================
   Wishlist: header badge, heart active state, wishlist page
   ========================================================================== */

/* Header wishlist icon – match cart icon spacing */
.header-wishlist-icon {
    /*margin-left: 20px;*/
}
.header-wishlist-icon a {
    position: relative;
    display: inline-block;
}

/* Wishlist badge – same style as .cart-count */
.ppstore-wishlist-count {
    position: absolute;
    top: -8px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 4px;
    border-radius: 50%;
    background-color: var(--base-color, #c89965);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

/* Wishlisted heart – active state (filled red heart) */
[data-wishlist-id].ppstore-wishlisted {
    color: #dc3545 !important;
}
[data-wishlist-id].ppstore-wishlisted i {
    color: #dc3545 !important;
}

/* Single product wishlist link – active state */
.product-info [data-wishlist-id].ppstore-wishlisted {
    color: #dc3545 !important;
}
.product-info [data-wishlist-id].ppstore-wishlisted + .feature-box-icon i,
.product-info .feature-box:has([data-wishlist-id].ppstore-wishlisted) .feature-box-icon i {
    color: #dc3545 !important;
}

/* Wishlist page */
#ppstore-wishlist-container .shop-boxed {
    margin-top: 0;
}

/* Wishlist page – grid item hover */
#ppstore-wishlist-container .shop-box {
    box-shadow: none;
    transition: box-shadow 0.3s ease;
}
#ppstore-wishlist-container .shop-box:hover {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

/* Wishlist empty state */
#ppstore-wishlist-container .text-center i.feather {
    opacity: 0.4;
}

