/* ============================================================
 * CORE PATCH v3 — Modern product card buttons
 *
 * Design philosophy:
 *   1. Both buttons share the same size, border-radius, font, padding
 *      → visual consistency (consistent UI rhythm).
 *   2. Inline SVG icons (not icon fonts) → no external requests,
 *      instant render, scalable, themeable via `currentColor`.
 *   3. Subtle color difference between the two states:
 *        - Cart button = primary brand color (CTA = "do this")
 *        - Options button = neutral slate (informational = "go here first")
 *   4. Rounded corners (8px) — modern, friendly, not too soft.
 *   5. Hover state lifts the button slightly (translateY) + brightens
 *      → affordance for clickability.
 *   6. Active state presses down → tactile feedback.
 *   7. Focus-visible state for keyboard users (a11y).
 *   8. Disabled state for out-of-stock (when applicable).
 *
 * Accessibility:
 *   - Color is never the only indicator (icons + text always present).
 *   - Contrast ratio meets WCAG AA (white-on-#2563eb = 5.34:1).
 *   - Focus ring visible to keyboard users.
 *   - `<button>` and `<a>` are natively focusable and clickable.
 * ============================================================ */

.btn-product {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    line-height: 1;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.btn-product svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* "افزودن به سبد" — primary CTA, brand color */
.btn-product-cart {
    background: var(--color-primary, #2563eb);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-product-cart:hover {
    background: var(--color-secondary, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    color: #ffffff;
    text-decoration: none;
}

.btn-product-cart:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

/* "انتخاب گزینه‌ها" — secondary, neutral slate */
.btn-product-options {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

.btn-product-options:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    color: #0f172a;
    text-decoration: none;
}

.btn-product-options:active {
    transform: translateY(0);
    background: #cbd5e1;
}

/* Keyboard focus ring (a11y) */
.btn-product:focus-visible {
    outline: 2px solid var(--color-primary, #2563eb);
    outline-offset: 2px;
}

/* Disabled state (when JS sets disabled, e.g., out-of-stock) */
.btn-product:disabled,
.btn-product[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Loading state — shown when AJAX is in flight */
.btn-product.is-loading {
    pointer-events: none;
    opacity: 0.75;
}

.btn-product.is-loading svg {
    animation: btn-product-spin 0.8s linear infinite;
}

@keyframes btn-product-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Make sure the form doesn't add extra spacing */
.add-to-cart-form {
    margin: 0;
    padding: 0;
}

/* On touch devices, disable the hover-lift (it causes "sticky hover"
   on mobile — the button stays lifted after tap) */
@media (hover: none) {
    .btn-product:hover {
        transform: none;
    }
}

/* Responsive: slightly smaller on very small screens */
@media (max-width: 480px) {
    .btn-product {
        padding: 10px 12px;
        font-size: 13px;
    }
    .btn-product svg {
        width: 16px;
        height: 16px;
    }
}
