/**
 * Advanced Promo Kit - Frontend Styles
 *
 * @since 1.0.0
 * @package APK
 */

/* ==========================================================================
   Image Wrapper - Contains product image and labels
   ========================================================================== */

.apk-image-wrapper {
    position: relative;
    display: block;
    width: 100%;
    margin: 0 auto 1.618em; /* Inherit WooCommerce image margin */
}

.apk-image-wrapper img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 !important; /* Remove margin from image, applied to wrapper instead */
}

/* ==========================================================================
   Labels Wrapper
   ========================================================================== */

.apk-labels-wrapper {
    position: absolute;
    height: min-content;
    display: flex;
    flex-flow: column nowrap;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    overflow: visible;
}

/* Out-of-image placement wrapper - displayed below the product image */
.apk-labels-wrapper.apk-placement-out-of-image {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    pointer-events: auto;
}

.apk-labels-wrapper.apk-placement-out-of-image .apk-label {
    position: relative;
    inset: auto;
}

/* ==========================================================================
   Single Label Styles
   ========================================================================== */

.apk-label {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    box-sizing: border-box;
    z-index: 10;
    /* Default badge styling - can be overridden by inline styles from database */
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
}

.apk-stacked {
    position: relative !important;
}

/* Label link wrapper */
.apk-label-link {
    pointer-events: auto;
    text-decoration: none;
    display: inline-block;
}

.apk-label-link:hover .apk-label {
    opacity: 0.9;
}

/* Shadow wrapper for clipped shapes */
.apk-label-shadow-wrapper {
    position: relative;
    pointer-events: auto;
}

/* ==========================================================================
   Placement Positions
   ========================================================================== */

/* Top Left */
.apk-placement-top-left {
    top: 10px;
    left: 10px;
}

/* Top Center */
.apk-placement-top-center {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

/* Top Right */
.apk-placement-top-right {
    top: 10px;
    right: 10px;
}

/* Middle Left */
.apk-placement-middle-left {
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
}

/* Middle Center */
.apk-placement-middle-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Middle Right */
.apk-placement-middle-right {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
}

/* Bottom Left */
.apk-placement-bottom-left {
    bottom: 10px;
    left: 10px;
}

/* Bottom Center */
.apk-placement-bottom-center {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
}

/* Bottom Right */
.apk-placement-bottom-right {
    bottom: 10px;
    right: 10px;
}

.apk-label-item {
    display: flex;
    width: 100%;
    position: absolute;
}

.apk-position-item-right {
    justify-content: flex-end;
}

/* ==========================================================================
   Badge Types
   ========================================================================== */

/* Text badge type */
.apk-badge-type-text .apk-label-text {
    display: block;
}

/* Image badge type */
.apk-badge-type-image {
    padding: 0;
    background: transparent !important;
}

.apk-badge-type-image .apk-label-image {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Icon badge type */
.apk-badge-type-icon {
    padding: 8px;
}

.apk-badge-type-icon .apk-label-icon {
    display: block;
    font-size: 1.2em;
}

/* ==========================================================================
   Tooltip Support
   ========================================================================== */

.apk-label[data-tooltip],
.apk-label-shadow-wrapper[data-tooltip] {
    cursor: help;
}

.apk-label[data-tooltip]:hover::after,
.apk-label-shadow-wrapper[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 5px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 11px;
    font-weight: normal;
    white-space: nowrap;
    border-radius: 3px;
    z-index: 100;
}

/* ==========================================================================
   Context-specific Styles
   ========================================================================== */

/* Archive/Loop pages - smaller labels */
.apk-labels-loop .apk-label {
    font-size: 11px;
    padding: 3px 8px;
}

/* Single product page - can be larger */
.apk-labels-single .apk-label {
    font-size: 13px;
    padding: 5px 12px;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media screen and (max-width: 768px) {
    .apk-label {
        font-size: 10px;
        padding: 3px 6px;
    }

    .apk-labels-loop .apk-label {
        font-size: 9px;
        padding: 2px 5px;
    }
}

@media screen and (max-width: 480px) {
    .apk-label {
        font-size: 9px;
        padding: 2px 5px;
    }
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes apk-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
  
@keyframes apk-flash {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0; }
}
  
@keyframes apk-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}
  
@keyframes apk-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
  
@keyframes apk-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
  
@keyframes apk-swing {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(15deg); }
    40% { transform: rotate(-10deg); }
    60% { transform: rotate(5deg); }
    80% { transform: rotate(-5deg); }   
}

.apk-animation-pulse { animation: apk-pulse 2s ease-in-out infinite; }
.apk-animation-flash { animation: apk-flash 2s ease-in-out infinite; }
.apk-animation-shake { animation: apk-shake 2s ease-in-out infinite; }
.apk-animation-bounce { animation: apk-bounce 2s ease-in-out infinite; }
.apk-animation-rotate { animation: apk-rotate 2s ease-in-out infinite; }
.apk-animation-swing { animation: apk-swing 2s ease-in-out infinite; }

/* ==========================================================================
   Custom Image Badge
   ========================================================================== */

.apk-label-custom-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ==========================================================================
   Single Product Override Styles
   ========================================================================== */

.product {
    overflow: visible !important;
}
