/**
 * ACF PDF Gallery con Watermark - Frontend Styles
 */

/* Wrapper principale */
.apgw-wrapper {
    position: relative;
    width: 100%;
}

/* Loading state */
.apgw-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
}

.apgw-loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: apgw-spin 1s linear infinite;
}

@keyframes apgw-spin {
    to {
        transform: rotate(360deg);
    }
}

.apgw-loading-text {
    margin-top: 15px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

/* Error state */
.apgw-error {
    padding: 40px 20px;
    text-align: center;
    background-color: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    color: #c53030;
}

.apgw-error p {
    margin: 0;
    font-size: 14px;
}

/* Gallery grid */
.apgw-gallery {
    display: grid;
    grid-template-columns: repeat(var(--apgw-columns, 3), 1fr);
    gap: 15px;
    width: 100%;
}

/* Responsive columns - usa variabili CSS dal widget */
@media (max-width: 1024px) {
    .apgw-gallery {
        grid-template-columns: repeat(var(--apgw-columns-tablet, 2), 1fr);
    }
}

@media (max-width: 767px) {
    .apgw-gallery {
        grid-template-columns: repeat(var(--apgw-columns-mobile, 1), 1fr);
    }
}

/* Gallery item */
.apgw-gallery-item {
    position: relative;
    overflow: hidden;
    background-color: #f5f5f5;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.apgw-gallery-link {
    display: block;
    width: 100%;
    height: 100%;
    line-height: 0;
    text-decoration: none;
}

.apgw-gallery-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

/* Hover effects */
.apgw-hover-zoom .apgw-gallery-item:hover .apgw-gallery-image {
    transform: scale(1.05);
}

.apgw-hover-brightness .apgw-gallery-item:hover .apgw-gallery-image {
    filter: brightness(1.15);
}

.apgw-hover-grayscale .apgw-gallery-item .apgw-gallery-image {
    filter: grayscale(100%);
    transition: filter 0.3s ease;
}

.apgw-hover-grayscale .apgw-gallery-item:hover .apgw-gallery-image {
    filter: grayscale(0%);
}

/* Page number badge */
.apgw-page-number {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    line-height: 1.2;
    pointer-events: none;
    z-index: 2;
}

/* Notice per editor */
.apgw-notice {
    padding: 20px;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    text-align: center;
}

/* GLightbox customizations */
.glightbox-container .gslide-image img {
    max-width: 95vw;
    max-height: 95vh;
}

.glightbox-container .gslide-title {
    font-size: 16px;
    font-weight: 600;
}

/* Overlay su hover per indicare cliccabilità */
.apgw-gallery-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0);
    transition: background-color 0.3s ease;
    pointer-events: none;
}

.apgw-gallery-item:hover::after {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Icona zoom su hover */
.apgw-gallery-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    z-index: 3;
    opacity: 0;
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3Cline x1='11' y1='8' x2='11' y2='14'%3E%3C/line%3E%3Cline x1='8' y1='11' x2='14' y2='11'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
}

.apgw-gallery-item:hover .apgw-gallery-link::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Skeleton loading per immagini */
.apgw-gallery-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: apgw-skeleton 1.5s infinite;
}

@keyframes apgw-skeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Aspect ratio container per prevenire layout shift */
.apgw-gallery-item {
    aspect-ratio: 210 / 297; /* A4 ratio come default */
}

/* Print styles */
@media print {
    .apgw-gallery {
        display: block;
    }
    
    .apgw-gallery-item {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .apgw-page-number {
        background-color: #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .apgw-gallery-item {
        border: 2px solid #000;
    }
    
    .apgw-page-number {
        background-color: #000;
        color: #fff;
    }
}

/* Tabs per multiplo */
.apgw-tabs-container {
    width: 100%;
}

.apgw-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
}

.apgw-tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.apgw-tab-btn:hover {
    color: #334155;
    background-color: #f8fafc;
}

.apgw-tab-btn.apgw-tab-active {
    color: #5b8a9a;
    border-bottom-color: #5b8a9a;
    font-weight: 600;
}

.apgw-tab-panel {
    display: none;
}

.apgw-tab-panel-active {
    display: block;
}

@media (max-width: 767px) {
    .apgw-tabs-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .apgw-tab-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .apgw-loader {
        animation: none;
    }
    
    .apgw-gallery-image,
    .apgw-gallery-item::after,
    .apgw-gallery-link::before {
        transition: none;
    }
}
