/**
 * Crop Interface Styles
 * 
 * Provides styling for the Canvas-based crop engine with modern design
 * and smooth animations. Includes responsive design for all devices.
 */

/* Crop Modal Container */
.crop-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-modal.active {
    opacity: 1;
    visibility: visible;
}

.crop-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

/* Crop Modal Content */
.crop-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    max-width: 95vw;
    max-height: 95vh;
    width: 1000px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.crop-modal.active .crop-modal-content {
    transform: scale(1) translateY(0);
}

/* Body class when modal is open */
body.crop-modal-open {
    overflow: hidden;
}

/* Crop Header */
.crop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.crop-title-section {
    flex: 1;
}

.crop-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.crop-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
    font-weight: 400;
    opacity: 0.8;
}

.crop-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.crop-close:hover {
    background-color: #f3f4f6;
    color: #374151;
    transform: scale(1.05);
}

.crop-close:active {
    transform: scale(0.95);
}

/* Crop Canvas Container */
.crop-canvas-container {
    position: relative;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f9f9f9;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-canvas {
    display: block;
    max-width: 100%;
    max-height: 400px;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Loading State */
.crop-canvas-container.loading {
    background: #f0f0f0;
}

.crop-canvas-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--photo-uploader-primary, #007cba);
    border-radius: 50%;
    animation: crop-loading-spin 1s linear infinite;
}

@keyframes crop-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Crop Controls */
.crop-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.crop-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: #666;
    flex: 1;
    min-width: 200px;
}

.crop-info-item {
    display: flex;
    justify-content: space-between;
}

.crop-info-label {
    font-weight: 500;
}

.crop-info-value {
    font-family: monospace;
    color: #333;
}

/* Crop Actions */
.crop-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.crop-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 80px;
    justify-content: center;
}

.crop-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.crop-btn-primary {
    background: var(--photo-uploader-primary, #007cba);
    color: white;
}

.crop-btn-primary:hover:not(:disabled) {
    background: var(--photo-uploader-primary-dark, #005a87);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.crop-btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.crop-btn-secondary:hover:not(:disabled) {
    background: #e9e9e9;
    border-color: #ccc;
}

.crop-btn-danger {
    background: #dc3545;
    color: white;
}

.crop-btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

/* Crop Settings Panel */
.crop-settings {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.crop-settings-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px 0;
}

.crop-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.crop-setting-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.crop-setting-label {
    font-size: 12px;
    font-weight: 500;
    color: #555;
}

.crop-setting-input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    background: white;
    transition: border-color 0.2s ease;
}

.crop-setting-input:focus {
    outline: none;
    border-color: var(--photo-uploader-primary, #007cba);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

/* Crop Instructions */
.crop-instructions {
    margin-top: 15px;
    padding: 12px;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    font-size: 13px;
    color: #0066cc;
}

.crop-instructions ul {
    margin: 0;
    padding-left: 20px;
}

.crop-instructions li {
    margin-bottom: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .crop-modal-content {
        width: 95vw;
        padding: 15px;
        margin: 10px;
    }
    
    .crop-header {
        margin-bottom: 15px;
    }
    
    .crop-title {
        font-size: 16px;
    }
    
    .crop-canvas-container {
        min-height: 300px;
    }
    
    .crop-canvas {
        max-height: 300px;
    }
    
    .crop-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .crop-info {
        min-width: auto;
        order: 2;
    }
    
    .crop-actions {
        order: 1;
        justify-content: center;
    }
    
    .crop-btn {
        flex: 1;
        min-width: auto;
    }
    
    .crop-settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .crop-modal-content {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding: 10px;
    }
    
    .crop-canvas-container {
        min-height: 250px;
    }
    
    .crop-canvas {
        max-height: 250px;
    }
    
    .crop-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .crop-btn {
        width: 100%;
    }
}

/* High DPI Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .crop-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
.crop-btn:focus {
    outline: 2px solid var(--photo-uploader-primary, #007cba);
    outline-offset: 2px;
}

.crop-close:focus {
    outline: 2px solid var(--photo-uploader-primary, #007cba);
    outline-offset: 2px;
}

/* Animation for crop area changes */
.crop-canvas.updating {
    transition: opacity 0.1s ease;
}

/* Error States */
.crop-error {
    padding: 12px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
    font-size: 13px;
    margin-top: 10px;
}

.crop-error-icon {
    display: inline-block;
    margin-right: 8px;
    font-weight: bold;
}

/* Success States */
.crop-success {
    padding: 12px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    color: #155724;
    font-size: 13px;
    margin-top: 10px;
}

.crop-success-icon {
    display: inline-block;
    margin-right: 8px;
    font-weight: bold;
}

/* Crop Preview */
.crop-preview {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.crop-preview-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px 0;
}

.crop-preview-image {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #f9f9f9;
}

/* Keyboard Shortcuts Help */
.crop-shortcuts {
    margin-top: 10px;
    font-size: 11px;
    color: #888;
    text-align: center;
}

.crop-shortcuts kbd {
    background: #f1f1f1;
    border: 1px solid #ccc;
    border-radius: 2px;
    padding: 1px 4px;
    font-family: monospace;
    font-size: 10px;
}/* Crop B
ody Layout */
.crop-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Crop Canvas Container */
.crop-canvas-container {
    flex: 1;
    position: relative;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 20px;
}

.crop-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}

/* Crop Loading */
.crop-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    gap: 16px;
}

.crop-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: cropSpinner 1s linear infinite;
}

