/*
 * product-card-enhanced.css
 * All classes use ec-card prefix — zero conflict with theme style.css
 * Layouts: ec-card--flyout | ec-card--inline
 */

/* ============================================================
   BASE — shared by all three layouts
   ============================================================ */

.ec-card {
    position: relative;
    background: transparent;
}

/* Full-card invisible link overlay */
.ec-card__overlay-link {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: pointer;
}

/* Thumbnail */
.ec-card__thumb {
    position: relative;
    padding: 7px;
    background: var(--global-color-card-bg);
    border-radius: 7px;
    margin-bottom: 5px;
}

.ec-card__thumb a {
    display: block;
}

.ec-card__thumb img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}

/* Body */
.ec-card__body {
    padding: 0;
}

.ec-card__content {
    padding: 0;
}

/* Elements above the overlay link */
.ec-card__thumb,
.ec-card__title,
.ec-card__rating,
.ec-card__seller,
.ec-card__badges,
.ec-card__float,
.ec-card__actions {
    position: relative;
    z-index: 20;
    pointer-events: auto;
}

/* Info icon and sale duration need higher z-index so tooltips show above all other elements */
.ec-card__info-icon,
.ec-card__sale-duration {
    position: relative;
    z-index: 30;
    pointer-events: auto;
}

/* Badges */
.ec-card__badges {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
}

.ec-card__badge {
    display: inline-block;
    background: var(--global-color-primary);
    color: var(--global-color-text-on-dark);
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 5px;
}

.ec-card__badge--out {
    background: var(--global-color-alert);
}

/* Price row */
.ec-card__price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.ec-card__badge-discount {
    display: inline-block;
    background: var(--global-color-link);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.ec-card__price-original {
    font-size: 13px;
    color: var(--global-color-text-muted);
    opacity: 0.7;
}

/* Sale duration */
.ec-card__sale-duration {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 5px;
    font-size: 10px;
    line-height: 1.2;
    width: fit-content;
    position: relative;
    z-index: 30;
}

.ec-card__duration-text {
    color: #565959;
    font-weight: 400;
}

.ec-card__info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 11px;
    height: 11px;
    border: 1px solid var(--global-color-text-subtle);
    border-radius: 50%;
    cursor: help;
    flex-shrink: 0;
    margin-left: 2px;
    padding: 4px;
    position: relative;
}

.ec-card__info-icon i {
    font-size: 7px;
    color: var(--global-color-text-subtle);
    font-style: normal;
    line-height: 1;
}

.ec-card__info-icon i::before {
    content: 'i';
    font-family: Georgia, serif;
    font-weight: 600;
    font-style: normal;
}

/* Tooltip — default shows BELOW the icon */
.ec-card__info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(100% + 8px);
    background: #fff;
    color: #0F1111;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #D5D9D9;
    box-shadow: 0 4px 8px rgba(0,0,0,.1);
    font-size: 10px;
    white-space: normal;
    width: 180px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease, visibility .15s ease;
    z-index: 99999;
    line-height: 1.4;
    font-weight: 400;
    text-align: left;
}

.ec-card__info-icon::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(100% + 2px);
    border: 6px solid transparent;
    border-bottom-color: #fff;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease, visibility .15s ease;
    z-index: 100000;
    filter: drop-shadow(0 -1px 1px rgba(0,0,0,.05));
}

.ec-card__info-icon:hover::after,
.ec-card__info-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Sale price */
.ec-card__price-sale {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    margin-bottom: 8px;
}

.ec-card__price-amount {
    font-size: 1.45rem;
    font-weight: 400;
    color: var(--global-color-text-body);
}

