/**
 * Cart Popup Cross-sell Styles
 * Jasny, minimalistyczny design pasujący do aromaholik
 */

/* Overlay */
.tp-cart-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 99999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tp-cart-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Popup Container */
.tp-cart-popup {
    background: #fff;
    border-radius: 16px;
    max-width: 600px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease;
}

.tp-cart-popup-overlay.active .tp-cart-popup {
    transform: scale(1) translateY(0);
}

/* Close Button */
.tp-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.tp-popup-close:hover {
    background: #eee;
    color: #333;
}

/* Header */
.tp-popup-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: linear-gradient(135deg, #faf8f5 0%, #f5f2ed 100%);
    border-bottom: 1px solid #e8e4dc;
}

/* Timer Circle */
.tp-popup-timer {
    flex-shrink: 0;
}

.tp-timer-circle {
    position: relative;
    width: 80px;
    height: 80px;
}

.tp-timer-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.tp-timer-circle circle {
    fill: none;
    stroke-width: 5;
}

.tp-timer-bg {
    stroke: #e8e4dc;
}

.tp-timer-progress {
    stroke: #8B7355;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.tp-timer-progress.warning {
    stroke: #d4a574;
}

.tp-timer-progress.danger {
    stroke: #c97c5d;
}

.tp-timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: 600;
    color: #5a4a3a;
    font-family: inherit;
}

/* Title Wrapper */
.tp-popup-title-wrapper {
    flex: 1;
}

.tp-popup-title {
    color: #3a3a3a;
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.3;
}

.tp-popup-subtitle {
    color: #777;
    font-size: 13px;
    margin: 0 0 10px;
    line-height: 1.4;
}

.tp-popup-header .tp-popup-discount-badge {
    display: inline-block;
    background: #d32f2f;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.25);
    margin-top: 8px;
}

/* Products Grid */
.tp-popup-products {
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    overflow-y: auto;
    background: #fff;
}

.tp-popup-product {
    flex: 0 0 auto;
    width: 160px;
    max-width: 180px;
}

.tp-popup-products::-webkit-scrollbar {
    width: 4px;
}

.tp-popup-products::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.tp-popup-products::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

/* Product Card */
.tp-popup-product {
    background: #fafafa;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s ease;
    border: 1px solid #eee;
}

.tp-popup-product:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.tp-popup-product-image {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    margin-bottom: 12px;
    background: #fff;
    overflow: hidden;
}

.tp-popup-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tp-popup-product-info {
    text-align: center;
}

.tp-popup-product-name {
    color: #3a3a3a;
    font-size: 13px;
    font-weight: 500;
    margin: 0 0 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 54px;
}

.tp-popup-product-price {
    margin-bottom: 12px;
}

.tp-popup-product-price del {
    color: #999;
    font-size: 12px;
    margin-right: 6px;
}

.tp-popup-product-price ins {
    color: #8B7355;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
}

/* Legacy price classes */
.tp-popup-product-prices {
    margin-bottom: 12px;
}

.tp-popup-price-old {
    color: #999;
    text-decoration: line-through;
    font-size: 12px;
    margin-right: 6px;
}

.tp-popup-price-new {
    color: #8B7355;
    font-size: 16px;
    font-weight: 600;
}

/* Product Actions */
.tp-popup-product-actions {
    margin-top: 12px;
}

/* Add Button */
.tp-popup-add-btn {
    width: 100%;
    background: linear-gradient(135deg, #43a047 0%, #2e7d32 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    min-height: 38px;
    box-shadow: 0 4px 10px rgba(46, 125, 50, 0.2);
}

.tp-popup-add-btn:hover:not(:disabled):not(.loading):not(.added) {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(46, 125, 50, 0.3);
}

.tp-popup-add-btn:active:not(:disabled):not(.loading):not(.added) {
    transform: translateY(0);
}

.tp-popup-add-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Button Loading State */
.tp-popup-add-btn.loading {
    color: transparent !important;
    pointer-events: none;
    background: #8B7355;
}

.tp-popup-add-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tp-btn-spin 0.8s linear infinite;
}

/* Button Added State */
.tp-popup-add-btn.added {
    background: #6a9a6a;
    cursor: default;
    pointer-events: none;
}

.tp-popup-add-btn.added::before {
    content: '✓ ';
}

