/**
 * Image Cropper Styles for Product Images
 * Enforces 1:1 aspect ratio for consistent display
 * 
 * Requirements:
 * - Aspect Ratio: 1:1 (square)
 * - Minimum Size: 800 x 800 px
 * - Maximum Size: 2000 x 2000 px
 * - Max File Size: 5MB
 */

/* ===== Cropper Modal Styles ===== */
.image-cropper-modal .modal-dialog {
    max-width: 850px;
}

.image-cropper-modal .modal-header {
    padding: 12px 20px;
}

.image-cropper-modal .modal-body {
    padding: 0;
    background: #1a1a2e;
}

/* Instruction bar */
.cropper-instruction-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 12px 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.cropper-instruction-bar i {
    font-size: 18px;
}

/* Cropper container */
.cropper-container-wrapper {
    width: 100%;
    height: 450px;
    position: relative;
    overflow: hidden;
    background: #0d1117;
}

.cropper-container-wrapper img {
    max-width: 100%;
    display: block;
}

/* Cropper.js custom styles */
.cropper-view-box,
.cropper-face {
    border-radius: 0;
}

.cropper-view-box {
    outline: 3px solid #6750A4;
    outline-color: rgba(103, 80, 164, 0.9);
}

.cropper-line {
    background-color: #6750A4;
}

.cropper-point {
    background-color: #6750A4;
    width: 12px;
    height: 12px;
    opacity: 1;
    border-radius: 50%;
}

.cropper-point.point-se {
    width: 16px;
    height: 16px;
}

.cropper-modal {
    background-color: rgba(0, 0, 0, 0.6);
}

.cropper-dashed {
    border-color: rgba(255, 255, 255, 0.5);
}

/* Cropper info bar */
.cropper-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #161b22;
    font-size: 13px;
    color: #8b949e;
    border-top: 1px solid #30363d;
}

.cropper-info-bar .original-size {
    color: #8b949e;
}

.cropper-info-bar .size-info {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
}

.cropper-info-bar .size-info.valid {
    background: rgba(40, 167, 69, 0.2);
    color: #3fb950;
}

.cropper-info-bar .size-info.invalid {
    background: rgba(220, 53, 69, 0.2);
    color: #f85149;
}

/* Cropper controls */
.cropper-controls {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    flex-wrap: wrap;
}

.cropper-controls .btn-group {
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.cropper-controls .btn {
    padding: 8px 12px;
}

.cropper-controls .btn i {
    font-size: 18px;
}

/* ===== Image Validation Indicator ===== */
/* Support multiple container types */
.image-wrapper,
.image-uploaded-div,
.card-img-top,
.border.rounded {
    position: relative;
}

.image-status-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 10;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.image-status-badge.valid {
    background: #28a745;
    color: #fff;
    pointer-events: none;
}

.image-status-badge.invalid {
    background: #dc3545;
    color: #fff;
    animation: pulse-warning 2s infinite;
    z-index: 12;
    pointer-events: auto !important;
}

@keyframes pulse-warning {
    0%, 100% { box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4); }
    50% { box-shadow: 0 2px 16px rgba(220, 53, 69, 0.8); }
}

.image-status-badge.invalid:hover {
    transform: scale(1.1);
    background: #c82333;
}

/* Needs crop overlay - fit to image container */
.needs-crop {
    position: relative;
    z-index: 1;
    display: inline-block !important;
}

.needs-crop::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(220, 53, 69, 0.1);
    border: 2px dashed #dc3545;
    border-radius: 8px;
    pointer-events: none;
    z-index: 2;
}

.needs-crop img {
    opacity: 0.85;
}

.needs-crop > a {
    pointer-events: none;
}

.needs-crop .image-crop-edit-btn,
.needs-crop .image-status-badge {
    pointer-events: auto !important;
}

/* Edit button on invalid images */
.image-crop-edit-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #6750A4 0%, #9c27b0 100%);
    color: #fff !important;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(103, 80, 164, 0.4);
    white-space: nowrap;
    text-decoration: none !important;
    pointer-events: auto !important;
}

.image-crop-edit-btn:hover {
    background: linear-gradient(135deg, #5a4399 0%, #7b1fa2 100%);
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(103, 80, 164, 0.5);
}

.image-crop-edit-btn i {
    font-size: 18px;
}

/* ===== Image Upload Area ===== */
.image-upload-section .card.border-dashed {
    border: 2px dashed #dee2e6;
    transition: all 0.2s ease;
}

.image-upload-section .card.border-dashed:hover {
    border-color: #6750A4;
    background: rgba(103, 80, 164, 0.05);
}

/* Image requirements info box */
.image-requirements-info {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-left: 4px solid #6750A4;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 18px;
}

.image-requirements-info h6 {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.image-requirements-info h6 i {
    color: #6750A4;
}

.image-requirements-info ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.image-requirements-info li {
    font-size: 12px;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 6px;
}

.image-requirements-info li i {
    color: #6750A4;
    font-size: 14px;
    width: 18px;
}

/* ===== Validation Messages ===== */
.image-validation-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 10px;
}

.image-validation-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.image-validation-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.image-validation-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* ===== Animation ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.image-wrapper.shake {
    animation: shake 0.5s ease-in-out;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
    .image-cropper-modal .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .cropper-container-wrapper {
        height: 300px;
    }
    
    .cropper-controls {
        padding: 10px 15px;
        gap: 8px;
    }
    
    .cropper-controls .btn {
        padding: 6px 10px;
    }
    
    .cropper-controls .btn i {
        font-size: 16px;
    }

    .image-requirements-info ul {
        grid-template-columns: 1fr;
    }
    
    .image-crop-edit-btn {
        padding: 10px 18px;
        font-size: 13px;
    }
}

/* ===== Dark Mode Support ===== */
[data-bs-theme="dark"] .image-requirements-info {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-color: #4a5568;
}

[data-bs-theme="dark"] .image-requirements-info h6 {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .image-requirements-info li {
    color: #a0aec0;
}

[data-bs-theme="dark"] .cropper-controls {
    background: #1a202c;
    border-color: #4a5568;
}

[data-bs-theme="dark"] .cropper-controls .btn-outline-secondary {
    color: #e2e8f0;
    border-color: #4a5568;
}

[data-bs-theme="dark"] .cropper-controls .btn-outline-secondary:hover {
    background: #2d3748;
}
