/*
 * PricePro — base stylesheet
 * ----------------------------------------------------------------------------
 * Loaded on the public frontend (when shortcode/block is present), in the
 * Elementor preview iframe (unconditionally) and in both editors so authors
 * see the live render. All visual values are driven by CSS custom properties
 * with the `--pp-` prefix; per-instance overrides are emitted inline by
 * Renderer::generate_inline_css_vars(), scoped via [data-pricepro-id].
 */

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

.pricepro {
    --pp-accent: #3b82f6;
    --pp-bg: #ffffff;
    --pp-text: #1f2937;
    --pp-category-color: var(--pp-accent);
    --pp-radius: 8px;
    --pp-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --pp-border: rgba(0, 0, 0, 0.08);
    --pp-muted: rgba(0, 0, 0, 0.55);

    font-family: var(--pp-font-family);
    color: var(--pp-text);
    background: var(--pp-bg);
    padding: 2rem 1.5rem;
    border-radius: var(--pp-radius);
    max-width: 100%;
    line-height: 1.5;
}

.pricepro :focus-visible {
    outline: 2px solid var(--pp-accent);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
 * List
 * ------------------------------------------------------------------------- */

.pricepro-list__title {
    margin: 0 0 1.5rem;
    font-size: 1.75rem;
    text-align: center;
    color: var(--pp-text);
}

.pricepro-list__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.pricepro-list__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pricepro-list__tab {
    appearance: none;
    border: 1px solid var(--pp-border);
    background: transparent;
    color: var(--pp-text);
    padding: 0.5rem 1rem;
    border-radius: calc(var(--pp-radius) / 2);
    cursor: pointer;
    font: inherit;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pricepro-list__tab:hover {
    border-color: var(--pp-accent);
}

.pricepro-list__tab[aria-selected="true"],
.pricepro-list__tab--active {
    background: var(--pp-accent);
    color: #fff;
    border-color: var(--pp-accent);
}

.pricepro-list__search-input {
    appearance: none;
    border: 1px solid var(--pp-border);
    background: transparent;
    color: var(--pp-text);
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--pp-radius) / 2);
    font: inherit;
    min-width: 200px;
}

.pricepro-list__category {
    padding: 1.5rem 0;
}

.pricepro-list__category + .pricepro-list__category {
    border-top: 1px solid var(--pp-border);
}

.pricepro-list__category-title {
    margin: 0 0 0.75rem;
    color: var(--pp-category-color);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.pricepro-list__category-description {
    margin: 0 0 1rem;
    color: var(--pp-muted);
    font-size: 0.95rem;
}

.pricepro-list__items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1rem;
}

.pricepro-list__items--two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 2.5rem;
}

.pricepro-list__items--one-col {
    grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 640px) {
    .pricepro-list__items--two-cols {
        grid-template-columns: minmax(0, 1fr);
    }

    .pricepro-list__title {
        font-size: 1.5rem;
    }

    .pricepro {
        padding: 1.5rem 1rem;
    }
}

.pricepro-list__item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "image body price"
        "image button button";
    align-items: start;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--pp-border);
}

.pricepro-list__item:last-child {
    border-bottom: 0;
}

.pricepro-list__item-image {
    grid-area: image;
    width: 64px;
    height: 64px;
    overflow: hidden;
    border-radius: calc(var(--pp-radius) / 2);
    flex-shrink: 0;
}

.pricepro-list__item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pricepro-list__item-body {
    grid-area: body;
    min-width: 0;
}

.pricepro-list__item-name {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
}

.pricepro-list__item-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 0.7em;
    cursor: help;
    color: var(--pp-muted);
}

.pricepro-list__item-description {
    margin: 0;
    color: var(--pp-muted);
    font-size: 0.9rem;
}

.pricepro-list__item-price {
    grid-area: price;
    color: var(--pp-accent);
    font-weight: 600;
    white-space: nowrap;
    text-align: right;
}

.pricepro-list__item-compare-price {
    text-decoration: line-through;
    opacity: 0.5;
    margin-right: 0.5em;
    font-weight: 400;
    color: var(--pp-muted);
}

.pricepro-list__item-button {
    grid-area: button;
    justify-self: start;
    margin-top: 0.5rem;
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background: var(--pp-accent);
    color: #fff;
    border-radius: calc(var(--pp-radius) / 2);
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.15s ease;
}

.pricepro-list__item-button:hover {
    opacity: 0.9;
}

/* ---------------------------------------------------------------------------
 * Table
 * ------------------------------------------------------------------------- */

.pricepro-table__title {
    margin: 0 0 1.5rem;
    font-size: 1.75rem;
    text-align: center;
}

