/**
 * WowAddons Laravel API - Quantity price table
 *
 * Styles for the "Adet Seçimi" list printed by
 * Quantity_Table::render_quantity_table. Colours are tokens on .by-qty-table
 * so they can be retuned from Additional CSS without touching this file.
 *
 * Rows are <button>s: the theme styles every [type="button"] (green fill,
 * 48px height, centred text), so the rules below reset those with selectors
 * three classes deep - enough to win without !important.
 */

/* The native PRAD block stays in the form (it holds the selection) but is
   never shown once the table replaces it. */
.by-qty-native {
    display: none !important;
}

/* Every row already shows its own total, so PRAD's "Toplam Fiyat" line is
   redundant while the table is on screen. Only the rows go: the price script
   inserts its error messages (.wowaddons-price-error) into the same summary,
   and those must stay visible. Products without a table keep the line.
   :has() avoids a flash on first paint; the class is set by the script for
   browsers without :has(). */
.prad-addons-wrapper:has(.by-qty-table:not(.is-hidden)) .prad-product-price-summary .prad-price-row,
.prad-addons-wrapper.by-qty-active .prad-product-price-summary .prad-price-row {
    display: none !important;
}

.prad-addons-wrapper:has(.by-qty-table:not(.is-hidden)) .prad-product-price-summary,
.prad-addons-wrapper.by-qty-active .prad-product-price-summary {
    margin-top: 0 !important;
}

.by-qty-table {
    --byq-accent: #f16543;
    --byq-accent-text: #ffffff;
    --byq-accent-muted: rgba(255, 255, 255, 0.82);
    --byq-border: #e2e8f0;
    --byq-border-hover: #f8b9a5;
    --byq-surface: #ffffff;
    --byq-text: #111827;
    --byq-text-soft: #374151;
    --byq-muted: #6b7280;
    --byq-focus: #c2410c;
    --byq-success: #3cc46b;
    --byq-skeleton: #eef2f6;
    --byq-skeleton-shine: #f8fafc;
    --byq-error: #c0392b;
    --byq-radius: 6px;

    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    color: var(--byq-text);
}

.by-qty-table *,
.by-qty-table *::before,
.by-qty-table *::after {
    box-sizing: border-box;
}

.by-qty-table.is-hidden,
.by-qty-table [hidden] {
    display: none !important;
}

/* --- Header --------------------------------------------------------------- */

.by-qty-table .by-qty-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin: 0 0 12px;
}

.by-qty-table .by-qty-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--byq-text);
}

.by-qty-table .by-qty-note {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #4b5563;
}

/* --- Rows ----------------------------------------------------------------- */

.by-qty-table .by-qty-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.by-qty-table .by-qty-list .by-qty-row {
    -webkit-appearance: none;
    appearance: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 100%;
    height: auto;
    min-height: 74px;
    margin: 0;
    padding: 14px 32px;
    border: 1px solid var(--byq-border);
    border-radius: var(--byq-radius);
    background: var(--byq-surface);
    box-shadow: none;
    color: var(--byq-text);
    fill: currentColor;
    font: inherit;
    font-weight: 400;
    line-height: 1.3;
    letter-spacing: normal;
    text-align: left;
    text-transform: none;
    white-space: normal;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.by-qty-table .by-qty-list .by-qty-row:hover {
    border-color: var(--byq-border-hover);
    background: var(--byq-surface);
    color: var(--byq-text);
}

.by-qty-table .by-qty-list .by-qty-row:focus {
    outline: none;
}

.by-qty-table .by-qty-list .by-qty-row:focus-visible {
    outline: 2px solid var(--byq-focus);
    outline-offset: 2px;
}

.by-qty-table .by-qty-list .by-qty-row.is-selected,
.by-qty-table .by-qty-list .by-qty-row.is-selected:hover {
    border-color: var(--byq-accent);
    background: var(--byq-accent);
    color: var(--byq-accent-text);
}

.by-qty-table .by-qty-list .by-qty-row.is-unavailable,
.by-qty-table .by-qty-list .by-qty-row.is-unavailable:hover {
    border-color: var(--byq-border);
    background: var(--byq-surface);
    color: var(--byq-text);
    opacity: 0.4;
    cursor: not-allowed;
}

.by-qty-table .by-qty-list .by-qty-row.is-unavailable.is-selected {
    background: var(--byq-accent);
    color: var(--byq-accent-text);
}

.by-qty-table .by-qty-qty,
.by-qty-table .by-qty-price,
.by-qty-table .by-qty-save {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.by-qty-table .by-qty-price {
    align-items: center;
    text-align: center;
}

.by-qty-table .by-qty-save {
    align-items: flex-end;
    text-align: right;
}

.by-qty-table .by-qty-num,
.by-qty-table .by-qty-amount {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
    font-variant-numeric: tabular-nums;
}

.by-qty-table .by-qty-amount {
    white-space: nowrap;
}

.by-qty-table .by-qty-unit,
.by-qty-table .by-qty-suffix {
    font-size: 14px;
    line-height: 1.2;
    color: var(--byq-muted);
}

.by-qty-table .by-qty-save-pct {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--byq-success);
}

.by-qty-table .by-qty-save-text {
    font-size: 14px;
    line-height: 1.2;
    color: var(--byq-success);
}

.by-qty-table .by-qty-na {
    color: var(--byq-muted);
    font-weight: 400;
}

.by-qty-table .is-selected .by-qty-unit,
.by-qty-table .is-selected .by-qty-suffix,
.by-qty-table .is-selected .by-qty-na {
    color: var(--byq-accent-muted);
}

.by-qty-table .is-selected .by-qty-save-pct,
.by-qty-table .is-selected .by-qty-save-text {
    color: var(--byq-accent-text);
}

/* Price placeholder while the quantity is being priced. */
.by-qty-table .by-qty-skeleton {
    display: inline-block;
    width: 6.5em;
    max-width: 100%;
    height: 0.9em;
    border-radius: 4px;
    vertical-align: middle;
    background: linear-gradient(90deg, var(--byq-skeleton) 25%, var(--byq-skeleton-shine) 37%, var(--byq-skeleton) 63%);
    background-size: 400% 100%;
    animation: by-qty-shimmer 1.4s ease infinite;
}

.by-qty-table .is-selected .by-qty-skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.3) 25%, rgba(255, 255, 255, 0.55) 37%, rgba(255, 255, 255, 0.3) 63%);
    background-size: 400% 100%;
}