@keyframes cropSpinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.crop-loading p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

/* Crop Error */
.crop-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #dc2626;
    gap: 12px;
    padding: 20px;
}

.crop-error-icon {
    font-size: 48px;
}

.crop-error-message {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #dc2626;
}

.crop-error-note {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

/* Crop Sidebar */
.crop-sidebar {
    width: 300px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.crop-info-panel,
.crop-instructions-panel {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
}

.crop-instructions-panel {
    border-bottom: none;
    flex: 1;
}

.crop-info-title,
.crop-instructions-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 16px 0;
}

/* Crop Info Grid */
.crop-info-grid {
    display: grid;
    gap: 12px;
}

.crop-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.crop-info-label {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
}

.crop-info-value {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Crop Instructions */
.crop-instructions-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.crop-instructions-list li {
    margin: 0 0 12px 0;
    padding: 12px;
    background: #f0f9ff;
    border-radius: 6px;
    border-left: 3px solid #3b82f6;
    font-size: 14px;
    line-height: 1.5;
    color: #1e40af;
}

.crop-instructions-list li:last-child {
    margin-bottom: 0;
}

.crop-instructions-list strong {
    font-weight: 600;
    color: #1e3a8a;
}

/* Crop Footer */
.crop-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.crop-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Crop Buttons */
.crop-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    text-decoration: none;
    user-select: none;
}

.crop-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.crop-btn-icon {
    font-size: 16px;
    line-height: 1;
}

.crop-btn-secondary {
    background: #ffffff;
    color: #374151;
    border-color: #d1d5db;
}

.crop-btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.crop-btn-primary {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.crop-btn-primary:hover:not(:disabled) {
    background: #2563eb;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.crop-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Responsive Design for Crop Modal */
@media (max-width: 1024px) {
    .crop-modal-content {
        width: 95vw;
        height: 90vh;
    }
    
    .crop-sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .crop-modal-content {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }
    
    .crop-body {
        flex-direction: column;
    }
    
    .crop-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-top: 1px solid #e5e7eb;
    }
    
    .crop-canvas-container {
        border-right: none;
        min-height: 300px;
    }
    
    .crop-header {
        padding: 16px;
    }
    
    .crop-title {
        font-size: 18px;
    }
    
    .crop-info-panel,
    .crop-instructions-panel {
        padding: 16px;
    }
    
    .crop-footer {
        padding: 16px;
    }
    
    .crop-actions {
        flex-direction: column;
    }
    
    .crop-btn {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .crop-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .crop-close {
        align-self: flex-end;
        margin-top: -8px;
    }
    
    .crop-canvas-container {
        padding: 12px;
        min-height: 250px;
    }
    
    .crop-info-grid {
        grid-template-columns: 1fr;
    }
    
    .crop-info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .crop-modal-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .crop-info-item {
        border-color: #000;
    }
    
    .crop-btn-secondary {
        border-color: #000;
        color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .crop-modal,
    .crop-modal-content,
    .crop-btn,
    .crop-close {
        transition: none;
    }
    
    .crop-loading-spinner {
        animation: none;
    }
}

/* Print styles - hide modal */
@media print {
    .crop-modal {
        display: none !important;
    }
}