/* ==========================================================================
   STILI GENERALI E VARIABILI DI TEMA
   ========================================================================== */
:root {
    --primary-color: #5b6b7c;
    --accent-color: #8a9ea7;
    --bg-color: #fcfbf9;
    --card-bg: #ffffff;
    --text-color: #333333;
    --font-serif: 'Lora', serif;
    --font-sans: 'Montserrat', sans-serif;
    --font-hand: 'Alex Brush', cursive;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    line-height: 1.6;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

/* ==========================================================================
   HEADER E NAVIGAZIONE
   ========================================================================== */
.site-header {
    text-align: center;
    padding: 40px 20px 20px;
    background: #ffffff;
    border-bottom: 1px solid #eae2d8;
}

.site-title {
    font-family: var(--font-hand);
    font-size: 3.5rem;
    margin: 0;
    font-weight: normal;
}

.site-title a {
    color: var(--primary-color);
    text-decoration: none;
}

.site-subtitle {
    font-family: var(--font-serif);
    font-style: italic;
    color: #777777;
    margin-top: 5px;
}

.main-nav {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.main-nav a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 20px;
    transition: background 0.3s;
}

.main-nav a:hover {
    background-color: #f0ebe5;
}

.user-welcome {
    font-size: 0.9rem;
    color: #666666;
    font-weight: 500;
}

.btn-auth {
    border: 1px solid var(--accent-color);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
    text-align: center;
    padding: 30px;
    font-size: 0.9rem;
    color: #888888;
    border-top: 1px solid #eae2d8;
    margin-top: 50px;
}

/* ==========================================================================
   HOME PAGE / SEZIONE DEDICA
   ========================================================================== */
.dedica-section {
    max-width: 800px;
    margin: 20px auto;
}

.card-dedica {
    background: #ffffff;
    padding: 40px;
    border-radius: 8px;
    border: 1px solid #eae2d8;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    text-align: center;
}

.card-dedica h2 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-top: 0;
    margin-bottom: 25px;
}

.poesia-body .verso {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-style: italic;
    color: #444444;
    line-height: 1.8;
}

/* ==========================================================================
   PAGINA GUESTBOOK / LIBRO DEI PENSIERI
   ========================================================================== */
.guestbook-container {
    max-width: 800px;
    margin: 0 auto;
}

.page-header {
    text-align: center;
    margin-bottom: 30px;
}

.page-header h2 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    font-size: 2.2rem;
    margin-bottom: 5px;
}

.subtitle {
    font-style: italic;
    color: #666666;
}

.card-form {
    background: #ffffff;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #eae2d8;
    margin-bottom: 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.card-form h3 {
    margin-top: 0;
    font-family: var(--font-serif);
    color: var(--primary-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cccccc;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 1rem;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-primary, .btn-secondary {
    display: inline-block;
    padding: 10px 22px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
}

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

.btn-secondary {
    background-color: var(--accent-color);
    color: #ffffff;
}

.login-prompt {
    text-align: center;
    padding: 10px;
}

.thoughts-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.thought-card {
    background: #ffffff;
    border-left: 4px solid var(--accent-color);
    padding: 20px;
    border-radius: 0 8px 8px 0;
    border-top: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

.thought-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px dashed #eeeeee;
    padding-bottom: 8px;
}

.author-name {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.thought-date {
    font-size: 0.85rem;
    color: #999999;
}

.thought-body p {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    color: #444444;
    line-height: 1.6;
}

/* ==========================================================================
   PAGINA GALLERIA (FOTO & VIDEO)
   ========================================================================== */
.gallery-container {
    max-width: 1000px;
    margin: 0 auto;
}

.gallery-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.filter-btn {
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 20px;
    color: var(--primary-color);
    background: #f0ebe5;
    font-weight: 500;
    transition: all 0.3s ease;
}

.filter-btn.active, .filter-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
}

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

.gallery-item {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.media-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: #000000;
}

.media-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.media-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: #ffffff;
}

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

.play-button {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 50px; height: 50px;
    background: rgba(255,255,255,0.85);
    color: #c4302b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.media-caption {
    padding: 12px 15px;
    margin: 0;
    font-size: 0.95rem;
    font-family: var(--font-serif);
    color: #555555;
    text-align: center;
}

/* MODALI (LIGHTBOX & YOUTUBE) */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.88);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: 20px; right: 30px;
    color: #ffffff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.modal-content-wrapper {
    max-width: 90%;
    max-height: 85vh;
    text-align: center;
}

