/**
 * Elementor Image Gallery Widget Styles
 * Modern, responsive design with smooth animations
 */

/* ==========================================================================
   Base Widget Styles
   ========================================================================== */

.elementor-image-gallery-widget {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.elementor-image-gallery-widget * {
    box-sizing: border-box;
}

/* Gallery Title */
.gallery-title {
    margin: 0 0 2rem 0;
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50 !important;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Enhanced title visibility for light backgrounds */
.gallery-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    ttransform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #4a90e2 0%, #50e3c2 100%);
    border-radius: 2px;
}

/* Ensure title underline is centered in Elementor editor */
.elementor-editor-active .gallery-title {
    text-align: center !important;
}

.elementor-editor-active .gallery-title::after {
    left: 50% !important;
    ttransform: translateX(-50%) !important;
}

/* ==========================================================================
   Upload Toggle Button
   ========================================================================== */

.upload-toggle-container {
    text-align: left;
    margin-bottom: 1rem;
}

.upload-toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #4a90e2;
    color: #ffffff;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    outline: none;
}

.upload-toggle-button:hover {
    background: #357abd;
    border-color: #357abd;
    ttransform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.upload-toggle-button:active {
    transform: translateY(0);
}

.upload-toggle-button svg {
    flex-shrink: 0;
}

/* ==========================================================================
   Upload Area Styles
   ========================================================================== */

/* Upload Area */
.upload-area {
    background: transparent; /* Remove background to let images show through */
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    overflow: hidden;
}

.upload-area:hover {
    border-color: #4a90e2;
    background: rgba(74, 144, 226, 0.05); /* Very light hover background */
}

.upload-area.drag-over {
    border-color: #4a90e2;
    background: rgba(74, 144, 226, 0.1);
    transform: scale(1.02);
}

/* Upload Icon */
.upload-icon {
    margin-bottom: 1.5rem;
    color: #6c757d;
    transition: all 0.3s ease;
}

.upload-area:hover .upload-icon {
    color: #4a90e2;
    transform: scale(1.1);
}

.upload-area.drag-over .upload-icon {
    color: #50e3c2;
    transform: scale(1.2) rotate(5deg);
}

/* Elementor editor fixes */
.elementor-editor-active .upload-area {
    background: #fafbfc !important;
}

/* Fix for Elementor editor overlay issue */
.elementor-editor-active .elementor-image-gallery-widget {
    position: relative;
    z-index: 1;
}

.elementor-editor-active .elementor-image-gallery-widget::before {
    display: none !important;
}

/* Ensure custom background colors work in both editor and frontend */
.elementor-image-gallery-widget .upload-area[style*="background"] {
    background-image: none !important;
}

/* Editor preview - always show upload area */
.elementor-editor-active .upload-area.elementor-editor-preview {
    display: block !important;
}

/* Title styling with underline */
.gallery-title {
    position: relative;
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
    text-align: center;
}

.gallery-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(135deg, #4a90e2 0%, #50e3c2 100%);
    border-radius: 2px;
}

/* Upload button styling */
.upload-button {
    background: #4a90e2;
    color: #ffffff;
    border: 2px solid #4a90e2;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.upload-button:hover {
    background: #357abd;
    border-color: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

/* Toggle button styling */
.upload-toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #4a90e2;
    color: #ffffff;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.upload-toggle-button:hover {
    background: #357abd;
    border-color: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.upload-toggle-button svg {
    transition: transform 0.3s ease;
}

.upload-toggle-button.active svg {
    transform: rotate(180deg);
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1) 0%, rgba(80, 227, 194, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.upload-area:hover {
    border-color: #4a90e2;
    background: linear-gradient(135deg, #ffffff 0%, #f1f3f4 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.15);
}

.upload-area:hover::before {
    opacity: 1;
}

.upload-area.drag-over {
    border-color: #50e3c2;
    background: linear-gradient(135deg, #ffffff 0%, #f0fffe 100%);
    transform: scale(1.02);
    box-shadow: 0 12px 35px rgba(80, 227, 194, 0.25);
}

.upload-area.drag-over::before {
    opacity: 1;
    background: linear-gradient(135deg, rgba(80, 227, 194, 0.2) 0%, rgba(74, 144, 226, 0.2) 100%);
}

.upload-content {
    position: relative;
    z-index: 2;
}

.upload-icon {
    margin-bottom: 1.5rem;
    color: #6c757d;
    transition: all 0.3s ease;
}

.upload-area:hover .upload-icon {
    color: #4a90e2;
    transform: scale(1.1);
}

.upload-area.drag-over .upload-icon {
    color: #50e3c2;
    transform: scale(1.2) rotate(5deg);
}

.upload-text {
    margin: 0 0 1.5rem 0;
    font-size: 1.1rem;
    color: #495057;
    font-weight: 500;
    line-height: 1.5;
}

.upload-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.upload-button:hover {
    background: linear-gradient(135deg, #357abd 0%, #2968a3 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.upload-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(74, 144, 226, 0.3);
}

/* Upload Progress */
.upload-progress {
    margin-top: 1.5rem;
    padding: 0 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2 0%, #50e3c2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 600;
    text-align: center;
}

/* ==========================================================================
   Gallery Grid Styles
   ========================================================================== */

.image-gallery-grid {
    width: 100%;
}

/* Grid Layout (default) */
.image-gallery-grid[data-layout="grid"], 
.image-gallery-grid:not([data-layout="masonry"]) {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Masonry Layout */
.image-gallery-grid[data-layout="masonry"] {
    display: block !important;
    grid-template-columns: none !important;
    column-count: 3;
    column-gap: 1rem;
    column-fill: balance;
    gap: 0 !important;
}

.image-gallery-grid[data-layout="masonry"] .gallery-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 1rem;
    break-inside: avoid;
    page-break-inside: avoid;
}

.image-gallery-grid[data-layout="masonry"] .gallery-item img {
    height: auto;
    object-fit: cover;
}

/* Gallery Item */
.gallery-item-overlay {display:none;}
.gallery-item-inner {margin: 0 !important;}
.gallery-item {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

.gallery-item.loaded {
    opacity: 1;
    ttransform: translateY(0) scale(1);
}

.gallery-item:hover {
    ttransform: translateY(-5px) scale(1.02);
    bbox-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

/* Image Wrapper */
.image-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    ttransition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

/* Aspect Ratios */
.aspect-square .image-wrapper {
    aspect-ratio: 1 / 1;
}

.aspect-landscape .image-wrapper {
    aspect-ratio: 4 / 3;
}

.aspect-portrait .image-wrapper {
    aspect-ratio: 3 / 4;
}

.aspect-original .image-wrapper {
    aspect-ratio: auto;
}

/* Hover Effects */
.hover-zoom:hover img {
    ttransform: scale(1.1);
}

.hover-fade:hover img {
    opacity: 0.8;
}

/* Image Overlay */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item:hover .image-overlay {
    opacity: 1;
}

.overlay-actions {
    display: flex;
    gap: 0.75rem;
    transform: translateY(10px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-item:hover .overlay-actions {
    transform: translateY(0);
}

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    color: #333;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.action-button:hover {
    background: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.action-button.delete-image:hover {
    background: #dc3545;
    color: white;
}

/* ==========================================================================
   Messages
   ========================================================================== */

.upload-message {
    position: relative;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideInDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-message p {
    margin: 0;
    font-weight: 500;
}

.upload-message-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.upload-message-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.upload-message-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border: 1px solid #ffeaa7;
}

.upload-message-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-close:hover {
    opacity: 1;
}

/* ==========================================================================
   Loading and Empty States
   ========================================================================== */

.gallery-loading,
.no-images,
.gallery-placeholder,
.error-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
    font-size: 1.1rem;
}

.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.gallery-loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #e9ecef;
    border-top: 3px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   Lightbox
   ========================================================================== */

.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    line-height: 1;
    padding: 0;
    color: #333;
    font-weight: bold;
    z-index: 10000;
}

.lightbox-close:hover {
    background: #ffffff;
    transform: scale(1.1);
}

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

/* Tablet */
@media (max-width: 1024px) {
    .image-gallery-grid[data-layout="grid"], 
    .image-gallery-grid:not([data-layout="masonry"]) {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .image-gallery-grid[data-layout="masonry"] {
        column-count: 2;
    }
    
    .upload-area {
        padding: 2.5rem 1.5rem;
    }
    
    .gallery-title {
        font-size: 1.75rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .image-gallery-grid[data-layout="grid"], 
    .image-gallery-grid:not([data-layout="masonry"]) {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .image-gallery-grid[data-layout="masonry"] {
        column-count: 1;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .upload-text {
        font-size: 1rem;
    }
    
    .upload-button {
        padding: 0.625rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .gallery-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .overlay-actions {
        gap: 0.5rem;
    }
    
    .action-button {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-content {
        padding: 1rem;
    }
    
    .lightbox-close {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .upload-area {
        padding: 1.5rem 0.75rem;
    }
    
    .upload-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .upload-text {
        font-size: 0.9rem;
    }
    
    .upload-button {
        padding: 0.5rem 1.25rem;
        font-size: 0.85rem;
    }
    
    .gallery-title {
        font-size: 1.25rem;
    }
    
    .image-gallery-grid {
        gap: 0.75rem;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .elementor-image-gallery-widget {
        color: #e9ecef;
    }
    
    .gallery-title {
        color: #f8f9fa;
    }
    
    .upload-area {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        border-color: #495057;
    }
    
    .upload-area:hover {
        background: linear-gradient(135deg, #34495e 0%, #3c4f66 100%);
        border-color: #4a90e2;
    }
    
    .upload-text {
        color: #ced4da;
    }
    
    .gallery-item {
        background: #FFFFFF;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }
    
    .gallery-loading,
    .no-images,
    .gallery-placeholder,
    .error-loading {
        color: #adb5bd;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .upload-area,
    .image-overlay,
    .upload-message {
        display: none !important;
    }
    
    .image-gallery-grid {
        display: block;
    }
    
    .gallery-item {
        display: inline-block;
        width: 48%;
        margin: 1% 1% 1% 0;
        page-break-inside: avoid;
    }
}

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

/* Focus styles */
.upload-button:focus,
.action-button:focus,
.message-close:focus,
.lightbox-close:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .upload-area {
        border-width: 3px;
    }
    
    .upload-button {
        border: 2px solid transparent;
    }
    
    .upload-button:focus {
        border-color: currentColor;
    }
}