.ec-card__sold {
    font-size: 11px;
    color: var(--global-color-text-muted);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

/* Title */
.ec-card__title {
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    font-size: 1rem;
    font-weight: 400;
    color: var(--global-color-text-main);
    text-decoration: none;
    margin-bottom: 10px;
    line-height: 1.4;
    word-break: break-word;
    transition: color .3s ease;
}

.ec-card__title:hover {
    color: var(--global-color-alert-text);
}

/* Rating wrapper */
.ec-card__rating-wrapper {
    margin-bottom: 4px;
}

/* Rating */
.ec-card__rating {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    text-decoration: none;
    color: inherit;
    transition: opacity .3s ease;
}

.ec-card__rating:hover { opacity: .8; }

.ec-card__rating-count {
    color: var(--global-color-link);
    font-size: 12px;
    font-weight: 400;
}

/* View Count */
.ec-card__view-count {
    font-size: 11px;
    color: var(--global-color-text-muted);
    margin-bottom: 6px;
    line-height: 1.2;
}

/* Delivery message */
.ec-card__delivery {
    font-size: 11px;
    margin-bottom: 6px;
    line-height: 1.4;
}

.ec-card__delivery-date {
    color: var(--global-color-text-body);
}

.ec-card__delivery-date strong {
    font-weight: 600;
}

.ec-card__delivery-charge {
    color: var(--global-color-success);
    font-weight: 500;
}

.ec-card__stars {
    display: flex;
    gap: 2px;
}

.ec-card__stars i {
    font-size: 16px;
    color: var(--global-color-primary);
}

/* Phosphor Icons - Regular (outline) star */
.ec-card__stars .ph-star {
    color: var(--global-color-primary);
    font-weight: 400;
}

/* Phosphor Icons - Filled star */
.ec-card__stars .ph-fill.ph-star {
    color: var(--global-color-primary);
}

/* Phosphor Icons - Half-filled star */
.ec-card__stars .ph-fill.ph-star-half {
    color: var(--global-color-primary);
}

/* Seller */
.ec-card__seller {
    display: inline-block;
    font-size: 12px;
    color: var(--global-color-link);
    text-decoration: none;
    transition: color .3s ease;
    margin-top: 0;
}

.ec-card__seller:hover {
    color: var(--global-color-link-hover);
    text-decoration: underline;
}

/* ── Action buttons (shown on mobile / deal desktop) ── */
.ec-card__actions {
    margin-top: 12px;
}

.ec-card__btn {
    display: block;
    width: 100%;
    padding: 5px 15px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 400;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all .3s ease;
    outline: none;
    box-sizing: border-box;
    border: none;
}

.ec-card__btn--cart {
    background: var(--global-color-warning);
    color: var(--global-color-text-main);
    border: none;
}

.ec-card__btn--cart:hover { opacity: .9; }

.ec-card__btn--select {
    background: transparent;
    color: var(--global-color-text-main);
    border: 1px solid var(--global-color-border-strong);
}

.ec-card__btn--select:hover,
.ec-card__btn--select:active,
.ec-card__btn--select:focus {
    background: var(--global-color-card-bg);
    color: var(--global-color-text-main);
    border-color: var(--global-color-border-strong);
}

/* ── Floating actions (offer/standard desktop) ── */
.ec-card__float {
    position: absolute;
    bottom: 10px;
    right: 12px;
    z-index: 20;
}

.ec-card__float-capsule {
    display: flex;
    align-items: center;
    gap: 0;
    background: transparent;
    border-radius: 50px;
    padding: 0;
    border: 1px solid transparent;
    transition: all .4s cubic-bezier(.4,0,.2,1);
    justify-content: flex-end;
}

.ec-card__float-capsule.active,
.ec-card__float-capsule:hover {
    background: var(--global-color-site-bg, #f5f5f5);
    border-color: var(--global-color-primary-border);
    padding: 4px;
    gap: 4px;
}

/* Only show on hover for true pointer devices */
@media (hover: hover) and (pointer: fine) {
    .ec-card__float-capsule:hover .ec-card__float-btn {
        display: flex !important;
        opacity: 1 !important;
        transform: scale(1) !important;
    }
    .ec-card__float-capsule:hover .ec-card__toggle-icon { transform: rotate(90deg) !important; }
    .ec-card__float-capsule:hover .ec-card__toggle-h    { opacity: 0 !important; }
}

.ec-card__float-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    color: var(--global-color-text-main);
    border: none;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity .3s ease, transform .3s ease;
    flex-shrink: 0;
    opacity: 0;
    transform: scale(0);
}

.ec-card__float-capsule.active .ec-card__float-btn {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.ec-card__float-btn:hover {
    border: 1px solid var(--global-color-text-body);
}

.ec-card__float-btn i { font-size: 14px; }

/* Phosphor Icons Support */
.ec-card__float-btn i.ph {
    font-weight: 400; /* Regular/outline weight */
    transition: font-weight 0.2s ease;
}

.ec-card__float-btn i.ph-fill {
    font-weight: 700; /* Fill weight */
    color: var(--global-color-text-main);
}

.ec-card__float-toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--global-color-warning);
    color: var(--global-color-text-main);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .3s ease;
    flex-shrink: 0;
}

