/**
 * AWCOP Frontend Styles
 * Uses CSS variables for customizable colors
 */

/* CSS Variables - can be overridden via admin settings */
:root {
    --awcop-bg: #e6f0ff;
    --awcop-fill: #1e73be;
    --awcop-text: #333;
    --awcop-border: #ddd;
    --awcop-shadow: rgba(0, 0, 0, 0.1);
}

/* Progress Bar Container */
.awcop-progress-container {
    background: #dbdbdb;
    border-radius: 15px;
    height: 18px;
    width: 100%;
    overflow: hidden;
    position: relative;
    margin: 15px 0;
    box-shadow: 0 2px 4px var(--awcop-shadow);
    padding: 3px;
}

/* Progress Bar Fill */
.awcop-progress-bar {
    background-color: var(--awcop-fill);
    background: linear-gradient(116deg, var(--awcop-fill) 70%, var(--awcop-bg) 78%, var(--awcop-fill) 80%);
    background-size: 200% 100%;
    animation: awcop-gradient-slide 12s linear infinite;
    height: 100%;
    width: 0;
    transition: width 0.6s ease-in-out;
    border-radius: 8px;
    position: relative;
}

/* Subtle gradient slide from left to right */
@keyframes awcop-gradient-slide {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Progress Bar Text */
.awcop-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--awcop-text);
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
    white-space: nowrap;
    text-shadow: 0px 0px 1px black;
    display: none !important;
    /* Hidden as per new design */
}

/* Removed left-right shake; using periodic up-down bounce instead */

/* Periodic bounce (triggered by JS toggling awcop-bounce) */
@keyframes awcop-bounce-once {
    0% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-3px);
    }

    60% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(0);
    }
}

.awcop-progress-container.awcop-bounce {
    animation: awcop-bounce-once 0.6s ease-out;
}

/* Threshold level markers */
.awcop-progress-levels {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.awcop-level-marker {
    position: absolute;
    top: 0;
    height: 100%;
    width: 1px;
    background: rgba(0, 0, 0, 0.15);
}

.awcop-level-marker.reached {
    background: rgba(30, 115, 190, 0.8);
}

.awcop-level-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #2d2d2d;
    background: #fff;
    border: 1px solid var(--awcop-border);
    border-radius: 3px;
    padding: 2px 4px;
    white-space: nowrap;
}

/* Points Widget Container */
.awcop-points-widget,
body div .awcop-points-widget,
.awcop-cart-redemption,
body div .awcop-cart-redemption,
.awcop-gifts-container,
body div .awcop-gifts-container {
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    row-gap: 0;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
    padding: 25px;
    margin: 0 0 20px 0;
}

.awcop-cart-redemption,
body div .awcop-cart-redemption,
.awcop-gifts-container,
body div .awcop-gifts-container {
    margin-top: 20px;
}

.awcop-gifts-container,
body div .awcop-gifts-container {
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
    padding: 25px;
    gap: 40px;
}

body div .awcop-gift-selector-details,
body div .awcop-gift-selector-details select {
    width: 100%;
}

.awcop-gift-selector-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 20px;
}

body div .awcop-gift-selector-end {
    display: inline-block;
    color: green;
    font-weight: bold;
    font-size: 14px;
}

body div .awcop-gift-selector-details select {
    max-width: 500px;
}

body div .awcop-gift-selector-image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.awcop-points-widget p,
body div .awcop-points-widget p,
.awcop-cart-redemption p,
body div .awcop-cart-redemption p {
    margin: 0;
    padding: 0;
}

.awcop-points-widget h3,
body div .awcop-points-widget h3,
.awcop-cart-redemption h3,
body div .awcop-cart-redemption h3,
.awcop-gifts-container h3,
body div .awcop-gifts-container h3 {
    margin-top: 0;
    color: #2d2d2d;
    font-size: 16px;
    font-weight: bold;
    line-height: 1em;
    padding: 0;
    margin: 0;
}

.awcop-points-widget h3,
body div .awcop-points-widget h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.awcop-points-widget h3 svg,
body div .awcop-points-widget h3 svg {
    width: 30px;
    height: 30px;
}

/* Points Display */
.awcop-points-display,
body div .awcop-points-display {
    font-size: 16px;
    line-height: 1em;
    font-weight: bold;
    color: #2ECC71;
    margin: 0;
    padding: 0;
}

