/* ─────────────────────────────────────────────
   WooCommerce Subscribe & Save — Front-End Styles
   ───────────────────────────────────────────── */

/* Base appearance. These used to be printed into wp_head from the settings page's colour and
   font-size fields; that UI is gone and the Breakdance element's design panel replaces it.

   They are declared on :root, not on .sas-purchase-options, and that placement is load-bearing: the
   element writes its overrides onto its own wrapper, which is an ancestor of .sas-purchase-options.
   Declaring a default on the block itself would be the nearer declaration and would win, leaving
   every design control doing nothing. Anything overriding these belongs on an ancestor. */
:root {
    --sas-accent:           #2c7be5;
    --sas-border:           #e0e0e0;
    --sas-tab-header-bg:    #f7f7f7;
    --sas-tab-hover-bg:     #efefef;
    --sas-active-bg:        #ffffff;
    --sas-save-badge-bg:    #e6f4ea;
    --sas-save-badge-color: #2e7d32;
    --sas-price-color:      #1a1a1a;
    --sas-inactive-color:   #666666;
    --sas-label-color:      #555555;
    --sas-select-border:    #cccccc;
    --sas-note-color:       #888888;
    --sas-tab-title-size:   14px;
    --sas-tab-badge-size:   11px;
    --sas-price-size:       22px;
    --sas-label-size:       12px;
    --sas-select-size:      14px;
    --sas-freq-size:        13px;
    --sas-badge-size:       12px;
    --sas-note-size:        13px;
    --sas-tiers-heading-color: #555555;
    --sas-tier-text-color:     #666666;
    --sas-tier-price-color:    #1a1a1a;
    --sas-tiers-heading-size:  12px;
    --sas-tier-text-size:      13px;
    --sas-tier-price-size:     13px;
    --sas-boxes-gap:           10px;
    --sas-box-border-width:    2px;
    --sas-select-hover-bg:     #efefef;
    --sas-box-inactive-bg:     #ffffff;
    --sas-box-hover-bg:        #f7f7f7;
}

.sas-purchase-options {
    margin: 0 0 20px;
    font-family: inherit;
}

/* ── Tabs Container ── */
.sas-tabs {
    display: flex;
    flex-direction: column;
}

/* ── Tab Headers (top row) ── */
.sas-tab-headers {
    display: flex;
    flex-direction: row;
    gap: 4px;
    padding: 0 4px;
    border-bottom: 2px solid var(--sas-border);
}

.sas-tab-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    cursor: pointer;
    border: 2px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: var(--sas-tab-header-bg);
    font-family: inherit;
    margin-bottom: -2px;
    transition: background 0.15s ease;
}

.sas-tab-header:hover {
    background: var(--sas-tab-hover-bg);
}

.sas-tab-header--active {
    background: var(--sas-active-bg);
    border-color: var(--sas-border);
    border-bottom-color: var(--sas-active-bg);
}

.sas-tab-title {
    font-size: var(--sas-tab-title-size);
    font-weight: 600;
    color: var(--sas-inactive-color);
}

.sas-tab-header--active .sas-tab-title {
    color: var(--sas-accent);
}

.sas-tab-badge {
    display: inline-block;
    background: var(--sas-save-badge-bg);
    color: var(--sas-save-badge-color);
    font-size: var(--sas-tab-badge-size);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ── Tab Panels ── */
.sas-tab-panels {
    border: 2px solid var(--sas-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 18px 16px;
    background: var(--sas-active-bg);
}

/* ── Panel Price ── */
.sas-panel-price {
    font-size: var(--sas-price-size);
    font-weight: 700;
    color: var(--sas-price-color);
    margin-bottom: 14px;
}

.sas-panel-price .woocommerce-Price-amount {
    color: inherit;
}

/* ── Interval Select (stacked) ── */
.sas-interval-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.sas-interval-label {
    font-size: var(--sas-label-size);
    font-weight: 600;
    color: var(--sas-label-color);
}

.sas-interval-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--sas-select-border);
    border-radius: 6px;
    font-size: var(--sas-select-size);
    background: var(--sas-active-bg);
    cursor: pointer;
    transition: border-color 0.2s;
}

.sas-interval-select:focus {
    outline: none;
    border-color: var(--sas-accent);
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.15);
}

