/* Layout general - Fondo gris claro */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    background-color: #f0f0f0;
    color: #333;
    min-height: 100vh;
    padding: 0;
}

.container {
    /* FIX: Restaurado max-width a 1400px para margen lateral y evitar solapamiento con barra */
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px 10px;
}

header {
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    color: #1DB954;
    margin-bottom: 5px;
}

h1 + p {
    font-size: 1.2rem;
    color: #555;
}

h2 {
    font-size: 1.6rem;
    text-align: center;
    color: #333;
    margin-bottom: 15px;
}

.btn {
    background-color: #1DB954;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(29, 185, 84, 0.2);
}

.btn:hover {
    background-color: #1ed760;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(29, 185, 84, 0.3);
}

.text-input, .select-input {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ddd;
    background-color: white;
    color: #333;
    font-size: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.status {
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
}

.status.success { color: #1DB954; }
.status.error { color: #e74c3c; }

/* Grid de cartas - muchas por fila */
#cards {
    display: grid;
    /* FIX: minmax a 160px para más cartas por fila sin solaparse */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    /* FIX: gap a 20px para espacio moderado entre cartas */
    gap: 20px;
    width: 100%;
    margin: 30px auto;
    /* FIX: padding a 20px para margen lateral */
    padding: 0 20px;
    justify-items: center;
    padding-bottom: 60px;
}

/* Cartas: fondo negro, cover grande, texto estilizado */
.card {
    width: 63mm;
    height: 88mm;
    perspective: 1500px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.7s ease-in-out;
    transform-style: preserve-3d;
    cursor: pointer;
}

.card:hover .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #000000;
    color: #fff;
    border-radius: 8mm;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
}

/* Anverso: cover grande */
.card-front {
    padding: 3px;
}

.cover-wrapper {
    height: 62mm; /* Cover grande */
    padding: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4mm;
}

/* Texto: grande y estilizado */
.info {
    flex: 1;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.title {
    font-size: 10pt;
    font-weight: bold;
    margin-bottom: 3px;
    line-height: 1.1;
}

.artist {
    font-size: 9pt;
    color: #1DB954;
    font-weight: 600;
    margin: 2px 0;
}

.album {
    font-size: 8pt;
    opacity: 0.9;
    margin: 2px 0;
}

.year {
    font-size: 8pt;
    color: #b3b3b3;
    margin: 2px 0;
}

.duration {
    font-size: 8pt;
    opacity: 0.8;
    margin-top: auto;
}

/* Reverso: QR grande centrado */
.card-back {
    transform: rotateY(180deg);
    justify-content: center;
    align-items: center;
    padding: 10px;
}

/* REEMPLAZA ESTO EN TU CSS */

/* Contenedor blanco del QR */
.qr {
    width: 65%;               /* Un poco más grande para que se vea bien en móvil */
    aspect-ratio: 1 / 1;      /* Mantiene siempre el cuadrado perfecto */
    background: white;
    border-radius: 10px;      /* Bordes redondeados más suaves */
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);

    /* Centrado del código dentro del cuadro blanco */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;             /* Padding fijo en lugar de % para evitar errores de cálculo */

    /* IMPORTANTE: Evita que el QR se aplaste si falta altura en el móvil */
    flex-shrink: 0;
}

/* El código generado (canvas o imagen) */
.qr img, .qr canvas {
    width: 100% !important;   /* Fuerza a ocupar el espacio disponible */
    height: 100% !important;
    object-fit: contain;      /* Mantiene la proporción del dibujo */
    display: block;
}

.scan {
    margin-top: 15px;
    font-size: 10px;          /* Texto un poco más pequeño en general */
    opacity: 0.9;
    text-align: center;
    padding: 0 5px;
}

/* Enlace */
a.card-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.playlist-title {
    position: sticky;
    top: 90px;
    z-index: 10;

    width: 100vw;
    margin-left: calc(-50vw + 50%);

    text-align: center;
    padding: 6px 0 6px;   /* 👈 CLAVE: casi sin aire */

    background-color: #f0f0f0;
    color: #1DB954;
    font-weight: 700;

    border-bottom: none; /* 👈 elimina 1px fantasma */
}



/* Popup de carga */
.loading-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;

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

.loading-box {
    background: #fff;
    padding: 30px 30px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    max-width: 400px;
}

.loading-box p {
    margin-top: 5px;
    font-size: 1rem;
    color: #333;
    font-weight: 600;
}

/* Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #ddd;
    border-top: 5px solid #1DB954;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Centrar carta cuando solo hay una */
#cards.single-card {
    grid-template-columns: 1fr;
    justify-items: center;
}

/* Centrar carta cuando solo hay una */
#cards.single-card a.card-link {
    grid-column: 1 / -1;      /* ocupa tó el grid */
    justify-self: center;     /* centra el link */
    width: fit-content;              /* deja que ajuste al contenido */
}

/* =====================
   FOOTER ULTRA COMPACTO
   ===================== */

footer {
    position: relative;
    z-index: 10;

    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 2px 0 14px;           /* 👈 mínimo real */
    gap: 1px;

    font-size: 0.65rem;
    background-color: #f0f0f0;
    color: #666;
    border-top: 1px solid #ddd;
}

.footer-link {
    margin: 0;
    line-height: 1;
}


.footer-text {
    margin: 0;
    line-height: 1;          /* 👈 clave */
}

