/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Header con logo */
header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    height: 60px;
    width: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-logo h1 {
    margin: 0;
    font-size: 1.8rem;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: 400;
    letter-spacing: 0.5px;
}

nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Bottoni */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #2ecc71;
}

.btn-primary:hover {
    background-color: #27ae60;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Galleria */
.gallery-container {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.gallery-stats {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    display: flex;
    gap: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.empty-gallery {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.05);
}

.empty-gallery h2 {
    color: #7f8c8d;
    margin-bottom: 1rem;
    font-weight: 300;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.gallery-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
}

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

.gallery-thumb {
    position: relative;
    height: 220px;
    overflow: hidden;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover .gallery-thumb img {
    transform: scale(1.05);
}

.audio-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(52, 152, 219, 0.9);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 2;
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    padding: 20px 15px 15px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1;
}

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

.gallery-info {
    padding: 20px;
}

.gallery-info h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #2c3e50;
    line-height: 1.4;
}

.truncate {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #7f8c8d;
    font-size: 0.95rem;
    line-height: 1.5;
}

.item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    font-size: 0.85rem;
}

.date {
    color: #95a5a6;
}

.has-audio {
    background: #3498db;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* Modal - Immagine intera a sinistra, testo scorrevole a destra con audio in fondo */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: white;
    border-radius: 16px;
    max-width: 1200px;
    width: 100%;
    height: 85vh;
    overflow: hidden;
    position: relative;
    animation: slideUp 0.4s ease;
}

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

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.modal-close:hover {
    background: #c0392b;
    transform: rotate(90deg);
}

.modal-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
    overflow: hidden;
}

/* Lato sinistro - Immagine */
.modal-image {
    height: 100%;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Lato destro - Layout fisso con scroll */
.modal-details {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
    overflow: hidden;
}

/* Intestazione fissa */
.modal-details h2 {
    color: #2c3e50;
    margin: 30px 30px 0 30px;
    font-size: 2rem;
    line-height: 1.3;
    padding-right: 40px;
    flex-shrink: 0;
}

/* Area testo scorrevole */
.modal-details-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    min-height: 0; /* Importante per flexbox */
}

.descrizione {
    font-size: 1.2rem;
    color: #7f8c8d;
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid #eee;
    line-height: 1.6;
}

.testo-completo {
    margin-bottom: 30px;
    line-height: 1.8;
    font-size: 1.05rem;
    color: #444;
}

/* Audio Player - Fisso in fondo */
.audio-player {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px 30px;
    border-top: 2px solid #3498db;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

audio {
    width: 100%;
    margin: 10px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

audio::-webkit-media-controls-panel {
    background-color: #f8f9fa;
}

.audio-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
}

/* Admin */
.admin-container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.admin-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.3s;
}

.admin-item:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.admin-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

.admin-item-info {
    padding: 20px;
}

.admin-item-info h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

.admin-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* Form */
.form-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.form-section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.form-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #3498db;
}

.current-files {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    border-left: 5px solid #3498db;
}

.current-files p {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

.form-group input[type="text"],
.form-group textarea,
.form-group input[type="file"] {
    width: 100%;
    padding: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-group small {
    display: block;
    margin-top: 8px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

/* Login */
.login-container {
    max-width: 420px;
    margin: 6rem auto;
    padding: 3rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 2.5rem;
    color: #2c3e50;
    font-weight: 300;
}

.login-container h1::before {
    content: '🔐 ';
}

.note {
    text-align: center;
    margin-top: 2rem;
    color: #7f8c8d;
    font-size: 0.9rem;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Messaggi */
.success {
    background: #d4edda;
    color: #155724;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid #c3e6cb;
    animation: slideIn 0.5s ease;
}

.success h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.success-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

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

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid #f5c6cb;
}

.error h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

/* Footer */
footer {
    text-align: center;
    padding: 2.5rem;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: #ecf0f1;
    margin-top: 4rem;
    font-size: 0.95rem;
    border-top: 3px solid #3498db;
}

footer p {
    margin: 8px 0;
    opacity: 0.9;
}

footer p:first-child {
    font-weight: 500;
    font-size: 1.1rem;
}

/* Utility */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* Scrollbar personalizzata */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.modal-details-content::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.modal-details-content::-webkit-scrollbar-thumb {
    background: #bdc3c7;
}

/* Responsive */
@media (max-width: 1024px) {
    .modal-content {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    
    .modal-image {
        height: 400px;
    }
    
    .modal-image img {
        object-fit: contain;
    }
    
    .modal-details {
        height: auto;
        max-height: 500px;
    }
    
    .modal-details h2 {
        margin: 20px 20px 0 20px;
    }
    
    .modal-details-content {
        padding: 15px 20px;
    }
    
    .audio-player {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
        padding: 1.5rem;
    }
    
    .header-logo {
        flex-direction: row;
        justify-content: center;
    }
    
    .logo-img {
        height: 35px;
    }
    
    .header-logo h1 {
        font-size: 1.3rem;
    }
    
    nav {
        justify-content: center;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .gallery-container {
        padding: 1.5rem;
    }
    
    .modal {
        height: 95vh;
    }
    
    .modal-details h2 {
        margin: 20px 20px 0 20px;
        font-size: 1.5rem;
    }
    
    .modal-details-content {
        padding: 15px 20px;
    }
    
    .audio-player {
        padding: 15px 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .audio-controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    
    .login-container {
        margin: 3rem 1rem;
        padding: 2rem 1.5rem;
    }
    
    .form-container {
        padding: 0 1rem;
    }
    
    .admin-grid {
        grid-template-columns: 1fr;
    }
    
    .header-logo {
        flex-direction: row;
    }
    
    .logo-img {
        height: 30px;
    }
    
    .header-logo h1 {
        font-size: 1.1rem;
    }
    
    .modal-image {
        height: 250px;
    }
    
    .modal-details {
        max-height: 400px;
    }
    
    .modal-details h2 {
        margin: 15px 15px 0 15px;
        font-size: 1.3rem;
    }
    
    .modal-details-content {
        padding: 10px 15px;
    }
    
    .audio-player {
        padding: 15px;
    }
}

/* Stampa */
@media print {
    header, footer, .modal-close, .audio-player, .btn {
        display: none !important;
    }
    
    .modal-overlay {
        position: static;
        background: white;
        padding: 0;
    }
    
    .modal {
        max-height: none;
        overflow: visible;
        height: auto;
    }
    
    .modal-content {
        grid-template-columns: 1fr;
    }
    
    .modal-image img {
        max-height: 400px;
        object-fit: contain;
    }
	/* Aggiungi questi stili alla fine del file style.css */

/* Badge per numero immagini */
.images-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(52, 152, 219, 0.9);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 2;
    font-size: 12px;
    font-weight: bold;
}

.images-badge svg {
    width: 20px;
    height: 20px;
}

.images-badge span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: bold;
}

.item-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.has-images {
    background: #e67e22;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}
/* Assicura che il carosello occupi tutto lo spazio */
.modal-image {
    position: relative;
    overflow: hidden;
}

.carousel-container {
    width: 100%;
    height: 100%;
}
/* Stile per quando non ci sono immagini */
.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    color: #95a5a6;
    font-style: italic;
}