.awcop-points-label {
    font-size: 14px;
    color: #2d2d2d;
    margin-bottom: 5px;
}

/* Use Points Button */
.awcop-use-points-btn,
body div .awcop-use-points-btn {
    background: #2ECC71;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
    transition: all 0.2s ease;
}

.awcop-use-points-btn:hover {
    opacity: 0.7;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--awcop-shadow);
    background: #2ECC71;
    color: #fff;
}

.awcop-use-points-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Checkbox Style */
.awcop-checkbox-wrapper {
    display: flex;
    align-items: center;
    margin: 15px 0;
}

.awcop-checkbox-wrapper input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

.awcop-checkbox-wrapper label {
    font-size: 14px;
    color: var(--awcop-text);
    cursor: pointer;
}

/* Gift Selection Container */
.awcop-gifts-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2d2d2d;
}

/* Gift Threshold Section */
.awcop-gift-item {
    margin-bottom: 0;
}

.awcop-gift-item:last-child {
    margin-bottom: 0;
}

.awcop-gift-header {
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.awcop-gift-header strong {
    color: var(--awcop-fill);
    font-size: 16px;
    line-height: 1.2em;
    font-weight: bold;
}

.awcop-threshold-selected-badge {
    background: #46b450;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* Gift Options Grid */
.awcop-gift-options {
    display: grid;
    grid-template-columns: auto auto auto;
    gap: 15px;
    justify-content: start;
    justify-items: start;
    align-items: start;
    align-content: space-between;
}

/* Gift Product Card */
.awcop-gift-option {
    background: #fff;
    border: 1px solid var(--awcop-border);
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.awcop-gift-option:hover {
    border-color: var(--awcop-fill);
    box-shadow: 0 4px 8px var(--awcop-shadow);
    transform: translateY(-2px);
}

.awcop-gift-option.awcop-selected {
    border-color: #46b450;
    border-width: 2px;
    background: #f0f9f1;
}

.awcop-gift-image {
    margin-bottom: 12px;
    text-align: center;
    border-radius: 6px;
    overflow: hidden;
    background: #f9f9f9;
    position: relative;
}

.awcop-selected-checkmark {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #46b450;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

body div .awcop-gift-image img {
    height: 180px;
    width: 180px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.awcop-gift-option:hover .awcop-gift-image img {
    transform: scale(1.05);
}

.awcop-gift-info {
    margin-bottom: 12px;
    flex-grow: 1;
}

.awcop-gift-name {
    display: block;
    font-weight: 600;
    color: #155724;
    font-size: 15px;
    margin-bottom: 5px;
    line-height: 1.4;
}

.awcop-gift-price {
    display: block;
    color: #155724;
    font-size: 14px;
}

.awcop-gift-option .awcop-select-gift-btn {
    width: 100%;
    margin-top: auto;
    padding: 10px 16px;
    font-size: 14px;
}

.awcop-gift-option .awcop-select-gift-btn.awcop-selected {
    background: #46b450;
    border-color: #46b450;
}

.awcop-gift-option .awcop-select-gift-btn.awcop-selected:hover {
    background: #399c3e;
}

.awcop-gift-selector,
body div .awcop-gift-selector {
    display: flex;
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 25px;
    min-height: 70px;
}

body div .awcop-gift-selector svg {
    height: 64px;
    width: 64px;
}

/* Gift Message */
.awcop-gift-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 4px;
    font-size: 14px;
}

.awcop-gift-message.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.awcop-gift-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.awcop-gift-select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--awcop-border);
    border-radius: 4px;
    font-size: 14px;
}

/* Loading State */
.awcop-loading {
    opacity: 0.6;
    pointer-events: none;
}

.awcop-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--awcop-fill);
    border-radius: 50%;
    animation: awcop-spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Messages */
.awcop-message {
    padding: 12px 16px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

.awcop-message.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.awcop-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.awcop-message.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Responsive Design */
@media (max-width: 768px) {
    .awcop-points-widget {
        padding: 15px;
    }

    .awcop-points-display {
        font-size: 20px;
    }

    .awcop-use-points-btn {
        width: 100%;
        text-align: center;
    }

    /* Gift selection responsive */
    .awcop-gifts-container {
        padding: 15px;
    }

    .awcop-gift-options {
        grid-template-columns: 1fr;
    }

    .awcop-gift-header strong {
        font-size: 15px;
    }
}

/* Points Redemption UI */
.awcop-points-info {
    margin-bottom: 0;
    margin-top: 5px;
}

.awcop-points-info p {
    font-size: 14px;
    color: #2d2d2d;
}

.awcop-points-info strong {
    color: var(--awcop-fill, #1e73be);
    font-weight: 600;
}

.awcop-redemption-control {
    margin: 5px 0;
}

.awcop-redemption-control label {
    display: flex;
    align-items: center;
    gap: 0;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
}

.awcop-redemption-control label input {
    margin-right: 5px;
}

.awcop-redemption-control label .woocommerce-Price-amount {
    margin-left: 5px;
    margin-right: 5px;
}

.awcop-redemption-control input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.awcop-redemption-control input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.awcop-redemption-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.awcop-redemption-message .awcop-success {
    color: #46b450;
    display: block;
}

.awcop-redemption-message .awcop-error {
    color: #dc3232;
    display: block;
}

.awcop-redemption-message .awcop-loading {
    color: #2d2d2d;
    display: block;
}

.awcop-redemption-message p {
    margin: 5px 0 0;
    font-weight: 600;
    color: var(--awcop-fill, #1e73be);
}

/* Loading Animation for Redemption */
.awcop-redemption-message .awcop-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-left-color: #2d2d2d;
    border-radius: 50%;
    animation: awcop-spin 0.8s linear infinite;
}

/* Responsive for redemption UI */
@media (max-width: 768px) {
    .awcop-cart-redemption {
        padding: 15px;
    }

    .awcop-cart-redemption h3 {
        font-size: 16px;
    }

    .awcop-redemption-control label {
        font-size: 14px;
    }
}

/* Gift Items - Hide Quantity Controls */
.cart_item.awcop-gift-item .product-quantity {
    opacity: 0.6;
    pointer-events: none;
}

.cart_item.awcop-gift-item .product-remove {
    display: none;
}

.cart_item.awcop-gift-item::before {
    content: "🎁 ";
    display: inline-block;
}

.cart_item.awcop-gift-item .product-name {
    font-weight: 600;
    color: var(--awcop-fill, #1e73be);
}

.cart_item.awcop-gift-item .product-price {
    color: #46b450;
}

/* Gift Badge */
.awcop-gift-badge {
    display: inline-block;
    background: var(--awcop-fill, #1e73be) !important;
    color: var(--awcop-text, #1e73be) !important;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
    letter-spacing: 0.5px;
}

/* Gift Quantity Lock */
.awcop-gift-qty-locked {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.awcop-gift-qty-locked .awcop-gift-badge {
    margin-left: 0;
}

/* Gift Auto-Managed Info Icon */
.awcop-gift-auto-managed {
    cursor: help;
    font-size: 16px;
    opacity: 0.7;
}

.awcop-gift-auto-managed:hover {
    opacity: 1;
}

.woocommerce-account .awcop-points-widget {
    text-align: center;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.woocommerce-account .awcop-points-widget .awcop-use-points-btn {
    text-decoration: none;
}

.awcop-woocommerce-my-account-points-title {
    font-size: 1.2em;
    margin-bottom: 1em;
    color: var(--awcop-text, #333);
    border-bottom: 2px solid var(--awcop-fill, #1e73be);
    padding-bottom: 0.5em;
}

.awcop-my-points-info {
    margin-bottom: 2em;
    padding: 0;
}

.awcop-my-points-info {
    background-color: transparent;
    color: #333;
}

.awcop-my-points-info p {
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: #333;
}

.awcop-my-points-info p:last-child {
    margin-bottom: 0;
}

.awcop-points-value-overview {
    margin-bottom: 2em;
    padding: 1em;
    background-color: #ededed;
    color: #333;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.awcop-points-value-overview ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.awcop-points-value-overview li {
    padding: 0.5em 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-weight: 500;
  color: #333;
}

.awcop-points-value-overview li:last-child {
    border-bottom: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .awcop-woocommerce-my-account-points-title {
        font-size: 1.1em;
    }

    .awcop-my-points-info,
    .awcop-points-value-overview {
        padding: 0.8em;
    }

    body .awcop-gift-option {
        width: 100%;
        height: auto;
        position: relative;
    }

    body div .awcop-gift-image img {
        width: 100%;
        max-width: 100%;
        height: auto;
        object-fit: contain;
    }

    .awcop-gifts-container {
        margin: 0;
    }
}