/* Image Gallery Styles */
.product-avatar {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid #ddd;
}

.product-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.has-gallery {
    position: relative;
}

.has-gallery::after {
    content: '📷';
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Gallery Modal */
.gallery-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: auto;
}

.gallery-modal.active {
    display: block;
}

.gallery-content {
    position: relative;
    margin: 50px auto;
    width: 90%;
    max-width: 1200px;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.gallery-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 36px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: color 0.2s;
}

.gallery-close:hover {
    color: #e74c3c;
}

.gallery-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.gallery-header h2 {
    margin: 0 0 10px 0;
    color: #333;
}

.gallery-header p {
    margin: 0;
    color: #777;
    font-size: 14px;
}

.gallery-main-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 30px;
    background: #f9f9f9;
}

.gallery-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.gallery-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* Square aspect ratio */
}

.gallery-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 3px solid transparent;
}

.gallery-thumbnail img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.gallery-thumbnail.primary img {
    border-color: #3498db;
}

.gallery-thumbnail.primary::after {
    content: 'PRIMARY';
    position: absolute;
    top: 5px;
    left: 5px;
    background: #3498db;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.gallery-thumbnail-actions {
    position: absolute;
    bottom: 5px;
    left: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-thumbnail:hover .gallery-thumbnail-actions {
    opacity: 1;
}

.gallery-thumbnail-btn {
    flex: 1;
    padding: 5px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.gallery-thumbnail-btn.primary-btn {
    background: #3498db;
    color: white;
}

.gallery-thumbnail-btn.primary-btn:hover {
    background: #2980b9;
}

.gallery-thumbnail-btn.delete-btn {
    background: #e74c3c;
    color: white;
}

.gallery-thumbnail-btn.delete-btn:hover {
    background: #c0392b;
}

.gallery-upload-section {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    border: 2px dashed #ddd;
}

.gallery-upload-section h3 {
    margin-top: 0;
    color: #333;
}

.gallery-upload-dropzone {
    border: 3px dashed #3498db;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background: white;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.gallery-upload-dropzone:hover {
    background: #ecf0f1;
    border-color: #2980b9;
}

.gallery-upload-dropzone.dragover {
    background: #d5e8f7;
    border-color: #2980b9;
}

.gallery-upload-dropzone p {
    margin: 10px 0;
    color: #555;
}

.gallery-upload-dropzone .icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.gallery-file-input {
    display: none;
}

.gallery-upload-preview {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.gallery-upload-preview-item {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
}

.gallery-upload-preview-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.gallery-upload-preview-item .remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
}

.gallery-upload-btn {
    margin-top: 15px;
    padding: 12px 30px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.gallery-upload-btn:hover {
    background: #229954;
}

.gallery-upload-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Loading spinner */
.gallery-loading {
    text-align: center;
    padding: 40px;
    color: #777;
}

.gallery-loading::after {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty state */
.gallery-empty {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* Image upload button in product list */
.upload-image-btn {
    padding: 6px 12px;
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.upload-image-btn:hover {
    background: #8e44ad;
}

.image-count-badge {
    display: inline-block;
    background: #3498db;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
}
