/* Layout general - Fondo gris claro */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}
header {
    position: sticky;
    top: 0;
    z-index: 1000;

    background-color: #f0f0f0;
    border-bottom: 1px solid #ddd;

    text-align: center;
    padding: 10px 0;
    color: #1DB954;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 10px;
}

header h1 {
    font-size: clamp(1.4rem, 4vw, 2.5rem);
    line-height: 1.1;
    margin: 0;

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

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    white-space: nowrap;
}

.playlist-bar {
    position: sticky;
    top: 56px;               /* ⬅ altura real del header */
    z-index: 900;

    width: 100%;
    background-color: #f0f0f0;

    border-bottom: 1px solid #ddd;
}
.playlist-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 6px 10px;

    text-align: center;
}

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;
    padding: 20px 10px;
}

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(240px, 1fr));
    /* FIX: gap a 20px para espacio moderado entre cartas */
    gap: 12px;
    width: 100%;
    margin: 30px auto;
    /* FIX: padding a 20px para margen lateral */
    padding: 0 8px;
    justify-items: stretch;
    padding-bottom: 60px;
    margin-bottom: 5px;   /* 👈 ajusta a gusto: 40–80px */
    max-width: 1800px;
}

/* Cartas: fondo negro, cover grande, texto estilizado */
.card {
    width: 100%;          /* ocupa la columna del grid */
    max-width: 74mm;      /* nunca más grande que la carta real */
    aspect-ratio: 74 / 105;
    height: auto;         /* deja que escale proporcionalmente */
    margin: 0 auto;

    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;
}
.card-back .qr {
    margin-top: auto;
    margin-bottom: auto;
}

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

.cover-wrapper {
    height: 65mm; /* 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);

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: flex-start;   /* 🔥 contenido arriba */

    padding: 10px;
}

/* 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: 0 0 10px 0;     /* espacio SOLO debajo */
    font-size: 10px;
    opacity: 0.9;
    text-align: center;
}

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

.playlist-title {
    top: 75px;
    z-index: 9;

    max-width: 1400px;
    margin: 0 auto;
    padding: 4px 10px;

    text-align: center;

    background-color: #f0f0f0;
    color: #1DB954;
    font-weight: 700;
    line-height: 1.2;
}




/* 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); }
}

/* Busca esta sección en tu style.css y reemplázala */
#cards.single-card {
    display: flex !important; /* Cambiamos grid por flex para centrado total */
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 400px; /* Evita que se pegue arriba */
}

#cards.single-card .card-link {
    width: 74mm; /* Mantiene el tamaño original de la carta */
    margin: 0 auto;
}

/* =====================
   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-text {
    margin: 0;
    line-height: 1;          /* 👈 clave */
    font-size:1.5rem;
}

.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);
}

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

/* =====================================
   CARTAS – TEXTO COMPACTO SOLO EN MÓVIL
   ===================================== */
@media (max-width: 768px) {
    .playlist-bar {
        top: 25px; /* header más pequeño en móvil */
    }

    .playlist-inner {
        padding: 4px 8px;
    }

    /* 🔥 iframe completamente FUERA */
    .bmc-container {
        display: none !important;
    }
    #cards {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* 👈 2 cartas por fila */
        gap: 14px;
        padding: 0 8px;
        padding-bottom: 120px;

        padding-left: 0;
        padding-right: 0;

        overflow-x: hidden;
    }
    /* 🔥 PRIORIDAD: carta única SIEMPRE centrada */
    #cards.single-card {
        display: flex !important;
        justify-content: center;
        align-items: center;
        width: 100%;
        min-height: 400px;
        padding: 20px 0;
    }
    #cards.single-card .card {
        width: 100%;
        max-width: 240px;
    }
    #cards.single-card .card-link {
        /* Eliminamos el 'width: fit-content' que causa el colapso a 6px */
        display: block;
        width: 74mm;
        height: 105mm;
        margin: 0 auto;
        flex-shrink: 0; /* Evita que se comprima */
    }

    /* 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);
    }

    .btn { padding: 12px 20px; }

    .bmc-fab:active {
        transform: scale(0.95);
    }
    .playlist-title {
        top: 48px;
        padding: 2px 6px;
        font-size: 0.9rem;
        margin: 0;

        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 */

        width: 100%;
        margin-left: 0;
    }
    #pagination {
     margin-bottom: 140px;  /* si hay paginación */
    }
    .card {
        width: 100%;
        max-width: 74mm;
        aspect-ratio: 74 / 105;
        height: auto;
        margin: 0 auto;
        perspective: 1500px;
    }


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

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

    /* Texto */
    .info {
        min-height: 64px; /* estabiliza la zona de texto */
        padding: 6px 6px 6px;
        gap: 1px;
        justify-content: center;
        text-align: center;
    }

    .title {
        font-size: 13px;
        line-height: 1.1;
        margin: 0;
        font-weight: 600;

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

    .artist {
        font-size: 11px;
        line-height: 1.1;
        margin: 0;
    }

    .album {
        font-size: 10px;
        line-height: 1.1;
        margin: 0;
    }

    .year {
        font-size: 10px;
        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 {
        position:top;
        font-size: 9px;
        margin-top: 0px;
    }

    header {
        padding: 4px 8px;
    }

    header h1 {
        font-size: 0.95rem;
    }

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

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

    .footer-content p {
        font-size: 0.8rem;
    }
    .container {
        padding: 16px 12px;
    }
}
/* 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;
}

.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 */
}