/* Footer */
.tp-popup-footer {
    padding: 16px 24px;
    text-align: center;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.tp-popup-skip {
    background: transparent;
    border: 1px solid #ddd;
    color: #777;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tp-popup-skip:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #555;
}

/* Expired State */
.tp-cart-popup.expired {
    opacity: 0.95;
}

.tp-cart-popup.expired .tp-popup-add-btn {
    background: #bbb !important;
    cursor: not-allowed;
    pointer-events: none;
}

.tp-cart-popup.expired .tp-timer-progress {
    stroke: #c97c5d !important;
}

.tp-cart-popup.expired .tp-timer-text {
    color: #c97c5d;
}

.tp-cart-popup.expired .tp-popup-discount-badge {
    background: #bbb;
}

.tp-cart-popup.expired .tp-popup-product {
    opacity: 0.7;
}

/* Loading State */
.tp-popup-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 40px 20px;
    gap: 16px;
    color: #888;
    font-size: 14px;
}

.tp-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e8e4dc;
    border-top-color: #8B7355;
    border-radius: 50%;
    animation: tp-btn-spin 0.8s linear infinite;
}

/* Animations */
@keyframes tp-btn-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Notifications */
.tp-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #fff;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 999999999;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    max-width: 90%;
    min-width: 280px;
}

.tp-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.tp-notification-success {
    border-left: 4px solid #6a9a6a;
}

.tp-notification-success .dashicons,
.tp-notification-success .tp-notification-icon {
    color: #6a9a6a;
}

.tp-notification-error {
    border-left: 4px solid #c97c5d;
}

.tp-notification-error .dashicons,
.tp-notification-error .tp-notification-icon {
    color: #c97c5d;
}

.tp-notification-warning {
    border-left: 4px solid #d4a574;
}

.tp-notification-warning .dashicons,
.tp-notification-warning .tp-notification-icon {
    color: #d4a574;
}

.tp-notification .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.tp-notification-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.tp-notification-message {
    font-size: 14px;
    color: #3a3a3a;
    line-height: 1.4;
}

/* Cart badge styles (for mini-cart) */
.tp-popup-discount-badge,
.tp-mini-cart-badge {
    display: inline-block;
    background: #8B7355;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
    vertical-align: middle;
}

/* Fixed quantity display for popup products in cart */
.tp-popup-fixed-quantity {
    display: inline-block;
    background: #f5f2ed;
    padding: 5px 12px;
    border-radius: 4px;
    font-weight: 600;
    color: #8B7355;
    cursor: not-allowed;
    font-size: 13px;
}

/* Cart page discount styles */
.woocommerce-cart-form .tp-popup-discount-badge,
.woocommerce-checkout .tp-popup-discount-badge {
    font-size: 11px;
    padding: 3px 8px;
}

