/* Enhanced Product Selector with Mask Preview Styles */

/* Product Card Styles */
.product-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    background: white;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.product-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.product-card.selected {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.product-card.disabled {
    border-color: #d1d5db;
    background: #f9fafb;
    cursor: not-allowed;
    opacity: 0.7;
}

.product-card.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Product Preview Section */
.product-preview-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    min-height: 120px;
}

.product-image, .mask-preview {
    position: relative;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.product-image img, .mask-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Product Labels */
.product-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 10px;
    padding: 4px 8px;
    text-align: center;
    font-weight: 500;
}

/* Mask Preview Specific Styles */
.mask-preview {
    position: relative;
}

.mask-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 8px;
}

.mask-preview:hover .mask-overlay {
    opacity: 1;
}

.mask-legend {
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: white;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.color-box.border {
    border: 1px solid #ccc;
}

/* Missing Mask Styles */
.mask-missing {
    background: #fef2f2;
    border-color: #fecaca;
}

.mask-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #9ca3af;
    text-align: center;
    padding: 16px;
}

/* Product Info Section */
.product-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.product-name {
    font-weight: 600;
    color: #111827;
    font-size: 14px;
    line-height: 1.3;
    margin: 0;
    flex: 1;
}

.product-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-ready {
    background: #dcfce7;
    color: #166534;
}

.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-processing {
    background: #dbeafe;
    color: #1e40af;
}

.status-error {
    background: #fee2e2;
    color: #dc2626;
}

.status-unknown {
    background: #f3f4f6;
    color: #6b7280;
}

.status-icon {
    font-size: 12px;
}

.status-text {
    font-weight: 500;
}

/* Product Meta Information */
.product-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #6b7280;
    gap: 8px;
}

.usage-count, .upload-date {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Selection Indicators */
.select-indicator {
    text-align: center;
    font-size: 11px;
    color: #3b82f6;
    font-weight: 500;
    padding: 4px 8px;
    background: #eff6ff;
    border-radius: 6px;
    margin-top: 4px;
}

.product-card.selected .select-indicator {
    color: #10b981;
    background: #ecfdf5;
}

.disabled-reason {
    text-align: center;
    font-size: 11px;
    color: #ef4444;
    font-weight: 500;
    padding: 4px 8px;
    background: #fef2f2;
    border-radius: 6px;
    margin-top: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .product-preview-section {
        grid-template-columns: 1fr;
        gap: 8px;
        min-height: auto;
    }
    
    .product-image, .mask-preview {
        min-height: 100px;
    }
    
    .product-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .product-meta {
        flex-direction: column;
        gap: 4px;
    }
}

/* Loading States */
.products-loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Enhanced Hover Effects */
.product-card:not(.disabled):hover .product-image {
    border-color: #3b82f6;
}

.product-card:not(.disabled):hover .mask-preview {
    border-color: #3b82f6;
}

.product-card.selected .product-image,
.product-card.selected .mask-preview {
    border-color: #10b981;
    background: #f0fdf4;
}

/* Accessibility Improvements */
.product-card:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.product-card[aria-selected="true"] {
    border-color: #10b981;
    background: #f0fdf4;
}

/* Animation for product grid appearance */
.product-card {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation for multiple cards */
.product-card:nth-child(1) { animation-delay: 0.1s; }
.product-card:nth-child(2) { animation-delay: 0.2s; }
.product-card:nth-child(3) { animation-delay: 0.3s; }
.product-card:nth-child(4) { animation-delay: 0.4s; }
.product-card:nth-child(5) { animation-delay: 0.5s; }
.product-card:nth-child(6) { animation-delay: 0.6s; }

/* Mask Quality Indicators (for future enhancement) */
.mask-quality-excellent::after {
    content: "✨";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 12px;
}

.mask-quality-good::after {
    content: "👍";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 12px;
}

.mask-quality-poor::after {
    content: "⚠️";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 12px;
}

/* Console Logging Visual Indicators */
.console-log-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #1f2937;
    color: #10b981;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.console-log-indicator.show {
    opacity: 1;
    transform: translateX(0);
}

/* Enhanced Error States */
.products-error {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Tooltip Styles for Mask Preview */
.mask-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.mask-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1f2937;
}

.mask-preview:hover .mask-tooltip {
    opacity: 1;
}