.pricepro-table__toggle {
    display: inline-flex;
    margin: 0 auto 2rem;
    border: 1px solid var(--pp-border);
    border-radius: 999px;
    padding: 0.25rem;
    background: transparent;
}

.pricepro-table__toggle-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--pp-text);
    padding: 0.4rem 1rem;
    font: inherit;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pricepro-table__toggle-btn[aria-pressed="true"],
.pricepro-table__toggle-btn--active {
    background: var(--pp-accent);
    color: #fff;
}

.pricepro-table__plans {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-items: stretch;
}

.pricepro-table--equalized .pricepro-table__plan {
    height: 100%;
}

.pricepro-table__plan {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--pp-bg);
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius);
    padding: 1.5rem;
    transition: transform 0.15s ease;
}

.pricepro-table__plan--recommended {
    border-width: 2px;
    border-color: var(--pp-accent);
    transform: translateY(-4px);
}

.pricepro-table__plan-badge {
    position: absolute;
    top: -0.75rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--pp-accent);
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.pricepro-table__plan-title {
    margin: 0.5rem 0 0.25rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.pricepro-table__plan-subtitle {
    margin: 0 0 1rem;
    color: var(--pp-muted);
    font-size: 0.9rem;
}

.pricepro-table__plan-price {
    margin: 0 0 1rem;
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.pricepro-table__plan-price-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--pp-accent);
    line-height: 1;
}

.pricepro-table__plan-recurrence {
    color: var(--pp-muted);
    font-size: 0.9rem;
}

.pricepro-table__plan-features {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    flex: 1;
}

.pricepro-table__plan-feature {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--pp-border);
    font-size: 0.95rem;
}

.pricepro-table__plan-feature:last-child {
    border-bottom: 0;
}

.pricepro-table__plan-feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
    border-radius: 50%;
    background: var(--pp-accent);
    color: #fff;
    font-size: 0.7em;
    flex-shrink: 0;
}

.pricepro-table__plan-feature--excluded .pricepro-table__plan-feature-icon {
    background: transparent;
    color: var(--pp-muted);
    border: 1px solid var(--pp-muted);
}

.pricepro-table__plan-feature--excluded .pricepro-table__plan-feature-text {
    color: var(--pp-muted);
    text-decoration: line-through;
}

.pricepro-table__plan-feature-tooltip {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 0.7em;
    cursor: help;
    color: var(--pp-muted);
}

.pricepro-table__plan-button {
    display: inline-block;
    text-align: center;
    padding: 0.6rem 1rem;
    background: var(--pp-accent);
    color: #fff;
    border-radius: calc(var(--pp-radius) / 2);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.15s ease;
    margin-top: auto;
}

.pricepro-table__plan-button:hover {
    opacity: 0.9;
}

/* ---------------------------------------------------------------------------
 * Dark mode (skipped for templates that already use a dark palette)
 * ------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
    .pricepro:not([data-template="restaurant"]) {
        --pp-bg: #1f2937;
        --pp-text: #f3f4f6;
        --pp-border: rgba(255, 255, 255, 0.12);
        --pp-muted: rgba(255, 255, 255, 0.55);
    }
}

/* ---------------------------------------------------------------------------
 * Phase 5 — JS-driven interactions
 * ------------------------------------------------------------------------- */

/* Items / panels filtered out by JS must collapse, even when the layout sets
   display: grid/flex on them. */
.pricepro [hidden] {
    display: none !important;
}

/* Smooth crossfade when the billing toggle swaps the price text. */
.pricepro-table__plan-price-amount {
    transition: opacity 0.15s ease-out;
}

/* Tooltip popup driven by aria-label — pure CSS, shows on hover and focus. */
.pricepro-list__item-tooltip,
.pricepro-table__plan-feature-tooltip {
    position: relative;
}

.pricepro-list__item-tooltip:hover::after,
.pricepro-list__item-tooltip:focus-visible::after,
.pricepro-table__plan-feature-tooltip:hover::after,
.pricepro-table__plan-feature-tooltip:focus-visible::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.88);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    width: max-content;
    max-width: 240px;
    white-space: normal;
    text-align: center;
    z-index: 100;
    pointer-events: none;
}

/* Sticky tabs on mobile when scrolled past their natural position. The CSS
   declares sticky always; JS toggles `--stuck` to add the visual treatment
   (shadow, padding) once the natural position is out of view. */
@media (max-width: 640px) {
    .pricepro-list__tabs {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--pp-bg);
        transition: box-shadow 0.2s ease, padding 0.2s ease;
    }

    .pricepro-list__tabs--stuck {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        padding: 0.5rem 1rem;
        margin: 0 -1rem;
    }
}
