/* ================================================================== */
/*  Plugin Header — Frontend Styles                                   */
/* ================================================================== */

/* ---------- Reset & Variables ------------------------------------ */
:root {
    --ph-bg: #ffffff;
    --ph-text: #333333;
    --ph-logo-size: 50px;
    --ph-header-padding-x: 32px;
    --ph-header-padding-y: 0;
    --ph-dropdown-bg: #ffffff;
    --ph-dropdown-shadow: 0 8px 32px rgba(0, 0, 0, .12);
    --ph-border: rgba(0, 0, 0, .08);
    --ph-hover-bg: rgba(0, 0, 0, .04);
    --ph-transition: .25s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Header Base ----------------------------------------- */
.ph-header {
    background: var(--ph-bg);
    color: var(--ph-text);
    width: 100%;
    z-index: 99999;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    transition: box-shadow var(--ph-transition);
}

.ph-header *,
.ph-header *::before,
.ph-header *::after {
    box-sizing: border-box;
}

/* Sticky */
.ph-header.ph-sticky {
    position: sticky;
    top: 0;
}

/* WP Admin Bar offset */
.admin-bar .ph-header.ph-sticky {
    top: 32px;
}

/* ---------- Inner Container ------------------------------------- */
.ph-header-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: var(--ph-header-padding-y) var(--ph-header-padding-x);
    display: flex;
    align-items: center;
    min-height: var(--ph-header-height, 64px);
}

/* ---------- Layout: Beside (default) ---------------------------- */
.ph-layout-beside .ph-header-inner {
    flex-direction: row;
}

/* ---------- Layout: Above --------------------------------------- */
.ph-layout-above .ph-header-inner {
    flex-direction: column;
    align-items: center;
}

.ph-layout-above .ph-logo {
    margin-bottom: 12px;
    padding-top: 16px;
}

.ph-layout-above .ph-nav {
    width: 100%;
    justify-content: center;
}

.ph-layout-above .ph-menu {
    justify-content: center;
}

/* ---------- Logo ------------------------------------------------ */
.ph-logo {
    flex-shrink: 0;
    margin-right: 24px;
    display: flex;
    align-items: center;
}

.ph-logo a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: opacity var(--ph-transition);
}

.ph-logo a:hover {
    opacity: .8;
}

.ph-logo img {
    display: block;
    height: auto !important;
    max-width: 100%;
    transition: all var(--ph-transition);
}

.ph-logo-crop .ph-logo img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    max-width: none; /* Allow fixed width from style attribute */
}

/* ---------- Navigation ------------------------------------------ */
.ph-nav {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.ph-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: var(--ph-menu-gap, 4px);
    justify-content: flex-end;
}

/* ---------- Menu Items ------------------------------------------ */
.ph-menu-item {
    display: flex;
    align-items: center;
    position: relative;
    border-radius: 6px;
    transition: background var(--ph-transition);
}

.ph-menu-item:hover {
    background: var(--ph-hover-bg);
}

.ph-menu-item:hover > a,
.ph-menu-item:hover .ph-dropdown-toggle {
    color: var(--ph-hover-color, var(--ph-text));
}

.ph-menu-item > a {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--ph-text);
    text-decoration: none;
    font-weight: 400;
    transition: color var(--ph-transition);
    white-space: nowrap;
}

.ph-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px 10px 0;
    cursor: pointer;
    color: var(--ph-text);
}

/* ---------- Active Page Styles ---------------------------------- */
/* Active Color & Style */
.ph-menu-item.ph-active > a {
    color: var(--ph-active-color, var(--ph-text));
}

/* Bold */
.ph-header[data-active-style="bold"] .ph-menu-item.ph-active > a {
    font-weight: 700 !important;
}

/* Underline */
.ph-header[data-active-style="underline"] .ph-menu-item.ph-active > a {
    position: relative;
}

.ph-header[data-active-style="underline"] .ph-menu-item.ph-active > a::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 16px;
    right: 16px;
    height: 2px;
    background: var(--ph-active-color, var(--ph-text));
    border-radius: 1px;
}

/* Both */
.ph-header[data-active-style="both"] .ph-menu-item.ph-active > a {
    font-weight: 700 !important;
    position: relative;
}

.ph-header[data-active-style="both"] .ph-menu-item.ph-active > a::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 16px;
    right: 16px;
    height: 2px;
    background: var(--ph-active-color, var(--ph-text));
    border-radius: 1px;
}

