/**
 * Mobile Products Navigation Dropdown
 * Full-screen slide-in navigation for product categories on mobile
 *
 * @package Custom_Fiorentini
 * @since 1.2.0
 */

/* ==========================================================================
   TRIGGER BUTTON - Fixed at bottom of screen
   ========================================================================== */

.pf-mobile-products-trigger {
    display: none;
}

@media (max-width: 768px) {
    .pf-mobile-products-trigger {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 56px;
        padding: 0 20px;
        background: var(--pf-primary, #006b5a);
        color: var(--pf-white, #ffffff);
        font-family: 'Montserrat', sans-serif;
        font-size: 15px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        border: none;
        outline: none;
        cursor: pointer;
        z-index: 990;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        animation: pf-trigger-slide-up 0.4s ease-out;
        transition: background-color 0.3s ease, transform 0.3s ease;
    }

    .pf-mobile-products-trigger:hover,
    .pf-mobile-products-trigger:focus {
        background: var(--pf-primary-dark, #00544a);
    }

    .pf-mobile-products-trigger:active {
        transform: scale(0.98);
    }

    .pf-mobile-products-trigger:focus-visible {
        outline: 2px solid var(--pf-white, #ffffff);
        outline-offset: -4px;
    }

    .pf-mobile-products-trigger__icon {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
        transition: transform 0.3s ease;
    }

    .pf-mobile-products-trigger:hover .pf-mobile-products-trigger__icon {
        transform: scale(1.1);
    }

    .pf-mobile-products-trigger__text {
        white-space: nowrap;
    }

    .pf-mobile-products-trigger.is-active {
        background: #006b5a !important;
    }

    .pf-mobile-products-trigger.is-active .pf-mobile-products-trigger__icon {
        transform: rotate(90deg);
    }
}

@keyframes pf-trigger-slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Safe area for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .pf-mobile-products-trigger {
            padding-bottom: calc(12px + env(safe-area-inset-bottom));
            height: calc(56px + env(safe-area-inset-bottom));
        }
    }
}

/* Content spacing to prevent hiding behind trigger */
@media (max-width: 768px) {
    .pf-products-section {
        padding-bottom: 80px;
    }
}

/* ==========================================================================
   MENU CONTAINER
   ========================================================================== */

.pf-mobile-products {
    display: none;
}

@media (max-width: 768px) {
    .pf-mobile-products {
        display: block;
    }
}

/* ==========================================================================
   OVERLAY - Dark backdrop
   ========================================================================== */

.pf-mobile-products__overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 9998;
}

.pf-mobile-products.is-open .pf-mobile-products__overlay {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   NAVIGATION PANEL - Slide in from right
   ========================================================================== */

.pf-mobile-products__nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 380px;
    height: 100%;
    background: var(--pf-primary, #006b5a);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pf-mobile-products.is-open .pf-mobile-products__nav {
    transform: translateX(0);
}

@media (max-width: 400px) {
    .pf-mobile-products__nav {
        max-width: 100%;
    }
}

/* ==========================================================================
   HEADER - Title and close button
   ========================================================================== */

.pf-mobile-products__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.pf-mobile-products__title {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--pf-white, #ffffff);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

/* ==========================================================================
   CLOSE BUTTON
   ========================================================================== */

.pf-mobile-products__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.pf-mobile-products__close:hover,
.pf-mobile-products__close:focus {
    opacity: 0.7;
}

.pf-mobile-products__close:focus {
    outline: 2px solid var(--pf-primary, #006b5a);
    outline-offset: 2px;
}

.pf-mobile-products__close:active {
    transform: scale(0.95);
}

.pf-mobile-products__close svg {
    width: 24px;
    height: 24px;
    stroke: var(--pf-white, #ffffff);
}

/* ==========================================================================
   SCROLLABLE LIST CONTAINER
   ========================================================================== */

.pf-mobile-products__list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    margin: 0;
    list-style: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.pf-mobile-products__list::-webkit-scrollbar {
    width: 4px;
}

.pf-mobile-products__list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.pf-mobile-products__list::-webkit-scrollbar-thumb {
    background: var(--pf-primary, #006b5a);
    border-radius: 2px;
}

/* ==========================================================================
   LEVEL 1 - CATEGORY ITEMS (REGULATORS, METERS, etc.)
   ========================================================================== */

.pf-mobile-products__category {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pf-mobile-products__category:last-child {
    border-bottom: none;
}

.pf-mobile-products__category-header {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 56px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.3s ease;
}

.pf-mobile-products__category-header:hover {
    background: rgba(255, 255, 255, 0.1);
}

.pf-mobile-products__category-link {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 16px 0 16px 20px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--pf-white, #ffffff);
    text-decoration: none;
    transition: color 0.3s ease, background 0.3s ease;
}

.pf-mobile-products__category-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Category Label (non-clickable) */
.pf-mobile-products__category-label {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 16px 0 16px 20px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--pf-white, #ffffff);
    cursor: pointer;
    user-select: none;
    transition: color 0.3s ease, background 0.3s ease;
}

/* Hover handled by parent header row */

/* ==========================================================================
   TOGGLE BUTTONS (Expand/Collapse)
   ========================================================================== */

.pf-mobile-products__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.pf-mobile-products__toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.pf-mobile-products__toggle:focus {
    outline: 2px solid var(--pf-primary, #006b5a);
    outline-offset: -2px;
}

.pf-mobile-products__toggle svg {
    width: 16px;
    height: 16px;
    stroke: var(--pf-white, #ffffff);
    transition: transform 0.3s ease;
}

.pf-mobile-products__toggle.is-expanded svg {
    transform: rotate(90deg);
}

/* Small toggle for nested levels */
.pf-mobile-products__toggle--small {
    width: 48px;
    height: 48px;
}

.pf-mobile-products__toggle--small svg {
    width: 14px;
    height: 14px;
}

/* ==========================================================================
   LEVEL 2 - SUBCATEGORIES (High-Medium Pressure, Smart Gas Meters, etc.)
   ========================================================================== */

.pf-mobile-products__submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    list-style: none;
    margin: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.15);
}

.pf-mobile-products__submenu.is-expanded {
    max-height: 2000px;
}

.pf-mobile-products__subcategory {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pf-mobile-products__subcategory:last-child {
    border-bottom: none;
}

.pf-mobile-products__subcategory-header {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
    transition: background 0.3s ease;
}

.pf-mobile-products__subcategory-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.pf-mobile-products__subcategory-link {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 0 12px 40px;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--pf-white, #ffffff);
    text-decoration: none;
    transition: color 0.3s ease, background 0.3s ease;
}

.pf-mobile-products__subcategory-link:hover {
    color: var(--pf-primary, #006b5a);
    background: rgba(255, 255, 255, 0.05);
}

/* Subcategory Label (non-clickable, expands children) */
.pf-mobile-products__subcategory-label {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 0 12px 40px;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--pf-white, #ffffff);
    cursor: pointer;
    user-select: none;
    transition: background 0.3s ease;
}

/* Hover handled by parent header row */

/* Direct link subcategory (no children) */
.pf-mobile-products__subcategory--direct .pf-mobile-products__subcategory-link {
    padding-right: 20px;
}

/* ==========================================================================
   LEVEL 3 - PRODUCTS (Individual product links)
   ========================================================================== */

.pf-mobile-products__products {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    list-style: none;
    margin: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.1);
}

.pf-mobile-products__products.is-expanded {
    max-height: 1500px;
}

.pf-mobile-products__product {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.pf-mobile-products__product:last-child {
    border-bottom: none;
}

.pf-mobile-products__product-link {
    display: block;
    min-height: 44px;
    padding: 12px 20px 12px 60px;
    font-family: 'Open Sans', sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: background 0.3s ease, color 0.3s ease, padding-left 0.3s ease;
}

.pf-mobile-products__product-link:hover,
.pf-mobile-products__product-link:focus {
    background: rgba(255, 255, 255, 0.03);
    color: var(--pf-white, #ffffff);
    padding-left: 65px;
}

.pf-mobile-products__product-link:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(0, 107, 90, 0.3);
}

.pf-mobile-products__product-link.is-active {
    color: var(--pf-primary, #006b5a);
    font-weight: 600;
}

/* ==========================================================================
   BODY STATE - Prevent scroll when menu open
   ========================================================================== */

body.pf-mobile-products-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   WORDPRESS ADMIN BAR ADJUSTMENT
   ========================================================================== */

body.admin-bar .pf-mobile-products__nav {
    top: 32px;
    height: calc(100% - 32px);
}

@media (max-width: 782px) {
    body.admin-bar .pf-mobile-products__nav {
        top: 46px;
        height: calc(100% - 46px);
    }
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

@keyframes pf-mobile-nav-fade-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.pf-mobile-products.is-open .pf-mobile-products__category {
    animation: pf-mobile-nav-fade-in 0.3s ease forwards;
}

.pf-mobile-products.is-open .pf-mobile-products__category:nth-child(1) { animation-delay: 0.05s; }
.pf-mobile-products.is-open .pf-mobile-products__category:nth-child(2) { animation-delay: 0.1s; }
.pf-mobile-products.is-open .pf-mobile-products__category:nth-child(3) { animation-delay: 0.15s; }
.pf-mobile-products.is-open .pf-mobile-products__category:nth-child(4) { animation-delay: 0.2s; }
.pf-mobile-products.is-open .pf-mobile-products__category:nth-child(5) { animation-delay: 0.25s; }

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .pf-mobile-products__overlay,
    .pf-mobile-products__nav,
    .pf-mobile-products__toggle svg,
    .pf-mobile-products__submenu,
    .pf-mobile-products__products,
    .pf-mobile-products__category,
    .pf-mobile-products-trigger {
        transition: none;
        animation: none;
    }
}

/* ==========================================================================
   DESKTOP: COMPLETELY HIDDEN
   ========================================================================== */

@media (min-width: 769px) {
    .pf-mobile-products,
    .pf-mobile-products-trigger {
        display: none !important;
    }
}