/* ── Interval Radio Buttons ── */
.sas-interval-radios {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sas-interval-radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid var(--sas-select-border);
    border-radius: 6px;
    background: var(--sas-active-bg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sas-interval-radio-label:hover {
    border-color: var(--sas-accent);
    background: var(--sas-select-hover-bg);
}

.sas-interval-radio {
    margin: 0;
    cursor: pointer;
    accent-color: var(--sas-accent);
    width: 18px;
    height: 18px;
}

.sas-interval-radio-label:has(.sas-interval-radio:checked) {
    border-color: var(--sas-accent);
    background: var(--sas-select-hover-bg);
}

.sas-radio-text {
    font-size: var(--sas-select-size);
    color: var(--sas-label-color);
    flex: 1;
}

/* ── Subscribe Summary ── */
.sas-subscribe-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sas-summary-frequency {
    font-size: var(--sas-freq-size);
    color: var(--sas-inactive-color);
}

.sas-summary-badge {
    display: inline-block;
    background: var(--sas-save-badge-bg);
    color: var(--sas-save-badge-color);
    font-size: var(--sas-badge-size);
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

/* ── Multi-buy tiers (Woo Discount Rules integration) ── */
.sas-tiers {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--sas-border);
}

.sas-tiers-heading {
    font-size: var(--sas-tiers-heading-size);
    color: var(--sas-tiers-heading-color);
    font-weight: 600;
    margin-bottom: 6px;
}

.sas-tiers-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.sas-tier {
    font-size: var(--sas-tier-text-size);
    color: var(--sas-tier-text-color);
    white-space: nowrap;
}

.sas-tier strong {
    color: var(--sas-tier-price-color);
    font-size: var(--sas-tier-price-size);
    font-weight: 600;
}

/* wc_price() wraps the amount in its own <span class="woocommerce-Price-amount">, which the theme
   gives an explicit colour (the same reason .sas-panel-price needs the identical override above) -
   without this, that span's own colour wins over the inherited --sas-tier-price-color on <strong>. */
.sas-tier strong .woocommerce-Price-amount {
    color: inherit;
}

/* ── Buy Now note ── */
.sas-buynow-note {
    font-size: var(--sas-note-size);
    color: var(--sas-note-color);
    margin: 6px 0 0;
}

/* ── Extra text ── */
.sas-extra-text {
    font-size: var(--sas-note-size);
    color: var(--sas-note-color);
    margin: 10px 0 0;
}

/* ── Quantity + Add to Cart inline row ── */
form.cart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

form.cart .sas-purchase-options {
    flex: 0 0 100%;
}

form.cart .quantity {
    float: none;
    margin: 0;
}

form.cart .single_add_to_cart_button {
    flex: 1;
    min-width: 0;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* WooCommerce appends this straight after the button inside form.cart once the AJAX add-to-cart
   plugin marks the button "added". Without a flex rule of its own, the button's flex:1 above claims
   the entire remaining row width first, leaving no room for this link and forcing it onto its own
   line below. Sharing flex:1 keeps it on the same row, splitting the space with the button.
   min-width:0 on both is load-bearing: flex items default to min-width:auto (their content's
   intrinsic width), so once a third item joins the row the two buttons' text can otherwise refuse
   to shrink below that, overflowing the row and wrapping "View basket" onto its own line anyway. */
form.cart .added_to_cart {
    flex: 1;
    min-width: 0;
    margin: 0 !important;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Boxes layout ─────────────────────────────────── */
.sas-layout-boxes {
    display: flex;
    flex-direction: column;
    gap: var(--sas-boxes-gap);
}

.sas-box {
    border: var(--sas-box-border-width) solid var(--sas-border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    background: var(--sas-box-inactive-bg);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}

.sas-box:hover {
    border-color: var(--sas-accent);
}

/* Excludes the already-active box: :hover on its own would outrank .sas-box--active's background
   by specificity (a class + pseudo-class beats a single class), swapping the active box's background
   away from --sas-active-bg the moment the pointer sits over it. */
.sas-box:not(.sas-box--active):hover {
    background: var(--sas-box-hover-bg);
}

.sas-box--active {
    background: var(--sas-active-bg);
    border-color: var(--sas-accent);
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.12);
}

.sas-box__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sas-box__title {
    font-weight: 600;
    font-size: var(--sas-tab-title-size);
    color: var(--sas-price-color);
}

.sas-box .sas-panel-price {
    margin-bottom: 10px;
}

.sas-box .sas-interval-select-wrapper {
    margin-top: 4px;
}

/* ── Responsive ── */
@media ( max-width: 480px ) {
    .sas-tab-header {
        flex: 1;
        padding: 8px 10px;
        justify-content: center;
    }

    .sas-tab-title {
        font-size: 13px;
    }

    .sas-tab-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .sas-tab-panels {
        padding: 14px 12px;
    }

    .sas-panel-price {
        font-size: 18px;
    }
}