@keyframes by-qty-shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

/* Server-rendered skeleton rows are plain divs; match the live buttons. */
.by-qty-table .by-qty-list div.by-qty-row {
    cursor: default;
}

/* --- "Daha Fazla Adet" ---------------------------------------------------- */

.by-qty-table .by-qty-footer {
    margin-top: 12px;
}

.by-qty-table .by-qty-footer .by-qty-more {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: auto;
    min-height: 54px;
    margin: 0;
    padding: 12px 16px;
    border: 1px solid var(--byq-border);
    border-radius: var(--byq-radius);
    background: var(--byq-surface);
    box-shadow: none;
    color: var(--byq-text-soft);
    fill: currentColor;
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.by-qty-table .by-qty-footer .by-qty-more:hover {
    border-color: var(--byq-border-hover);
    background: var(--byq-surface);
    color: var(--byq-text-soft);
}

.by-qty-table .by-qty-footer .by-qty-more:focus {
    outline: none;
}

.by-qty-table .by-qty-footer .by-qty-more:focus-visible {
    outline: 2px solid var(--byq-focus);
    outline-offset: 2px;
}

.by-qty-table .by-qty-chevron {
    flex: none;
    transition: transform 0.2s ease;
}

.by-qty-table .by-qty-more.is-expanded .by-qty-chevron {
    transform: rotate(180deg);
}

/* --- "Önce X seçin" hint ---------------------------------------------------- */

.by-qty-table .by-qty-hint {
    margin: 12px 0 0;
    padding: 10px 14px;
    border: 1px solid #fed7aa;
    border-radius: var(--byq-radius);
    background: #fff7ed;
    color: #9a3412;
    font-size: 14px;
    line-height: 1.5;
}

/* --- Required warning ----------------------------------------------------- */

.by-qty-table.has-error .by-qty-list .by-qty-row:not(.is-unavailable):not(.is-selected) {
    border-color: #f5b7b1;
}

.by-qty-table .by-qty-error {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--byq-error);
}

/* --- Small screens -------------------------------------------------------- */

@media (max-width: 600px) {
    .by-qty-table .by-qty-list .by-qty-row {
        min-height: 64px;
        padding: 12px 16px;
        gap: 8px;
    }

    .by-qty-table .by-qty-num,
    .by-qty-table .by-qty-amount {
        font-size: 17px;
    }

    .by-qty-table .by-qty-unit,
    .by-qty-table .by-qty-suffix,
    .by-qty-table .by-qty-save-text {
        font-size: 12px;
    }

    .by-qty-table .by-qty-save-pct {
        font-size: 14px;
    }

}

@media (prefers-reduced-motion: reduce) {
    .by-qty-table .by-qty-skeleton {
        animation: none;
    }

    .by-qty-table .by-qty-list .by-qty-row,
    .by-qty-table .by-qty-chevron {
        transition: none;
    }
}
