/**
 * PosterLab Frame Add-on Styles
 * Beautiful frame selector with color swatches and preview
 */

/* Main wrapper */
.posterlab-frame-addon-wrapper {
    margin: 24px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 12px;
    border: 1px solid #e5e5e5;
}

/* Header */
.posterlab-frame-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
}

.posterlab-frame-label {
    font-family: 'Abhaya Libre ExtraBold', 'Georgia', serif;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.posterlab-frame-optional {
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Frame options grid */
.posterlab-frame-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 12px;
}

@media (min-width: 768px) {
    .posterlab-frame-options {
        grid-template-columns: repeat(9, 1fr);
    }
}

/* Individual frame option */
.posterlab-frame-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.posterlab-frame-option:hover {
    border-color: #ccc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.posterlab-frame-option.selected {
    border-color: #c41e3a;
    background: #fff5f7;
}

.posterlab-frame-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Color swatch */
.posterlab-frame-swatch {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
    border: 2px solid #e5e5e5;
}

.posterlab-frame-swatch-none {
    background: linear-gradient(135deg, #f5f5f5 45%, #ddd 45%, #ddd 55%, #f5f5f5 55%);
}

.posterlab-no-frame-icon {
    font-size: 20px;
    color: #999;
    font-weight: bold;
}

.posterlab-frame-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Frame name */
.posterlab-frame-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.2;
}

/* Frame price */
.posterlab-frame-price {
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

.posterlab-frame-option.selected .posterlab-frame-price {
    color: #c41e3a;
    font-weight: 600;
}

/* No frame option specific */
.posterlab-frame-option-no-frame .posterlab-frame-price {
    visibility: hidden;
}

/* Frame preview container */
.posterlab-frame-preview-container {
    margin-top: 20px;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.posterlab-frame-preview {
    max-width: 300px;
    margin: 0 auto;
    position: relative;
}

.posterlab-frame-preview-image {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Loading state */
.posterlab-frame-option.loading .posterlab-frame-swatch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top-color: #c41e3a;
    border-radius: 50%;
    animation: posterlab-spin 0.6s linear infinite;
}

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

/* Selected indicator */
.posterlab-frame-option.selected::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: #c41e3a;
    color: white;
    font-size: 10px;
    font-weight: bold;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.posterlab-frame-option {
    position: relative;
}

/* Tooltip for frame info */
.posterlab-frame-option[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: #333;
    color: #fff;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10;
}

.posterlab-frame-option:hover[data-tooltip]::before {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 8px);
}

/* Price update animation */
.posterlab-frame-price.updating {
    opacity: 0.5;
}

.posterlab-frame-price.updated {
    animation: posterlab-pulse 0.3s ease;
}

@keyframes posterlab-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .posterlab-frame-addon-wrapper {
        padding: 16px;
        margin: 16px 0;
    }
    
    .posterlab-frame-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .posterlab-frame-option {
        padding: 10px 6px;
    }
    
    .posterlab-frame-swatch {
        width: 40px;
        height: 40px;
    }
    
    .posterlab-frame-name {
        font-size: 10px;
    }
    
    .posterlab-frame-price {
        font-size: 9px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .posterlab-frame-addon-wrapper {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .posterlab-frame-label {
        color: #fff;
    }
    
    .posterlab-frame-option {
        background: #333;
    }
    
    .posterlab-frame-option.selected {
        background: #3d2a2e;
    }
    
    .posterlab-frame-name {
        color: #eee;
    }
    
    .posterlab-frame-price {
        color: #aaa;
    }
}

/* Integration with product gallery - show frame preview on main image */
.posterlab-product-with-frame {
    position: relative;
}

.posterlab-frame-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.posterlab-frame-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Summary section showing selected frame */
.posterlab-frame-summary {
    margin-top: 12px;
    padding: 12px;
    background: #fff;
    border-radius: 6px;
    border-left: 3px solid #c41e3a;
    display: none;
}

.posterlab-frame-summary.visible {
    display: block;
}

.posterlab-frame-summary-text {
    font-size: 14px;
    color: #333;
}

.posterlab-frame-summary-price {
    font-weight: 700;
    color: #c41e3a;
}