.ec-card__toggle-icon {
    width: 11.5px;
    height: 11.5px;
    position: relative;
    display: inline-block;
    transition: transform .4s cubic-bezier(.4,0,.2,1);
}

.ec-card__toggle-line {
    position: absolute;
    background: currentColor;
    border-radius: 1px;
    transition: all .4s cubic-bezier(.4,0,.2,1);
}

.ec-card__toggle-h {
    width: 11.5px; height: 2px;
    top: 50%; left: 0; margin-top: -1px;
    opacity: 1;
}

/* Tablet (481-768px): adjust toggle-h position for better centering */
@media (min-width: 481px) and (max-width: 768px) {
    .ec-card__toggle-h { left: -43.5%; }
}

.ec-card__toggle-v {
    width: 2px; height: 11.5px;
    left: 50%; top: 0; margin-left: -1px;
    opacity: 1;
}

.ec-card__float-capsule.active .ec-card__toggle-icon { transform: rotate(90deg); }
.ec-card__float-capsule.active .ec-card__toggle-h    { opacity: 0; }

/* ============================================================
   FLYOUT layout (ec-card--flyout)
   Desktop: floating actions, no bottom button
   Mobile ≤480px: horizontal card, show bottom button
   ============================================================ */

.ec-card--flyout .ec-card__actions { display: none; }

/* ============================================================
   FLYOUT layout (ec-card--flyout)
   Same as offer
   ============================================================ */

.ec-card--flyout .ec-card__actions { display: none; }

/* ============================================================
   INLINE layout (ec-card--inline)
   Desktop: no floating actions, always show bottom button
   Mobile ≤480px: horizontal card, show bottom button
   ============================================================ */

.ec-card--inline .ec-card__float    { display: none !important; }
.ec-card--inline .ec-card__actions  { display: block; }

.ec-card--inline .ec-card__price-amount {
    font-size: 1.7rem;
}

/* ============================================================
   RESPONSIVE — tablet (481px – 768px) floating btn size
   ============================================================ */

@media (min-width: 481px) and (max-width: 768px) {
    .ec-card__float-btn,
    .ec-card__float-toggle {
        width: 18px;
        height: 18px;
    }
    .ec-card__float-btn i { font-size: 9px; }
    .ec-card__float-capsule.active { padding: 2px; gap: 2px; }
}

/* ============================================================
   RESPONSIVE — mobile ≤480px
   All layouts: hide floating, show bottom button, horizontal
   ============================================================ */

