/* ===============================
   Sahaj Woo – Points UI

   Note: .wap-insufficient has been replaced by .wap-points-error,
   which is the class the PHP actually outputs. The old rule never
   matched anything.
================================ */

/* -------------------------------
   Per-item toggle
-------------------------------- */

.wap-use-points {
    margin-top: 6px;
    font-size: 13px;
    position: relative;
}

.wap-use-points label,
.wap-use-points .wap-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.wap-use-points input[type="checkbox"] {
    margin: 0;
    flex: 0 0 auto;
}

/* Disabled = not enough points left for this line */
.wap-use-points input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

.wap-use-points input[type="checkbox"]:disabled + *,
.wap-use-points label:has(input:disabled) {
    opacity: .55;
    cursor: not-allowed;
}

/* In-flight AJAX state */
.wap-use-points.is-busy {
    opacity: .6;
    pointer-events: none;
}

.wap-use-points.is-busy::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -22px;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border: 2px solid #d1d5db;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: wap-spin .6s linear infinite;
}

@keyframes wap-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .wap-use-points.is-busy::after { animation: none; }
}

/* Points applied badge */
.wap-use-points .wap-badge {
    margin-left: 8px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #2fbf71;
    color: #2fbf71;
    background: #ecfdf5;
    border-radius: 14px;
    line-height: 1;
    white-space: nowrap;
}

/* Insufficient points / AJAX failure message */
.wap-points-error {
    color: #b32d2e;
    font-size: 12px;
    margin-top: 3px;
}

/* -------------------------------
   Progress bar
-------------------------------- */

.wap-points-progress {
    margin: 16px 0 20px;
}

.wap-points-progress-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.wap-points-progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.wap-points-progress-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #10b981, #22c55e);
    transition: width .3s ease;
}

/* -------------------------------
   Cart page refresh state
-------------------------------- */

.woocommerce-cart-form.wap-refreshing {
    opacity: .55;
    pointer-events: none;
    transition: opacity .15s ease;
}

/* -------------------------------
   Mini / slide cart summary
   (server-rendered by render_mini_cart_summary)
-------------------------------- */

.wap-mini-points {
    margin: 12px 0;
    padding: 12px 14px;
    background: #fff8e8;
    border: 1px solid #f3d37a;
    border-radius: 10px;
    text-align: center;
    color: #8a6300;
    font-size: 13px;
    line-height: 1.4;
}

.wap-mini-points-applied {
    font-weight: 600;
    color: #2fbf71;
}

.wap-mini-points-available {
    font-weight: 600;
}

.wap-mini-points-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: #8a6300;
    text-decoration: underline;
}

.wap-mini-points-link:hover,
.wap-mini-points-link:focus {
    color: #5c4200;
}

/* -------------------------------
   Checkout panel
   (rendered as a <tr> inside the review-order table)
-------------------------------- */

.wap-checkout-points > td {
    padding: 14px 12px !important;
}

.wap-checkout-panel {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
}

.wap-checkout-panel > strong {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
}

.wap-checkout-lines {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wap-checkout-line {
    padding: 8px 0;
    border-top: 1px solid #e5e7eb;
}

.wap-checkout-line:first-child {
    border-top: 0;
    padding-top: 0;
}

.wap-checkout-line-name {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.wap-checkout-line .wap-use-points {
    margin-top: 2px;
}

/* -------------------------------
   Legacy JS-injected slide-cart notice
   (fallback only — used when the theme's slide cart does not fire
   woocommerce_widget_shopping_cart_before_buttons)
-------------------------------- */

.wap-minicart-notice {
    margin: 16px;
    padding: 16px;
    background: #fff8e8;
    border: 1px solid #f3d37a;
    border-radius: 10px;
    text-align: center;
    color: #8a6300;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}

.wap-minicart-notice strong {
    display: block;
    font-size: 22px;
    margin-bottom: 6px;
}

.wap-minicart-notice small {
    display: block;
    margin-top: 6px;
    color: #666;
    font-size: 13px;
}

/* -------------------------------
   Main points panel
   (master opt-out + optional per-item lines + progress)
-------------------------------- */

.wap-points-panel {
    position: relative;
    margin: 0 0 20px;
    padding: 14px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
}

.wap-points-panel.is-busy {
    opacity: .6;
    pointer-events: none;
}

.wap-points-panel .wap-use-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.wap-points-panel.is-opted-out {
    background: #fff;
    border-style: dashed;
}

.wap-points-optout-note {
    margin: 8px 0 0;
    font-size: 12px;
    color: #6b7280;
}

.wap-points-panel .wap-checkout-lines {
    margin-top: 10px;
}

.wap-points-panel .wap-points-progress {
    margin: 12px 0 0;
}

/* Cart lines that cannot be redeemed with points */

.wap-checkout-line.is-ineligible .wap-checkout-line-name {
    opacity: .7;
}

.wap-checkout-line .wap-points-note {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}