/* Mobile Responsive */
@media (max-width: 600px) {

    /* Ensure box-sizing for all popup elements */
    .tp-cart-popup,
    .tp-cart-popup *,
    .tp-cart-popup *::before,
    .tp-cart-popup *::after {
        box-sizing: border-box;
    }

    .tp-cart-popup-overlay {
        align-items: center;
        justify-content: center;
        padding: 12px;
    }

    .tp-cart-popup {
        width: calc(100% - 24px);
        max-width: 600px;
        max-height: 85vh;
        border-radius: 16px;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
    }

    .tp-popup-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .tp-popup-header {
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: 16px;
        gap: 12px;
        flex-shrink: 0;
    }

    .tp-popup-title-wrapper {
        padding-right: 28px;
    }

    .tp-timer-circle {
        width: 60px;
        height: 60px;
    }

    .tp-timer-text {
        font-size: 13px;
    }

    .tp-popup-title {
        font-size: 16px;
        margin-bottom: 4px;
    }

    .tp-popup-subtitle {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .tp-popup-header .tp-popup-discount-badge {
        font-size: 12px;
        padding: 4px 10px;
        margin-top: 4px;
    }

    .tp-popup-products {
        padding: 12px;
        gap: 10px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .tp-popup-product {
        width: calc(50% - 5px);
        max-width: none;
        padding: 10px;
    }

    .tp-popup-product-image {
        margin-bottom: 8px;
    }

    .tp-popup-product-name {
        font-size: 11px;
        min-height: 40px;
        margin-bottom: 6px;
    }

    .tp-popup-product-price {
        margin-bottom: 8px;
    }

    .tp-popup-product-price del,
    .tp-popup-price-old {
        font-size: 11px;
    }

    .tp-popup-product-price ins,
    .tp-popup-price-new {
        font-size: 13px;
    }

    .tp-popup-product-actions {
        margin-top: 8px;
    }

    .tp-popup-add-btn {
        padding: 7px 10px;
        font-size: 10px;
        min-height: 32px;
        letter-spacing: 0.3px;
    }

    .tp-popup-footer {
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        flex-shrink: 0;
    }

    .tp-popup-skip {
        padding: 8px 20px;
        font-size: 12px;
    }

    .tp-notification {
        bottom: 20px;
        left: 10px;
        right: 10px;
        transform: translateX(0) translateY(100px);
        min-width: auto;
    }

    .tp-notification.show {
        transform: translateX(0) translateY(0);
    }

    /* FOMO elements on mobile */
    .tp-selling-fast-badge {
        top: 6px;
        left: 6px;
        padding: 3px 6px;
        font-size: 9px;
    }

    .tp-stock-text {
        font-size: 10px;
    }
}

/* Very small screens (360px and below, e.g. Samsung Galaxy S8+) */
@media (max-width: 399px) {

    .tp-cart-popup-overlay {
        padding: 8px;
    }

    .tp-cart-popup {
        width: calc(100% - 16px);
        max-height: 90vh;
        border-radius: 12px;
    }

    .tp-popup-header {
        flex-direction: row;
        padding: 12px;
        gap: 10px;
    }

    .tp-popup-title-wrapper {
        padding-right: 24px;
    }

    .tp-timer-circle {
        width: 50px;
        height: 50px;
    }

    .tp-timer-text {
        font-size: 12px;
    }

    .tp-popup-title {
        font-size: 14px;
        line-height: 1.2;
        margin-bottom: 3px;
    }

    .tp-popup-subtitle {
        font-size: 11px;
        line-height: 1.3;
        margin-bottom: 4px;
    }

    .tp-popup-header .tp-popup-discount-badge {
        font-size: 11px;
        padding: 3px 8px;
        margin-top: 2px;
    }

    .tp-popup-products {
        padding: 10px;
        gap: 8px;
    }

    .tp-popup-product {
        width: calc(50% - 4px);
        padding: 8px;
        border-radius: 8px;
    }

    .tp-popup-product-image {
        border-radius: 6px;
        margin-bottom: 6px;
    }

    .tp-popup-product-name {
        font-size: 10px;
        min-height: 32px;
        margin-bottom: 4px;
        line-height: 1.3;
    }

    .tp-popup-product-price {
        margin-bottom: 6px;
    }

    .tp-popup-product-price del,
    .tp-popup-price-old {
        font-size: 10px;
        margin-right: 3px;
    }

    .tp-popup-product-price ins,
    .tp-popup-price-new {
        font-size: 12px;
    }

    .tp-popup-product-actions {
        margin-top: 6px;
    }

    .tp-popup-add-btn {
        padding: 6px 8px;
        font-size: 9px;
        min-height: 28px;
        border-radius: 6px;
        letter-spacing: 0.2px;
    }

    .tp-popup-footer {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .tp-popup-skip {
        padding: 7px 16px;
        font-size: 11px;
    }

    .tp-popup-close {
        top: 6px;
        right: 6px;
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    /* FOMO elements on very small screens */
    .tp-selling-fast-badge {
        top: 4px;
        left: 4px;
        padding: 2px 5px;
        font-size: 8px;
    }

    .tp-stock-bar-container {
        margin: 4px 0;
    }

    .tp-stock-text {
        font-size: 9px;
    }
}

/* FOMO Effects */
@keyframes pulse-red {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

.tp-timer-progress.critical {
    stroke: #dc3545;
    /* transition handled by base class */
}

.tp-cart-popup-timer.critical {
    color: #dc3545;
    animation: pulse-red 2s infinite;
    border-radius: 50%;
    z-index: 1;
    /* Ensure above background if needed */
}

.tp-selling-fast-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #d32f2f;
    /* Solid premium red */
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
    /* Subtle colored shadow */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tp-stock-bar-container {
    margin: 8px 0;
    width: 100%;
}

.tp-stock-bar {
    height: 4px;
    /* Thinner */
    background: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.tp-stock-progress {
    height: 100%;
    background: #d32f2f;
    /* Match badge */
    border-radius: 2px;
}

.tp-stock-text {
    font-size: 11px;
    color: #666;
    text-align: right;
}

/* Enhancing existing discount badge */
.tp-popup-product-price ins {
    color: #e63946;
    font-weight: bold;
}