/**
 * ShopLinker Frontend Styles
 * Modern, responsive design for product preview popup
 */

/* Popup Container */
#shoplinker-popup-container {
    position: fixed;
    z-index: 999998;
    pointer-events: none;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#shoplinker-popup-container.active {
    pointer-events: auto;
}

/* Backdrop - invisible overlay for clicking outside */
#shoplinker-popup-container.active::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: auto;
    cursor: default;
}

.shoplinker-product-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(0, 0, 0, 0.2);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Icon Styles */
.shoplinker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    vertical-align: middle;
}

.shoplinker-icon img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
}

.shoplinker-icon-custom img {
    max-width: 20px;
    max-height: 20px;
}

.shoplinker-product-link:hover {
    text-decoration-color: rgba(0, 0, 0, 0.5);
    color: inherit;
}

.shoplinker-product-link.shoplinker-out-of-stock {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Popup Container */
.shoplinker-popup {
    position: absolute !important;
    z-index: 999999 !important;
    display: none;
    width: 320px;
    max-width: 90vw;
    background: #ffffff !important;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: shoplinkerFadeIn 0.3s ease-out;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s;
}

.shoplinker-popup.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s 0s;
}

/* Close button */
.shoplinker-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 1000000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
    pointer-events: auto !important;
}

.shoplinker-popup-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.shoplinker-popup-close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.shoplinker-popup-close:active {
    transform: scale(0.95);
}

/* Popup Arrow */
.shoplinker-popup::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #ffffff;
}

.shoplinker-popup.shoplinker-popup-bottom::before {
    top: auto;
    bottom: -8px;
    border-bottom: none;
    border-top: 8px solid #ffffff;
}

.shoplinker-popup.shoplinker-popup-left::before {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    border-left: none;
    border-right: 8px solid #ffffff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.shoplinker-popup.shoplinker-popup-right::before {
    right: 20px;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    border-right: none;
    border-left: 8px solid #ffffff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

/* Popup Content */
.shoplinker-popup-content {
    padding: 0;
}

.shoplinker-popup-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background: #f5f5f5;
}

.shoplinker-popup-body {
    padding: 16px;
}

.shoplinker-popup-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1a1a1a;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shoplinker-popup-price {
    font-size: 20px;
    font-weight: 700;
    color: #2c5530;
    margin: 0 0 12px 0;
}

.shoplinker-popup-price del {
    font-size: 14px;
    font-weight: 400;
    color: #999;
    margin-right: 8px;
}

.shoplinker-popup-price ins {
    text-decoration: none;
    color: #d32f2f;
}

.shoplinker-popup-description {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin: 0 0 16px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shoplinker-popup-stock {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 12px;
}

.shoplinker-popup-stock.shoplinker-in-stock {
    background: #e8f5e9;
    color: #2e7d32;
}

.shoplinker-popup-stock.shoplinker-out-of-stock {
    background: #ffebee;
    color: #c62828;
}

/* Add to Cart Button */
.shoplinker-popup-button {
    width: 100%;
    padding: 12px 20px;
    background: #2c5530;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
    display: block;
    box-sizing: border-box;
    margin-bottom: 0;
}

/* Success message and view cart */
.shoplinker-popup-after-add,
.shoplinker-already-in-cart {
    text-align: center;
    padding: 15px 0;
}

.shoplinker-success-message {
    color: #2e7d32;
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.shoplinker-view-cart-button {
    display: inline-block;
    padding: 10px 20px;
    background: #2c5530;
    color: #ffffff !important;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    text-align: center;
}

.shoplinker-view-cart-button:hover {
    background: #1e3d21;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 85, 48, 0.3);
    color: #ffffff !important;
}

.shoplinker-view-cart-button:active {
    transform: translateY(0);
}

.shoplinker-popup-button:hover {
    background: #1e3d21;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 85, 48, 0.3);
}

.shoplinker-popup-button:active {
    transform: translateY(0);
}

.shoplinker-popup-button:disabled,
.shoplinker-popup-button.shoplinker-loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.shoplinker-popup-button.shoplinker-success {
    background: #2e7d32;
}

.shoplinker-popup-button.shoplinker-success::after {
    content: ' ✓';
}

/* Loading Spinner */
.shoplinker-popup-button.shoplinker-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: shoplinkerSpin 0.6s linear infinite;
    vertical-align: middle;
}

/* Error Message */
.shoplinker-error {
    color: #c62828;
    font-size: 14px;
    padding: 8px;
    background: #ffebee;
    border-radius: 4px;
    display: inline-block;
}

/* Loading State */
.shoplinker-popup-loading {
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

.shoplinker-popup-loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #2c5530;
    border-radius: 50%;
    animation: shoplinkerSpin 0.6s linear infinite;
}

/* Animations */
@keyframes shoplinkerFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shoplinkerSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .shoplinker-popup {
        width: 280px;
    }
    
    .shoplinker-popup-image {
        height: 160px;
    }
    
    .shoplinker-popup-body {
        padding: 12px;
    }
    
    .shoplinker-popup-title {
        font-size: 14px;
    }
    
    .shoplinker-popup-price {
        font-size: 18px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .shoplinker-popup {
        border: 2px solid #000;
    }
    
    .shoplinker-product-link {
        text-decoration-thickness: 2px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .shoplinker-popup,
    .shoplinker-product-link,
    .shoplinker-popup-button {
        animation: none;
        transition: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .shoplinker-popup {
        background: #1a1a1a;
        color: #ffffff;
    }
    
    .shoplinker-popup::before {
        border-bottom-color: #1a1a1a;
    }
    
    .shoplinker-popup.shoplinker-popup-bottom::before {
        border-top-color: #1a1a1a;
    }
    
    .shoplinker-popup-title {
        color: #ffffff;
    }
    
    .shoplinker-popup-description {
        color: #cccccc;
    }
    
    .shoplinker-popup-image {
        background: #2a2a2a;
    }
}