.modal-content {
    max-width: 100%;
    max-height: 75vh;
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

.modal-caption {
    color: #dddddd;
    margin-top: 15px;
    font-family: var(--font-serif);
    font-size: 1.1rem;
}

.modal-video-wrapper {
    width: 90%;
    max-width: 800px;
    aspect-ratio: 16/9;
}

.modal-video-wrapper iframe {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* ==========================================================================
   PAGINE AUTENTICAZIONE (LOGIN / REGISTRAZIONE)
   ========================================================================== */
.auth-container {
    max-width: 450px;
    margin: 40px auto;
}

.card-auth {
    background: #ffffff;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #eae2d8;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.card-auth h2 {
    margin-top: 0;
    text-align: center;
    font-family: var(--font-serif);
    color: var(--primary-color);
}

.auth-subtitle {
    text-align: center;
    font-size: 0.9rem;
    color: #666666;
    margin-bottom: 25px;
}

.auth-form .form-group {
    margin-bottom: 18px;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cccccc;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 1rem;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-block {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-size: 1rem;
    margin-top: 10px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eeeeee;
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   ELEMENTI DI NOTIFICA E PAGINAZIONE
   ========================================================================== */
.alert {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.alert-danger {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 40px;
}

.page-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    padding: 6px 12px;
    border: 1px solid #dddddd;
    border-radius: 4px;
    background: #ffffff;
}

.page-link:hover {
    background: #f5f5f5;
}

/* --- ADMIN STYLES --- */
.admin-container {
    max-width: 900px;
    margin: 20px auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #eae2d8;
    padding-bottom: 15px;
}

.admin-menu {
    display: flex;
    gap: 10px;
}

.admin-table-wrapper {
    overflow-x: auto;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eae2d8;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.admin-table th, .admin-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

.admin-table th {
    background-color: #f9f7f5;
    font-family: var(--font-serif);
    color: var(--primary-color);
}

.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff8e1; color: #f57f17; }

.btn-sm {
    padding: 4px 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
}

.btn-approve { background: #2e7d32; color: #fff; }
.btn-delete { background: #c62828; color: #fff; }

.actions-cell {
    display: flex;
    gap: 5px;
}

/* --- ADMIN LAYOUT & PANELS --- */
.admin-wrapper {
    max-width: 1100px;
    margin: 20px auto;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 20px 25px;
    border-radius: 8px;
    border: 1px solid #eae2d8;
    margin-bottom: 25px;
}

.admin-topbar h2 {
    margin: 0;
    font-family: var(--font-serif);
    color: var(--primary-color);
}

.admin-nav-links {
    display: flex;
    gap: 10px;
    align-items: center;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 850px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

.admin-card {
    background: #ffffff;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #eae2d8;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.admin-card h3 {
    margin-top: 0;
    font-family: var(--font-serif);
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.admin-form .form-group {
    margin-bottom: 15px;
}

.admin-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.admin-form input[type="text"],
.admin-form select,
.admin-form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cccccc;
    border-radius: 5px;
    font-family: var(--font-sans);
    box-sizing: border-box;
}

.table-scroll {
    max-height: 400px;
    overflow-y: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table th, .admin-table td {
    padding: 10px;
    border-bottom: 1px solid #eeeeee;
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    background: #fdfbf9;
    position: sticky;
    top: 0;
    z-index: 2;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    text-decoration: none;
    color: #fff;
    display: inline-block;
}

.btn-approve { background: #2e7d32; }
.btn-delete { background: #c62828; }

/* --- ALBUMS GRID STYLES --- */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.album-card {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #eae2d8;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.album-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.album-cover-wrapper {
    position: relative;
    width: 100%;
    height: 190px;
    background: #f0ebe5;
    overflow: hidden;
}

.album-cover-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.album-card:hover .album-cover-wrapper img {
    transform: scale(1.04);
}

.album-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.album-info {
    padding: 18px;
    text-align: center;
}

.album-info h3 {
    margin: 0 0 8px 0;
    font-family: var(--font-serif);
    color: var(--primary-color);
    font-size: 1.2rem;
}

.album-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #666666;
}

.album-detail-header {
    margin-bottom: 30px;
    text-align: center;
}

.album-detail-header h3 {
    font-family: var(--font-serif);
    font-size: 2rem;
    color: var(--primary-color);
    margin-top: 15px;
}

/* --- SWIPER MODAL STYLES --- */
.swiper-container-wrapper {
    width: 90%;
    max-width: 900px;
    height: 80vh;
    position: relative;
}

.swiper {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.swiper-slide {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #000000;
}

.swiper-slide img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.swiper-caption {
    color: #ffffff;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    padding: 12px 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    width: 100%;
    box-sizing: border-box;
}

/* Colore controlli Swiper */
.swiper-button-next, .swiper-button-prev {
    color: #ffffff !important;
}

.swiper-pagination-fraction {
    color: #ffffff !important;
    bottom: 10px !important;
}

/* --- HOME PAGE & RICORDI --- */
.home-container {
    max-width: 820px;
    margin: 0 auto;
}

.story-section {
    display: flex;
    flex-direction: column;
    gap: 35px;
    margin-top: 30px;
}

.story-card {
    background: #ffffff;
    padding: 35px;
    border-radius: 8px;
    border: 1px solid #eae2d8;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

.story-title {
    font-family: var(--font-serif);
    color: var(--primary-color);
    font-size: 1.6rem;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

.story-content p {
    font-family: var(--font-serif);
    font-size: 1.08rem;
    color: #3b3b3b;
    line-height: 1.8;
    margin-bottom: 18px;
}

.section-subtitle {
    font-size: 1.25rem !important;
    font-weight: 600;
    color: var(--primary-color);
    margin-top: 20px;
}

.divider {
    border: 0;
    border-top: 1px dashed #dddddd;
    margin: 30px 0;
}

.signature {
    text-align: right;
    font-family: var(--font-hand);
    font-size: 2rem !important;
    color: var(--primary-color);
    margin-top: 15px;
}

.quote-box {
    background: #fcfbf9;
    border-left: 4px solid var(--accent-color);
    padding: 15px 20px;
    margin: 25px 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.1rem;
    color: #555555;
}

.quote-box cite {
    display: block;
    margin-top: 8px;
    font-size: 0.9rem;
    font-style: normal;
    color: #888888;
}

.highlight-text {
    font-weight: 600;
    font-size: 1.15rem !important;
    color: var(--primary-color);
    line-height: 1.7;
}

/* --- IMPOSTAZIONI IMMAGINI NEI TESTI --- */
.story-img-center {
    text-align: center;
    margin: 20px 0;
}

.story-img-responsive {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.inline-block {
    display: inline-block;
    vertical-align: middle;
    margin: 5px;
}

.inline-img-sm {
    height: 28px;
    vertical-align: middle;
    margin-left: 8px;
}

.inline-img-icon {
    height: 24px;
    vertical-align: middle;
    margin: 0 4px;
}

.inline-img-bear {
    max-height: 90px;
    vertical-align: middle;
    margin-left: 15px;
}

/* --- PULSANTE TORNA SU --- */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 45px;
    height: 45px;
    background-color: var(--primary-color, #5b6b7c);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

#backToTop.show {
    opacity: 0.9;
    visibility: visible;
}

#backToTop:hover {
    opacity: 1;
    background-color: var(--accent-color, #8a9ea7);
    transform: translateY(-3px);
}