/**
 * Gallery Master - Main Styles
 * Author: Rug Chat
 * Version: 1.0.0
 */

/* Gallery Container */
.gallery-master-container {
    margin: 20px 0;
    clear: both;
}

.gallery-master-title {
    margin: 0 0 20px 0;
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
}

/* Gallery Grid */
.gallery-master-grid {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(3, 1fr);
}

.gallery-master-grid[data-columns="1"] {
    grid-template-columns: 1fr;
}

.gallery-master-grid[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.gallery-master-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.gallery-master-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.gallery-master-grid[data-columns="5"] {
    grid-template-columns: repeat(5, 1fr);
}

.gallery-master-grid[data-columns="6"] {
    grid-template-columns: repeat(6, 1fr);
}

/* Gallery Item */
.gallery-master-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.gallery-master-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Gallery Link */
.gallery-master-link {
    display: block;
    position: relative;
    text-decoration: none;
    line-height: 0;
}

/* Gallery Image */
.gallery-master-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-master-item:hover .gallery-master-image {
    transform: scale(1.05);
}

/* Overlay */
.gallery-master-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;
}

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

/* Zoom Icon */
.gallery-master-zoom {
    font-size: 24px;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.gallery-master-zoom:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Gallery Actions */
.gallery-master-actions {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
    text-align: center;
}

.gallery-master-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    min-width: 120px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.gallery-master-download-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s;
}

.gallery-master-download-btn:hover {
    background: linear-gradient(45deg, #5a6fd8, #6a4190);
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.gallery-master-download-btn:hover:before {
    left: 100%;
}

.gallery-master-download-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.download-icon {
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.download-text {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Caption */
.gallery-master-caption {
    padding: 10px;
    background: white;
    font-size: 14px;
    color: #666;
    text-align: center;
    border-top: 1px solid #eee;
}

/* Widget Styles */
.gallery-master-widget .gallery-master-container {
    margin: 0;
}

.gallery-master-widget .gallery-master-title {
    font-size: 1.2em;
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-master-grid[data-columns="4"],
    .gallery-master-grid[data-columns="5"],
    .gallery-master-grid[data-columns="6"] {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .gallery-master-grid {
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .gallery-master-grid[data-columns="3"],
    .gallery-master-grid[data-columns="4"],
    .gallery-master-grid[data-columns="5"],
    .gallery-master-grid[data-columns="6"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .gallery-master-zoom {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* Loading Animation */
.gallery-master-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.gallery-master-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: gallery-master-spin 1s linear infinite;
}

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

/* Admin Styles */
.gallery-master-select-images {
    margin-top: 10px;
}

.gallery-master-setting-header {
    margin: 15px 0 10px 0;
    font-size: 16px;
    font-weight: 600;
}

.setting-gallery-master,
.setting-gallery-title,
.setting-show-captions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
}

.setting-gallery-master span,
.setting-gallery-title span,
.setting-show-captions span {
    font-weight: 500;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .gallery-master-title {
        color: #e0e0e0;
    }
    
    .gallery-master-item {
        background: #2c3338;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .gallery-master-caption {
        background: #2c3338;
        color: #e0e0e0;
        border-top-color: #444;
    }
    
    .gallery-master-actions {
        background: #2c3338;
        border-top-color: #444;
    }
    
    .gallery-master-download-btn {
        background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
        box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    }
    
    .gallery-master-download-btn:hover {
        background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
        box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
    }
}

/* Magnific Popup Custom Styles */
.gallery-master-popup .mfp-content {
    position: relative;
}

.gallery-master-popup .mfp-figure {
    position: relative;
}

.gallery-master-popup .mfp-bottom-bar {
    margin-top: -36px;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    cursor: auto;
}

.gallery-master-popup .mfp-title {
    text-align: left;
    line-height: 18px;
    color: #F3F3F3;
    word-wrap: break-word;
    padding-right: 36px;
}

/* Custom Download Button in Popup */
.mfp-popup-download {
    position: absolute;
    top: 15px;
    right: 60px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 1001;
    font-size: 18px;
    backdrop-filter: blur(5px);
}

.mfp-popup-download:hover {
    background: rgba(76, 175, 80, 0.8);
    color: white;
    text-decoration: none;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.mfp-popup-download:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}

/* Ensure arrows are visible and styled */
.gallery-master-popup .mfp-arrow {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Navigation Arrow Styles */
.gallery-master-popup .mfp-arrow {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    margin-top: -25px;
}

.gallery-master-popup .mfp-arrow:after {
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    margin-top: -8px;
}

.gallery-master-popup .mfp-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.gallery-master-popup .mfp-arrow-left {
    margin-left: 10px;
}

.gallery-master-popup .mfp-arrow-left:after {
    border-right: 15px solid #fff;
    margin-left: 12px;
}

.gallery-master-popup .mfp-arrow-right {
    margin-right: 10px;
}

.gallery-master-popup .mfp-arrow-right:after {
    border-left: 15px solid #fff;
    margin-left: 20px;
}

/* Mobile Touch Indicators */
@media (max-width: 768px) {
    .gallery-master-popup:after {
        content: "👆 Deslize para navegar";
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 12px;
        z-index: 1052;
        pointer-events: none;
        animation: fadeInOut 4s ease-in-out;
    }
    
    .gallery-master-popup .mfp-arrow {
        width: 60px;
        height: 60px;
        margin-top: -30px;
    }
    
    .gallery-master-popup .mfp-arrow:after {
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        margin-top: -10px;
    }
    
    .gallery-master-popup .mfp-arrow-left:after {
        border-right: 18px solid #fff;
        margin-left: 15px;
    }
    
    .gallery-master-popup .mfp-arrow-right:after {
        border-left: 18px solid #fff;
        margin-left: 24px;
    }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    25%, 75% { opacity: 1; }
}

/* Print Styles */
@media print {
    .gallery-master-overlay {
        display: none !important;
    }
    
    .gallery-master-item {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .gallery-master-item:hover {
        transform: none;
    }
}