/* Variables y estilos globales */
:root {
    --primary-color: #bb6783;
    --primary-color-hover: #fff;
    --primary-color-hover-link: rgb(231, 163, 187);
    --text-color: #333;
    --bg-overlay: rgba(3, 3, 3, 0.6);
    --font-family: 'Arial', sans-serif;
}

body {
    background-color: #f5f5f5;
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    color: var(--text-color);
}

.select-template-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

/* Grilla de plantillas (infinite scroll) */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* En móviles, forzar 2 columnas */
@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.template-card {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    height: 450px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    background-color: transparent;
}

.template-card:hover {
    transform: translateY(-5px);
}

.template-image-container {
    overflow: hidden;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1;
}

.template-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    filter: brightness(0.85);
}

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

.template-info {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 15px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.86), transparent);
    color: white;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Mostrar el nombre de la plantilla */
.template-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.template-button, .template-butons {
    width: 90%;
    background-color: var(--primary-color);
    color: white;
    padding: 10px;
    border-radius: 15px;
    font-size: 1rem;
    text-decoration: none;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.template-button:hover {
    background-color: var(--primary-color-hover);
    color: var(--primary-color);
}

.template-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

@media (max-width: 480px) {
    .template-card {
        height: 350px;
    }
}

/* Leyenda de carga */
.loading {
    text-align: center;
    font-size: 1.2rem;
    color: var(--primary-color);
    margin: 20px 0;
    display: none;
}

/* Carrusel de Favoritos */
.favorites-section {
    margin-bottom: 20px;
    text-align: left;
}

.favorites-section h2 {
    font-size: 1.2rem;
    margin: 0 0 10px;
}

.favorites-wrapper {
    position: relative;
}

.favorites-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
    padding-bottom: 10px;
}

.favorites-container::-webkit-scrollbar {
    display: none;
}

.favorite-card {
    flex: 0 0 auto;
    width: 150px;
    border-radius: 10px;
    overflow: hidden;
    scroll-snap-align: start;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.favorite-card .card-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
}

.favorite-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.favorite-card .card-footer {
    padding: 5px 8px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.favorite-card .card-title {
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-color);
}

.favorite-card .card-actions {
    display: flex;
    width: 100%;
    justify-content: space-around;
}

.favorite-card .card-actions a {
    color: var(--primary-color);
    font-size: 1.2rem;
    text-decoration: none;
    transition: color 0.3s;
}

.favorite-card {
    color: var(--primary-color-hover);
}
.card-actions a:hover {
    color: var(--primary-color-hover-link);
}

/* Botones de navegación del carrusel */
.favorites-prev,
.favorites-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    display: none;
}

.favorites-prev {
    left: -20px;
}

.favorites-next {
    right: -20px;
}

@media (min-width: 768px) {

    .favorites-prev,
    .favorites-next {
        display: block;
    }
}

/* Sección de "Todas las Plantillas" */
.all-templates-container h2 {
    margin-top: 40px;
    margin-bottom: 20px;
}

.template-button.favorite-button.favorited {
    background: var(--primary-color-hover);
    color: var(--primary-color);
}