/* Galleria Foto Styles */

/* Variabili CSS */
:root {
    --primary-color: #00bf8f;
    --secondary-color: #001510;
    --accent-color: #FF4B4B;
    --light-bg: #f8f9fa;
    --text-color: #2d3436;
    --transition: all 0.3s ease;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* Main container */
.galleria-main {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--light-bg) 0%, #ffffff 100%);
}

/* Hero Section */
.galleria-hero {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: white;
    padding: 4rem 2rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.galleria-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
}

.hero-content h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-content p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin: 0;
}

/* Selezione Consiglio */
.consiglio-selector {
    padding: 4rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.selector-container h2 {
    text-align: center;
    font-size: 2.5rem;
    color: var(--secondary-color);
    margin-bottom: 3rem;
    font-weight: 600;
}

.consiglio-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.consiglio-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.consiglio-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.consiglio-card:hover .card-image img {
    transform: scale(1.05);
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.consiglio-card:hover .card-overlay {
    opacity: 1;
}

.card-overlay i {
    font-size: 4rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.evento-terminato {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background: rgba(255, 75, 75, 0.9);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.card-content {
    padding: 1.5rem;
}

.card-content h3 {
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.card-content p {
    color: #666;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.photo-count {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Slideshow Section */
.slideshow-section {
    background: #000;
    min-height: 100vh;
    position: relative;
}

.slideshow-header {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.slideshow-info h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.slideshow-info p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

.slideshow-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.7rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.action-btn.close-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* Loading indicator */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 10;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Main slideshow */
.slideshow-container {
    position: relative;
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
}

.main-slideshow {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-counter {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.navigation-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 10;
    pointer-events: none;
}

.nav-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    pointer-events: all;
    backdrop-filter: blur(10px);
}

.nav-btn:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

.slides-container {
    width: 100%;
    height: 100%;
    display: flex;
    transition: transform 0.5s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.slide {
    flex: 0 0 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
    box-sizing: border-box;
}

.slide img {
    max-width: calc(100% - 4rem);
    max-height: calc(100% - 4rem);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: block;
}

/* Thumbnail strip */
.thumbnail-strip {
    background: rgba(0, 0, 0, 0.9);
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.thumbnail-strip::-webkit-scrollbar {
    height: 6px;
}

.thumbnail-strip::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.thumbnail-strip::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.thumbnail-container {
    display: flex;
    gap: 0.5rem;
    min-width: max-content;
}

.thumbnail {
    width: 80px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    opacity: 0.7;
}

.thumbnail:hover,
.thumbnail.active {
    opacity: 1;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 2rem;
    }

    .hero-content p {
        font-size: 1rem;
    }

    .consiglio-cards {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .consiglio-card {
        max-width: 500px;
        margin: 0 auto;
    }

    .slideshow-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .slideshow-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .action-btn span {
        display: none;
    }

    .navigation-controls {
        padding: 0 1rem;
    }

    .nav-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .thumbnail {
        width: 60px;
        height: 45px;
    }

    .slide {
        padding: 1rem;
    }

    .slide img {
        max-width: calc(100% - 2rem);
        max-height: calc(100% - 2rem);
    }
}

@media (max-width: 480px) {
    .galleria-hero {
        padding: 2rem 1rem 1rem;
    }

    .consiglio-selector {
        padding: 2rem 1rem;
    }

    .selector-container h2 {
        font-size: 2rem;
    }

    .card-image {
        height: 200px;
    }

    .slideshow-header {
        padding: 0.5rem 1rem;
    }

    .slideshow-info h2 {
        font-size: 1.2rem;
    }

    .action-btn {
        padding: 0.5rem;
        min-width: 44px;
    }
}

/* Animazioni e transizioni aggiuntive */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.consiglio-card {
    animation: fadeIn 0.6s ease-out;
}

.consiglio-card:nth-child(1) {
    animation-delay: 0.1s;
}

.consiglio-card:nth-child(2) {
    animation-delay: 0.2s;
}

.slideshow-section {
    animation: fadeIn 0.5s ease-out;
}

.thumbnail {
    transition: all 0.3s ease;
}

.thumbnail:hover {
    box-shadow: 0 4px 12px rgba(0, 191, 143, 0.3);
}

/* Stili per il preloader delle immagini */
.slide img {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Miglioramenti per l'accessibilità */
.action-btn:focus,
.nav-btn:focus,
.thumbnail:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Stili per il drag and drop (futuro sviluppo) */
.drag-over {
    border: 2px dashed var(--primary-color);
    background: rgba(0, 191, 143, 0.1);
}

/* Indicatore di caricamento migliorato */
.loading-indicator p {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Stili per la modalità fullscreen */
.slideshow-section:-webkit-full-screen {
    background: #000;
}

.slideshow-section:-moz-full-screen {
    background: #000;
}

.slideshow-section:fullscreen {
    background: #000;
}

/* Stili per fullscreen mobile alternativo */
.slideshow-section.mobile-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: calc(var(--vw, 1vw) * 100) !important;
    height: 100vh !important;
    height: calc(var(--vh, 1vh) * 100) !important;
    z-index: 9999 !important;
    background: #000 !important;
    overflow: hidden !important;
}

.mobile-fullscreen-active {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

.mobile-fullscreen-active body {
    overflow: hidden !important;
}

.mobile-fullscreen .slideshow-container {
    width: 100vw !important;
    width: calc(var(--vw, 1vw) * 100) !important;
    height: 100vh !important;
    height: calc(var(--vh, 1vh) * 100) !important;
}

.mobile-fullscreen .slideshow-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    width: calc(var(--vw, 1vw) * 100) !important;
    z-index: 10000 !important;
    background: rgba(0, 0, 0, 0.9) !important;
}

.mobile-fullscreen .main-slideshow {
    width: 100vw !important;
    width: calc(var(--vw, 1vw) * 100) !important;
    height: calc(100vh - 80px) !important;
    height: calc(calc(var(--vh, 1vh) * 100) - 80px) !important;
}

.mobile-fullscreen .thumbnail-strip {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    width: calc(var(--vw, 1vw) * 100) !important;
    z-index: 10000 !important;
}

/* Stili specifici per iOS fullscreen */
.slideshow-section.ios-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    width: calc(var(--vw, 1vw) * 100) !important;
    height: 100vh !important;
    height: calc(var(--vh, 1vh) * 100) !important;
    z-index: 9999 !important;
    background: #000 !important;
    overflow: hidden !important;
    -webkit-overflow-scrolling: touch;
}

.ios-fullscreen-active {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    -webkit-overflow-scrolling: touch;
}

.ios-fullscreen-active body {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-overflow-scrolling: touch;
}

.ios-fullscreen .slideshow-container {
    width: 100vw !important;
    width: calc(var(--vw, 1vw) * 100) !important;
    height: 100vh !important;
    height: calc(var(--vh, 1vh) * 100) !important;
    position: relative !important;
    overflow: hidden !important;
}

.ios-fullscreen .slideshow-header {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 10000 !important;
    background: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

.ios-fullscreen .main-slideshow {
    width: 100% !important;
    height: calc(100vh - 80px) !important;
    height: calc(calc(var(--vh, 1vh) * 100) - 80px) !important;
    position: absolute !important;
    top: 80px !important;
    left: 0 !important;
    overflow: hidden !important;
}

.ios-fullscreen .thumbnail-strip {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 10000 !important;
    background: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

/* Miglioramenti per il touch su iOS */
.ios-fullscreen .slide img {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x pan-y;
    max-width: 95% !important;
    max-height: 95% !important;
}

.ios-fullscreen .slides-container {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}

/* Nasconde la barra di stato su iOS quando possibile */
@supports (-webkit-touch-callout: none) {
    .ios-fullscreen {
        /* Stili specifici per iOS Safari */
        -webkit-appearance: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    .ios-fullscreen-active {
        /* Forza l'altezza completa su iOS */
        height: 100vh !important;
        height: calc(var(--vh, 1vh) * 100) !important;
        min-height: -webkit-fill-available !important;
    }
}

/* Stili per fullscreen fallback */
.slideshow-section.fallback-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: #000 !important;
    overflow: hidden !important;
}

.fallback-fullscreen-active {
    margin: 0 !important;
    padding: 0 !important;
    background: black !important;
    overflow: hidden !important;
}

/* Overlay messaggio iOS fullscreen */
#ios-fullscreen-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(10px);
}

.ios-message-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: left;
    max-width: 350px;
    margin: 1rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.ios-message-text h3 {
    margin: 0 0 1rem 0;
    color: var(--secondary-color);
    font-size: 1.3rem;
    text-align: center;
}

.ios-message-text p {
    margin: 0 0 1rem 0;
    color: #666;
    line-height: 1.5;
    text-align: center;
    font-weight: 600;
}

.ios-message-text ul {
    margin: 0 0 1.5rem 0;
    padding-left: 0;
    list-style: none;
}

.ios-message-text li {
    margin: 0.8rem 0;
    color: #444;
    line-height: 1.4;
    font-size: 0.95rem;
}

#ios-message-close {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    width: 100%;
    font-size: 1rem;
}

#ios-message-close:hover {
    background: #00a67d;
    transform: translateY(-2px);
}

/* Overlay messaggio rotazione */
#rotate-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.rotate-message-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 300px;
    margin: 1rem;
}

.rotate-message-text h3 {
    margin: 0 0 1rem 0;
    color: var(--secondary-color);
    font-size: 1.2rem;
}

.rotate-message-text p {
    margin: 0 0 1.5rem 0;
    color: #666;
    line-height: 1.5;
}

#rotate-message-close {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

#rotate-message-close:hover {
    background: #00a67d;
    transform: translateY(-2px);
}

/* Forza orientamento landscape su mobile fullscreen (non iOS) */
@media screen and (orientation: portrait) and (max-width: 768px) {
    .mobile-fullscreen:not(.ios-fullscreen) {
        transform: rotate(90deg) !important;
        transform-origin: center center !important;
        width: 100vh !important;
        height: 100vw !important;
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        margin-top: -50vw !important;
        margin-left: -50vh !important;
    }
}

/* Miglioramenti per la performance */
.slides-container {
    will-change: transform;
}

.thumbnail-container {
    will-change: scroll-position;
}

/* Stili per dispositivi con hover limitato (touch) */
@media (hover: none) {
    .consiglio-card:hover {
        transform: none;
    }

    .card-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.2);
    }

    .thumbnail:hover {
        transform: none;
        box-shadow: none;
    }
}