/* ---------- Chevron --------------------------------------------- */
.ph-chevron {
    transition: transform var(--ph-transition);
}

.ph-has-dropdown.open .ph-chevron {
    transform: rotate(180deg);
}

/* ---------- Product Dropdown ------------------------------------ */
.ph-has-dropdown {
    position: relative;
}

.ph-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 480px;
    background: var(--ph-dropdown-bg, #ffffff);
    border-radius: 12px;
    box-shadow: var(--ph-dropdown-shadow);
    border: 1px solid var(--ph-border);
    padding: 20px;
    z-index: 100;
    transform-origin: top right;
    animation: phDropIn .2s ease-out;
    max-height: calc(100vh - var(--ph-header-height, 64px) - 20px);
    overflow-y: auto;
}

.ph-layout-above .ph-dropdown {
    right: 50%;
    transform: translateX(50%);
}

.ph-has-dropdown.open .ph-dropdown {
    display: block;
}

@keyframes phDropIn {
    from {
        opacity: 0;
        margin-top: -8px;
    }
    to {
        opacity: 1;
        margin-top: 0;
    }
}

/* ---------- Products Grid --------------------------------------- */
.ph-products-grid {
    display: grid;
    grid-template-columns: repeat(var(--ph-prod-cols, 3), 1fr);
    gap: var(--ph-prod-gap, 16px);
}

/* ---------- Product Card ---------------------------------------- */
.ph-product-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--ph-text);
    border-radius: 10px;
    overflow: hidden;
    width: var(--ph-item-w, 100%);
    height: var(--ph-item-h, auto);
    position: relative;
}

.ph-product-card.ph-has-bg {
    background: var(--ph-bg);
    border: 1px solid var(--ph-border);
}

.ph-product-card.ph-has-shadow {
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

.ph-product-img-wrap {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ph-product-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    display: block;
}

.ph-product-caption {
    padding: 10px 12px;
    font-size: var(--ph-cap-fs, 13px);
    font-family: var(--ph-cap-ff, inherit);
    color: var(--ph-cap-color, inherit);
    text-align: var(--ph-cap-align, center);
    font-weight: 500;
    line-height: 1.35;
    width: 100%;
}

.ph-caption-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 4px;
    padding: 6px 10px;
    width: auto;
    max-width: 90%;
}

/* ---------- Product Badge --------------------------------------- */
.ph-product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f44336;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    z-index: 10;
    line-height: 1;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
}

/* ---------- Hamburger ------------------------------------------- */
.ph-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
    margin-left: auto;
}

.ph-hamburger span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: var(--ph-text);
    border-radius: 2px;
    transition: transform var(--ph-transition), opacity var(--ph-transition);
}

/* Hamburger open state */
.ph-hamburger.open span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.ph-hamburger.open span:nth-child(2) {
    opacity: 0;
}

.ph-hamburger.open span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* ================================================================ */
/*  RESPONSIVE                                                       */
/* ================================================================ */

@media (max-width: 1024px) {
    .ph-header-inner {
        padding: 0 16px;
        flex-wrap: wrap;
        min-height: 56px;
    }

    /* Force beside layout on mobile */
    .ph-layout-above .ph-header-inner {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .ph-layout-above .ph-logo {
        margin-bottom: 0;
        padding-top: 0;
    }

    .ph-logo {
        margin-right: auto;
    }

    .ph-hamburger {
        display: flex;
    }

    .ph-nav {
        display: none;
        width: 100%;
        flex-basis: 100%;
        order: 3;
    }

    .ph-nav.open {
        display: block;
        animation: phSlideDown .3s ease-out;
    }

    @keyframes phSlideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .ph-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px 0 16px;
    }

    .ph-menu-item {
        flex-wrap: wrap;
        border-radius: 8px;
    }
    
    .ph-menu-item > a {
        padding: 12px 16px;
        flex: 1;
    }

    /* Dropdown on mobile */
    .ph-dropdown {
        position: static;
        min-width: 100%;
        width: 100%;
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 16px 0;
        margin: 0;
        transform: none !important;
        right: auto !important;
        left: auto !important;
    }

    .ph-products-grid {
        grid-template-columns: repeat(var(--ph-prod-cols, 2), 1fr);
        gap: var(--ph-prod-gap, 10px);
        justify-items: center;
    }
}

@media (max-width: 480px) {
    .ph-products-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================================================ */
/*  PRINT                                                            */
/* ================================================================ */
@media print {
    .ph-header {
        display: none !important;
    }
}
