/**
 * Comprehensive Gallery Upload System - Enhanced Styles
 * Includes: Responsive design, error handling, animations, and performance optimizations
 */

/* ==========================================================================
   Gallery Upload Interface
   ========================================================================== */

.dropzone {
    border: 3px dashed #dee2e6;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: #f8f9fa;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropzone:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    transform: translateY(-2px);
}

.dropzone.drag-over {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.dropzone-content {
    pointer-events: none;
    max-width: 400px;
    width: 100%;
}

.dropzone-icon {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.dropzone:hover .dropzone-icon {
    color: #667eea;
    transform: scale(1.1);
}

.dropzone h3 {
    color: #495057;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.dropzone p {
    color: #6c757d;
    margin-bottom: 1rem;
}

.btn-link {
    background: none;
    border: none;
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}

.btn-link:hover {
    color: #764ba2;
}

.upload-info {
    margin-top: 1rem;
}

.upload-info p {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

/* ==========================================================================
   Image Processing Area
   ========================================================================== */

.processing-area {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.processing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.processing-header h3 {
    color: #2c3e50;
    margin: 0;
}

.batch-controls {
    display: flex;
    gap: 1rem;
}

.image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.image-preview-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.image-preview-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.image-preview-item.cropped {
    border-color: #28a745;
}

.image-preview-item.cropped::after {
    content: '✓ Cropped';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.preview-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    gap: 1rem;
}

.preview-image:hover .image-overlay {
    opacity: 1;
}

.preview-info {
    padding: 1rem;
}

.file-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.file-details {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.file-size,
.file-dimensions {
    font-size: 0.9rem;
    color: #6c757d;
}

.aspect-ratio {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.aspect-landscape {
    background: #17a2b8;
}

.aspect-portrait {
    background: #fd7e14;
}

.aspect-square {
    background: #28a745;
}

.processing-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.processing-options input,
.processing-options textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9rem;
}

.processing-options input:focus,
.processing-options textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.quality-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.quality-slider {
    flex: 1;
}

.quality-value {
    font-weight: 600;
    color: #667eea;
}

/* ==========================================================================
   Crop Modal
   ========================================================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.crop-modal .modal-content {
    background: white;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: #495057;
}

.modal-body {
    padding: 1.5rem;
}

.crop-controls {
    margin-bottom: 1.5rem;
}

.aspect-ratio-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.aspect-btn {
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.aspect-btn:hover {
    background: #e9ecef;
}

.aspect-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.crop-info {
    font-size: 0.9rem;
    color: #6c757d;
}

.crop-container {
    max-height: 400px;
    overflow: hidden;
    border-radius: 8px;
}

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #e9ecef;
}

/* ==========================================================================
   Progress Indicators
   ========================================================================== */

.batch-progress {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.progress-stats {
    font-size: 1.1rem;
    color: #667eea;
    font-weight: 600;
}

.progress-bar-container {
    background: #e9ecef;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.progress-bar {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 35%, rgba(255, 255, 255, 0.2) 35%, rgba(255, 255, 255, 0.2) 65%, transparent 65%);
    background-size: 20px 20px;
    animation: progressStripes 1s linear infinite;
}

@keyframes progressStripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 0; }
}

.progress-details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #dee2e6;
}

.progress-item.status-completed {
    border-left-color: #28a745;
}

.progress-item.status-processing {
    border-left-color: #ffc107;
}

.progress-item.status-failed {
    border-left-color: #dc3545;
}

.progress-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}

.progress-title {
    flex: 1;
    font-weight: 500;
}

.progress-status {
    font-size: 0.9rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.progress-item.status-completed .progress-status {
    background: #d4edda;
    color: #155724;
}

.progress-item.status-processing .progress-status {
    background: #fff3cd;
    color: #856404;
}

.progress-item.status-failed .progress-status {
    background: #f8d7da;
    color: #721c24;
}

/* ==========================================================================
   Upload Results
   ========================================================================== */

.upload-results {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.results-summary {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.result-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
}

.result-stat.success {
    background: #d4edda;
    color: #155724;
}

.result-stat.error {
    background: #f8d7da;
    color: #721c24;
}

.result-stat i {
    font-size: 1.2rem;
}

.results-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.result-item {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.result-item.completed {
    border-color: #28a745;
}

.result-item.failed {
    border-color: #dc3545;
}

.result-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.result-info {
    padding: 1rem;
}

.result-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.result-status {
    font-size: 0.9rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.result-item.completed .result-status {
    background: #d4edda;
    color: #155724;
}

.result-item.failed .result-status {
    background: #f8d7da;
    color: #721c24;
}

/* ==========================================================================
   Error Handling
   ========================================================================== */

.upload-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: none;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.error-content i {
    color: #721c24;
    font-size: 1.2rem;
}

.error-content span {
    color: #721c24;
    font-weight: 500;
    flex: 1;
}

.error-close {
    background: none;
    border: none;
    color: #721c24;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.error-close:hover {
    color: #491217;
}

/* Connection Error States */
.connection-error {
    text-align: center;
    padding: 3rem 2rem;
    color: #6c757d;
}

.connection-error i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #dc3545;
}

.retry-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 1rem;
}

.retry-button:hover {
    background: #5a6fd8;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet Styles */
@media (max-width: 992px) {
    .processing-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .batch-controls {
        width: 100%;
        justify-content: flex-end;
    }

    .image-previews {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }

    .crop-modal .modal-content {
        width: 95vw;
    }

    .results-summary {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .dropzone {
        padding: 2rem 1rem;
        min-height: 150px;
    }

    .dropzone-icon {
        font-size: 2.5rem;
    }

    .dropzone h3 {
        font-size: 1.2rem;
    }

    .processing-area {
        padding: 1rem;
    }

    .image-previews {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .preview-image {
        height: 180px;
    }

    .file-details {
        flex-direction: column;
        gap: 0.5rem;
    }

    .aspect-ratio-buttons {
        grid-template-columns: 1fr 1fr;
        display: grid;
        gap: 0.5rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .crop-container {
        max-height: 300px;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .progress-details {
        grid-template-columns: 1fr;
    }

    .results-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .batch-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    .dropzone {
        padding: 1.5rem 0.5rem;
    }

    .upload-info p {
        font-size: 0.8rem;
    }

    .processing-area,
    .batch-progress,
    .upload-results {
        padding: 1rem 0.5rem;
    }

    .preview-image {
        height: 150px;
    }

    .crop-modal .modal-content {
        margin: 1rem;
        width: calc(100vw - 2rem);
        max-height: calc(100vh - 2rem);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .aspect-ratio-buttons {
        grid-template-columns: 1fr;
    }

    .crop-container {
        max-height: 250px;
    }
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .dropzone,
    .image-preview-item,
    .progress-bar,
    .gallery-image {
        transition: none;
    }

    .progress-bar::after {
        animation: none;
    }

    .gallery-image.loaded {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dropzone {
        border-width: 2px;
        border-color: currentColor;
    }

    .image-preview-item {
        border-width: 2px;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Print styles */
@media print {
    .dropzone,
    .processing-area,
    .batch-progress,
    .modal,
    .upload-results .results-header {
        display: none;
    }

    .results-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* ==========================================================================
   Accessibility Enhancements
   ========================================================================== */

/* Focus styles */
.dropzone:focus-within,
input:focus,
textarea:focus,
button:focus,
.btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast borders for better visibility */
.image-preview-item,
.modal-content,
.progress-item {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Ensure sufficient color contrast */
.text-muted {
    color: #5a6c7d !important;
}

/* Better button states */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
}