.footer-link {
    margin: 0;
    line-height: 1;
    color: #1DB954;
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

/* Botón Buy Me a Coffee */
.bmc-container {
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 9999;
}

.bmc-container iframe {
    transform: scale(0.5);          /* 👈 tamaño reducido */
    z-index: 3001;  /* 👈 redundancia segura */
    transform-origin: top right;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}


#cards {
    margin-bottom: 5px;   /* 👈 ajusta a gusto: 40–80px */
}

#pagination {
    margin-bottom: 80px;   /* espacio para el botón ☕ */
}

/* =====================================
   CARTAS – TEXTO COMPACTO SOLO EN MÓVIL
   ===================================== */
@media (max-width: 768px) {
    /* 🔥 iframe completamente FUERA */
    .bmc-container {
        display: none !important;
    }
    #cards {
        grid-template-columns: repeat(2, 1fr); /* 👈 2 cartas por fila */
        gap: 14px;
        padding: 0 10px;
        padding-bottom: 120px;
    }
    /* 🔥 PRIORIDAD: carta única SIEMPRE centrada */
    #cards.single-card {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    #cards.single-card .card {
        max-width: 240px;
    }
    #cards.single-card a.card-link {
        grid-column: 1 / -1;
        justify-self: center;
        width: fit-content;
    }

    /* Botón flotante real */
    .bmc-fab {
        display: flex;
        position: fixed;

        bottom: 16px;
        right: 16px;

        width: 52px;
        height: 52px;

        background-color: #1DB954;
        color: #fff;

        border-radius: 50%;
        font-size: 24px;

        align-items: center;
        justify-content: center;

        box-shadow: 0 6px 16px rgba(0,0,0,0.3);
        z-index: 9999;

        text-decoration: none;
    }

    .bmc-fab:active {
        transform: scale(0.95);
    }

    h1 { font-size: 2rem; }
    .btn { padding: 12px 20px; }

    .bmc-fab:active {
        transform: scale(0.95);
    }
    .playlist-title {
        top: 40px;       /* 👈 altura real del header móvil */
        padding: 6px 8px;         /* reduce altura */
        font-size: 0.9rem;        /* más pequeño */
        line-height: 1.2;         /* compacta el texto */

        padding-top: 0;      /* 👈 clave */
        margin-top: 0;       /* 👈 asegura soldadura */

        border-top: none;

        white-space: nowrap;      /* una sola línea */
        overflow: hidden;         /* evita crecer */
        text-overflow: ellipsis;  /* … si es muy largo */
    }
    #pagination {
     margin-bottom: 140px;  /* si hay paginación */
    }
    /* Carta */
    .card {
        width: 240px;
        height: auto;
        aspect-ratio: 63 / 88;
    }

    /* Cover */
    .cover-wrapper {
        height: auto;
    }

    .cover {
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }

    /* Texto */
    .info {
        padding: 6px 6px 8px;
        gap: 1px;
        justify-content: flex-start;
        text-align: center;
    }

    .title {
        font-size: 11px;
        line-height: 1.05;
        margin: 0;
        font-weight: 600;

        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .artist {
        font-size: 10px;
        line-height: 1.05;
        margin: 0;
    }

    .album {
        font-size: 9px;
        line-height: 1.05;
        margin: 0;
    }

    .year {
        font-size: 9px;
        line-height: 1;
        margin: 0;
        opacity: 0.8;
    }

    .card-back {
        padding: 10px;
        justify-content: center;
        gap: 10px; /* Espacio entre el QR y el texto */
    }
    /* Ajuste fino para que el texto no moleste al QR en pantallas muy pequeñas */
    .scan {
        font-size: 9px;
        margin-top: 5px;
    }

    header {
        padding: 4px 8px;          /* 👈 mínimo real */
        padding-bottom: 0;   /* 👈 elimina el aire */
        margin-bottom: 0;    /* 👈 por si acaso */
    }

    header h1 {
        font-size: 0.95rem;        /* 👈 mucho más compacto */
        line-height: 1.1;
        margin: 0;

        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;                  /* espacio justo icono-texto */
        white-space: nowrap;       /* una sola línea */

        margin-bottom: 0;    /* 👈 MUY importante */
    }

    header h1 i {
        font-size: 1rem;           /* icono pequeño */
    }

    .main-footer {
        padding: 30px 15px;
        margin-top: 30px;
    }

    .footer-content p {
        font-size: 0.8rem;
    }
}
/* Móvil en horizontal → 4 columnas */
@media (max-width: 768px) and (orientation: landscape) {
    #cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

/* Fuerza estilo limpio del botón de café */
.bmc-container a,
.bmc-container iframe {
    transform: scale(0.5);
    transform-origin: top right;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* =========================
   ESTILOS DEL FOOTER
   ========================= */
.main-footer {
    background-color: #ffffff;
    border-top: 2px solid #1DB954; /* El verde de Spotify */
    padding: 40px 20px;
    margin-top: 50px;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.footer-content p {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

header {
    position: sticky;
    top: 0;
    z-index: 1000; /* 👈 más alto que playlist-title */

    width: 100vw;                      /* 👈 ancho total */
    margin-left: calc(-50vw + 50%);    /* 👈 rompe el container */

    background-color: #f0f0f0; /* importante para que tape lo de debajo */

    text-align: center;
    padding: 10px 0;

    border-bottom: 1px solid #ddd;
}

.playlist-title {
    line-height: 1;
    margin: 10;
}

.playlist-main {
    display: block;
    margin: 10;
}

.playlist-count {
    display: block;
    margin-top: 3px;   /* 👈 aquí está la magia */
    margin-bottom: 0px;
    font-size: 0.8rem;
    opacity: 0.85;
}

.unified-section h2 {
    color: #1DB954; /* verde Spotify */
}





