/*
 * Floating share button (FAB) + per-product commission badge.
 *
 * Phase 02 fills the FAB styles. Phase 03 will add the product badge
 * styles. Enqueued site-wide via class-frontend.php (depends on
 * dimi-affiliate-frontend).
 */

/* -------------------------------------------------------------------------
 * .dimi-fab — fixed bottom-right floating action button for logged-in
 * active affiliates. Server-rendered by Dimi_Affiliate_Floating_Share.
 * ------------------------------------------------------------------------- */
.dimi-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--dimi-brand-primary, var(--dimi-color-primary, #2563eb));
    color: #fff;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
    cursor: pointer;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.dimi-fab:hover {
    transform: translateY(-2px);
    background: var(--dimi-brand-primary-hover, #1d4ed8);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
}

.dimi-fab:active {
    transform: translateY(0);
}

.dimi-fab:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--dimi-brand-primary, #2563eb), 0 6px 16px rgba(15, 23, 42, 0.2);
}

.dimi-fab svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* Screen-reader-only label inside the FAB — the SVG is decorative. */
.dimi-fab__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

/* Compact size on mobile so the FAB doesn't crowd a small viewport. */
@media (max-width: 640px) {
    .dimi-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
    .dimi-fab svg {
        width: 20px;
        height: 20px;
    }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
    .dimi-fab {
        transition: none;
    }
    .dimi-fab:hover {
        transform: none;
    }
}

/* -------------------------------------------------------------------------
 * .dimi-product-commission — per-product "You earn: X ₫" badge + Copy
 * Link button under each WC product card. Server-rendered by
 * Dimi_Affiliate_Product_Commission via woocommerce_after_shop_loop_item
 * and woocommerce_single_product_summary hooks.
 *
 * Visible only to logged-in active affiliates.
 * ------------------------------------------------------------------------- */
.dimi-product-commission {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    padding: 6px 10px;
    background: var(--dimi-color-surface-subtle, #f5f7fb);
    border: 1px solid var(--dimi-color-border, #e5e7eb);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.35;
}

.dimi-product-commission__badge {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.dimi-product-commission__label {
    color: var(--dimi-color-text-muted, #6b7280);
}

.dimi-product-commission__amount {
    font-weight: 600;
    color: var(--dimi-color-text-strong, #111827);
}

.dimi-product-commission__amount .woocommerce-Price-amount,
.dimi-product-commission__amount bdi {
    color: inherit;
    font-weight: inherit;
}

.dimi-product-commission__copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #fff;
    border: 1px solid var(--dimi-color-border, #e5e7eb);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.2;
    color: var(--dimi-color-text, #374151);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dimi-product-commission__copy:hover {
    background: var(--dimi-color-primary-50, #eff6ff);
    border-color: var(--dimi-brand-primary, #2563eb);
    color: var(--dimi-brand-primary, #2563eb);
}

.dimi-product-commission__copy:focus-visible {
    outline: 2px solid var(--dimi-brand-primary, #2563eb);
    outline-offset: 2px;
}

.dimi-product-commission__copy svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

/* The hidden input that holds the affiliate URL — only the copy handler
 * reads it. Visually removed so it doesn't render under the badge. */
.dimi-product-commission__url {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

/* Compact variant — used inside shop-archive loop cards where vertical
 * space is tight. Stack the badge above the button. */
.dimi-product-commission.is-compact {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.dimi-product-commission.is-compact .dimi-product-commission__copy {
    width: 100%;
    justify-content: center;
}

@media (max-width: 480px) {
    .dimi-product-commission {
        font-size: 12px;
        padding: 6px 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dimi-product-commission__copy {
        transition: none;
    }
}

/* -------------------------------------------------------------------------
 * .dimi-inline-toast — minimal copy-feedback toast for frontend pages
 * where the dashboard's richer window.showToast UI isn't loaded.
 * Single shared instance per page, role=status + aria-live=polite so
 * screen readers announce copy success / failure.
 * ------------------------------------------------------------------------- */
.dimi-inline-toast {
    position: fixed;
    bottom: 96px; /* clear of .dimi-fab at bottom: 24 + height 56 + gap */
    right: 24px;
    max-width: calc(100vw - 48px);
    padding: 10px 14px;
    background: #111827;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 9999;
}

.dimi-inline-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.dimi-inline-toast--error {
    background: #b91c1c;
}

@media (max-width: 640px) {
    .dimi-inline-toast {
        bottom: 80px;
        right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dimi-inline-toast {
        transition: opacity 0.18s ease;
        transform: none;
    }
}
