/* ===== BASE PAGE ===== */
body {
    background: #fff !important;
    color: #000;
}

.templates-page {
    padding-top: 130px;
    width: 92%;
    margin: 0 auto;
}

.templates-title {
    text-align: center;
    margin-bottom: 50px;
}

.templates-title h1 {
    font-size: 3rem;
    color: #00bfff;
    font-weight: 700;
}

/* ===== LAYOUT ===== */
.templates-layout {
    display: flex;
    gap: 10px;
}

/* ===== DESKTOP SIDEBAR ===== */
.sidebar {
    width: 200px;
    background: #f5f7fb;
    border: 1px solid #e5e8ee;
    padding: 25px;
    border-radius: 12px;
    height: fit-content;
    position: sticky;
    top: 120px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== BUTTONS ===== */
.filter-btn.main {
    width: 100%;
    padding: 14px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 10px;
    border: none;
    background: #fff;
    cursor: pointer;
    transition: 0.25s ease;
    color: #000;
    text-align: center;
}

.filter-btn.main:hover,
.filter-btn.main.active {
    background: #00bfff;
    color: #fff;
    box-shadow: 0 0 12px rgba(0, 191, 255, 0.45);
}

/* ===== GRID ===== */
.templates-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

/* Ogni box contiene solo il wrapper */
.template-box {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;

    display: flex;
    justify-content: center;
    align-items: center;
}

.template-box img {
    width: 87%;
    margin: 10px auto;
    /* CENTRA DAVVERO */
    display: block;
    border-radius: 20px;
    transition: 0.35s ease;
}

/* ===================================== */
/*       IMMAGINE + OVERLAY CENTRATI     */
/* ===================================== */
.img-wrap {
    position: relative;
    width: fit-content;
    /* LARGHEZZA = immagine */
    margin: 0 auto;
    /* Centra davvero */
}

.img-wrap img {
    width: 87%;
    /* dimensione immagine */
    display: block;
    border-radius: 20px;
    transition: 0.35s ease;
}

.img-wrap:hover img {
    filter: blur(2px) brightness(0.85);
    transform: scale(1.03);
}

.img-wrap .template-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: 0.3s ease;
    pointer-events: none;
}

.img-wrap:hover .template-overlay {
    opacity: 1;
}

.img-wrap .template-overlay h4 {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
}

/* ===== FILTER BUTTON MOBILE ===== */
.filter-toggle {
    display: none;
    width: 100%;
    padding: 14px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    background: #00bfff;
    color: #fff;
    border: none;
    border-radius: 12px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: 0.25s ease;
}

.filter-toggle:hover {
    filter: brightness(1.1);
}

/* ===== MOBILE MODE ===== */
@media (max-width: 900px) {

    .templates-layout {
        flex-direction: column;
    }

    .filter-toggle {
        display: block;
    }

    .sidebar {
        display: none;
        background: #f5f7fb;
        border: 1px solid #e5e8ee;
        padding: 20px;
        border-radius: 14px;
        animation: slideDown 0.3s ease;
        margin: 0 auto;
        width: 100%;
        max-width: 350px;
    }

    .sidebar.open {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        justify-content: center;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* 2 immagini per riga */
    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .img-wrap img {
        width: 85%;
    }
}
/* Sidebar sempre visibile su desktop */
@media (min-width: 901px) {
    .sidebar {
        display: flex !important;
    }
}