@media (max-width: 480px) {

    /* Remove card margins on mobile */
    .ec-card { margin: 0 !important; }

    /* Mobile float button positioning and sizing */
    .ec-card__float {
        bottom: 7px !important;
        right: 7px !important;
    }

    .ec-card__float-btn,
    .ec-card__float-toggle {
        width: 22px !important;
        height: 22px !important;
    }

    /* Show bottom button for offer & standard on mobile */
    .ec-card--flyout .ec-card__actions,
    .ec-card--flyout .ec-card__actions {
        display: block !important;
        margin-top: 6px;
    }

    /* Hide floating actions on mobile for all layouts */
    .ec-card--flyout .ec-card__float,
    .ec-card--flyout .ec-card__float {
        display: none !important;
    }

    /* Mobile button sizing */
    .ec-card--flyout .ec-card__btn,
    .ec-card--flyout .ec-card__btn,
    .ec-card--inline .ec-card__btn {
        padding: 5px 10px !important;
        border-radius: 16px !important;
        font-size: 11px !important;
    }

    /* Horizontal card layout */
    .ec-card--flyout,
    .ec-card--inline,
    .ec-card--flyout {
        display: flex !important;
        flex-direction: row !important;
        gap: 0 !important;
        align-items: stretch !important;
        margin-bottom: 12px !important;
    }

    /* Thumbnail — left side */
    .ec-card--flyout .ec-card__thumb,
    .ec-card--inline .ec-card__thumb,
    .ec-card--flyout .ec-card__thumb {
        width: 35.5% !important;
        flex-shrink: 0 !important;
        margin-bottom: 0 !important;
        border-radius: 8px 0 0 8px !important;
        padding: 6px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .ec-card--flyout .ec-card__thumb a,
    .ec-card--inline .ec-card__thumb a,
    .ec-card--flyout .ec-card__thumb a {
        display: flex !important;
        align-items: center !important;
        width: 100% !important;
    }

    .ec-card--flyout .ec-card__thumb img,
    .ec-card--inline .ec-card__thumb img,
    .ec-card--flyout .ec-card__thumb img {
        object-fit: contain !important;
        border-radius: 3px !important;
    }

    /* Body — right side */
    .ec-card--flyout .ec-card__body,
    .ec-card--inline .ec-card__body,
    .ec-card--flyout .ec-card__body {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-width: 0 !important;
        border: 1px solid var(--global-color-primary-border) !important;
        border-left: none !important;
        border-radius: 0 8px 8px 0 !important;
        padding: 8px 10px !important;
        background: transparent !important;
    }

    .ec-card--flyout .ec-card__content,
    .ec-card--inline .ec-card__content,
    .ec-card--flyout .ec-card__content {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        padding: 0 !important;
    }

    /* Smaller text on mobile */
    .ec-card--flyout .ec-card__title,
    .ec-card--inline .ec-card__title,
    .ec-card--flyout .ec-card__title {
        font-size: 11px !important;
        -webkit-line-clamp: 3 !important;
        margin-bottom: 4px !important;
    }

    .ec-card--flyout .ec-card__price-amount,
    .ec-card--flyout .ec-card__price-amount {
        font-size: 1.25rem !important;
    }

    .ec-card--inline .ec-card__price-amount {
        font-size: 1.25rem !important;
    }

    .ec-card--flyout .ec-card__rating,
    .ec-card--inline .ec-card__rating,
    .ec-card--flyout .ec-card__rating {
        font-size: 9px !important;
        margin-bottom: 3px !important;
    }

    .ec-card--flyout .ec-card__stars i,
    .ec-card--inline .ec-card__stars i,
    .ec-card--flyout .ec-card__stars i {
        font-size: 12px !important;
    }

    .ec-card--flyout .ec-card__badge-discount,
    .ec-card--inline .ec-card__badge-discount,
    .ec-card--flyout .ec-card__badge-discount {
        font-size: 9px !important;
        padding: 1px 4px !important;
    }

    .ec-card--flyout .ec-card__price-original,
    .ec-card--inline .ec-card__price-original,
    .ec-card--flyout .ec-card__price-original {
        font-size: 10px !important;
    }

    .ec-card--flyout .ec-card__sale-duration,
    .ec-card--inline .ec-card__sale-duration,
    .ec-card--flyout .ec-card__sale-duration {
        font-size: 8px !important;
    }

    .ec-card--flyout .ec-card__sold,
    .ec-card--inline .ec-card__sold,
    .ec-card--flyout .ec-card__sold {
        font-size: 9px !important;
    }

    .ec-card--flyout .ec-card__actions,
    .ec-card--inline .ec-card__actions,
    .ec-card--flyout .ec-card__actions {
        margin-top: 6px !important;
    }
}

/* ============================================================
   LOADING STATE — btn-loading class added by front-ecommerce.js
   ============================================================ */

/* Add to cart button — yellow background, spinner uses text-on-dark color */
.ec-card__btn--cart.btn-loading,
.ec-card__btn--cart.button-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.ec-card__btn--cart.btn-loading::after,
.ec-card__btn--cart.button-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--global-color-text-on-dark);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: ec-card-spin .7s linear infinite;
}

/* Flyout buttons — site-bg background, spinner uses text-main (dark) so it's visible */
.ec-card__float-btn.btn-loading,
.ec-card__float-btn.button-loading {
    position: relative;
    pointer-events: none;
}

.ec-card__float-btn.btn-loading i,
.ec-card__float-btn.button-loading i {
    opacity: 0;
}

.ec-card__float-btn.btn-loading::after,
.ec-card__float-btn.button-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid var(--global-color-text-main);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: ec-card-spin .7s linear infinite;
}

@keyframes ec-card-spin {
    to { transform: rotate(360deg); }
}

/* Tooltip — show ABOVE when .tooltip-above class is added by JS */
.ec-card__info-icon.tooltip-above::after {
    top: auto;
    bottom: calc(100% + 8px);
}

.ec-card__info-icon.tooltip-above::before {
    top: auto;
    bottom: calc(100% + 2px);
    border-bottom-color: transparent;
    border-top-color: #fff;
}


/* ============================================================
   QUANTITY CONTROL — shown after add to cart
   ============================================================ */

.ec-card__qty-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 2px solid var(--global-color-warning);
    border-radius: 50px;
    padding: 0;
    background: #fff;
    overflow: hidden;
    height: 33px;
}

.ec-card__qty-btn {
    flex-shrink: 0;
    width: 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--global-color-text-main);
    transition: border-color .2s;
    font-size: 16px;
    padding: 0;
}

.ec-card__qty-btn:hover {
    background: none;
}

.ec-card__qty-btn:disabled {
    cursor: wait;
    pointer-events: none;
}

.ec-card__qty-input:disabled {
    cursor: wait;
}

.ec-card__qty-btn--minus {
    border-right: 2px solid transparent;
    transition: border-color .2s;
}

.ec-card__qty-btn--minus:hover:not(:disabled),
.ec-card__qty-btn--minus:active:not(:disabled) {
    border-right-color: var(--global-color-warning);
}

.ec-card__qty-btn--plus {
    border-left: 2px solid transparent;
    transition: border-color .2s;
}

.ec-card__qty-btn--plus:hover:not(:disabled),
.ec-card__qty-btn--plus:active:not(:disabled) {
    border-left-color: var(--global-color-warning);
}

.ec-card__qty-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    cursor: text;
    padding: 2px 4px;
}

.ec-card__qty-input {
    width: 30px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--global-color-text-main);
    border: none;
    background: transparent;
    outline: none;
    padding: 0;
    min-width: 0;
    line-height: 1;
    -moz-appearance: textfield; /* Firefox */
}

.ec-card__qty-label {
    font-size: 12px;
    font-weight: 400;
    color: var(--global-color-text-muted);
    white-space: nowrap;
    line-height: 1;
}

/* Hide spinner buttons in Chrome, Safari, Edge */
.ec-card__qty-input::-webkit-outer-spin-button,
.ec-card__qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ec-card__qty-btn i {
    font-size: 16px;
    line-height: 1;
}
