/* ===== YGB Panel Deslizante - Estilo claro con botón lateral ===== */
:root {
    --ygb-text: #333333;
    --ygb-border: #e0e0e0;
    --ygb-price: #E26143;
    --ygb-button-bg: #ffffff;
    --ygb-button-border: #8ac64b;
    --ygb-button-text: #8ac64b;
    --ygb-button-hover: #E26143;
    --ygb-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    --ygb-transition: all 0.3s ease;
}

/* ===== PANEL PRINCIPAL - SIN FOOTER ===== */
.ygb-panel {
    position: fixed;
    bottom: -100vh;
    left: 0;
    width: 100%;
    max-height: 90vh;
    background: #ffffff;
    color: var(--ygb-text);
    box-shadow: var(--ygb-shadow);
    transition: var(--ygb-transition);
    z-index: 99999;
    border-top: 1px solid var(--ygb-border);
    display: flex;
    flex-direction: column;
}

.ygb-panel.abierto {
    bottom: 0;
}

/* Cabecera - Solo título y X */
.ygb-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--ygb-border);
    flex-shrink: 0;
}

.ygb-titulo {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ygb-text);
}

.ygb-icono {
    font-size: 1.6rem;
}

/* Botón cerrar - SIN BORDE CIRCULAR */
.ygb-cerrar {
    background: none;
    border: none;
    color: #666;
    font-size: 26px;
    cursor: pointer;
    width: auto;
    height: auto;
    padding: 5px 10px;
    transition: var(--ygb-transition);
    line-height: 1;
    font-weight: 300;
}

.ygb-cerrar:hover {
    color: #E26143;
    background: none;
    transform: scale(1.1);
}

/* Contenido - Scrollable (SIN FOOTER) */
.ygb-panel-contenido {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
    max-height: calc(90vh - 60px);
}

/* ===== GRID COMPACTO - CON CENTRADO AUTOMÁTICO ===== */
.ygb-grid-contenido {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    align-items: stretch;
    justify-content: center;
}

/* Escritorio grande (992px en adelante) - Centrar solo con menos de 4 tarjetas */
@media (min-width: 992px) {
    /* 1 tarjeta - centrado con flex */
    .ygb-grid-contenido:has(.ygb-item-card:first-child:last-child) {
        display: flex;
        justify-content: center;
    }
    
    .ygb-grid-contenido:has(.ygb-item-card:first-child:last-child) .ygb-item-card {
        max-width: 280px;
        width: 100%;
    }
    
    /* 2 tarjetas - grid de 2 columnas centrado */
    .ygb-grid-contenido:has(.ygb-item-card:first-child:nth-last-child(2)) {
        grid-template-columns: repeat(2, minmax(200px, 240px));
        justify-content: center;
    }
    
    /* 3 tarjetas - grid de 3 columnas centrado */
    .ygb-grid-contenido:has(.ygb-item-card:first-child:nth-last-child(3)) {
        grid-template-columns: repeat(3, minmax(180px, 220px));
        justify-content: center;
    }
}

/* Tablet (768px a 991px) - Centrar con menos de 3 tarjetas */
@media (min-width: 768px) and (max-width: 991px) {
    /* 1 tarjeta */
    .ygb-grid-contenido:has(.ygb-item-card:first-child:last-child) {
        display: flex;
        justify-content: center;
    }
    
    .ygb-grid-contenido:has(.ygb-item-card:first-child:last-child) .ygb-item-card {
        max-width: 280px;
        width: 100%;
    }
    
    /* 2 tarjetas */
    .ygb-grid-contenido:has(.ygb-item-card:first-child:nth-last-child(2)) {
        grid-template-columns: repeat(2, minmax(180px, 220px));
        justify-content: center;
    }
}

/* Tarjetas compactas y más finas */
.ygb-item-card {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    transition: var(--ygb-transition);
    border: 1px solid var(--ygb-border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
}

@media (min-width: 1200px) {
    .ygb-grid-contenido {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}

/* Contenedor de imagen - Proporción cuadrada, más compacto */
.ygb-item-imagen {
    width: 100%;
    aspect-ratio: 1/1;
    max-height: 160px;
    overflow: hidden;
    position: relative;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--ygb-border);
}

.ygb-item-imagen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--ygb-transition);
    display: block;
}

.ygb-item-card:hover .ygb-item-imagen img {
    transform: scale(1.05);
}

/* Contenido de tarjeta - Más compacto, menos espacio */
.ygb-item-contenido {
    padding: 8px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ygb-item-titulo {
    margin: 0 0 4px;
    font-size: 0.9rem;
    line-height: 1.3;
    height: 2.4em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ygb-item-titulo a {
    color: var(--ygb-text);
    text-decoration: none;
    font-weight: 600;
}

.ygb-item-titulo a:hover {
    color: #000;
    text-decoration: underline;
}

.ygb-item-resumen {
    font-size: 0.75rem;
    line-height: 1.3;
    margin-bottom: 6px;
    color: #666;
    height: 2.5em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Precio - Más pegado al título */
.ygb-producto-precio {
    font-size: 1rem;
    font-weight: bold;
    color: var(--ygb-price);
    margin: 2px 0 6px;
}

.ygb-producto-precio del {
    color: #999;
    font-size: 0.75rem;
    margin-right: 4px;
}

/* Botón comprar - Compacto y elegante */
.boton-comprar {
    display: inline-block;
    background: var(--ygb-button-bg);
    color: var(--ygb-button-text);
    padding: 5px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s;
    border: 2px solid var(--ygb-button-border);
    cursor: pointer;
    width: 100%;
    text-align: center;
    margin-top: auto;
}

.boton-comprar:hover {
    background: var(--ygb-button-bg);
    color: var(--ygb-button-hover);
    border-color: var(--ygb-button-border);
    transform: translateY(-1px);
}

/* OFERTA badge */
.ygb-oferta {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: bold;
    animation: pulse 2s infinite;
    z-index: 10;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===== BADGE DE AGOTADO ===== */
.ygb-agotado-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #6c757d;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Botón de producto agotado */
.boton-comprar.producto-agotado {
    background: #e0e0e0 !important;
    color: #999 !important;
    border-color: #ccc !important;
    cursor: not-allowed !important;
    pointer-events: none;
    opacity: 0.7;
}

.boton-comprar.producto-agotado:hover {
    transform: none !important;
    background: #e0e0e0 !important;
    color: #999 !important;
    border-color: #ccc !important;
}

/* ===== BOTÓN FLOTANTE - CON IMAGEN Y EMOJI DEL MISMO TAMAÑO (35px) ===== */
.ygb-boton-flotante {
    position: fixed;
    background: var(--ygb-button-bg);
    color: var(--ygb-button-text);
    border: 2px solid var(--ygb-button-border);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 99998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-width: 48px;
}

/* Contenedor del icono - Tamaño fijo para todos (35px) */
.ygb-boton-icono {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    flex-shrink: 0;
}

/* Emojis y Font Awesome */
.ygb-boton-icono i,
.ygb-boton-icono .ygb-icono-emoji {
    font-size: 35px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Para emojis simples */
.ygb-boton-icono:has(> .ygb-icono-emoji) {
    font-size: 35px;
}

/* Imágenes - TAMAÑO FORZADO a 35px */
.ygb-boton-icono img,
.ygb-boton-icono .ygb-icono-imagen {
    width: 35px !important;
    height: 35px !important;
    max-width: 35px !important;
    max-height: 35px !important;
    min-width: 35px !important;
    min-height: 35px !important;
    object-fit: contain;
    display: block;
}

/* Texto del botón */
.ygb-boton-texto {
    white-space: nowrap;
    font-size: 1rem;
    font-weight: 600;
}

/* Posición izquierda */
.ygb-boton-flotante.posicion-izquierda {
    left: -10px;
    border-left: none;
    border-radius: 0 50px 50px 0;
}

.ygb-boton-flotante.posicion-izquierda .ygb-boton-texto {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ygb-boton-flotante.posicion-izquierda:hover {
    left: 0;
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.2);
}

.ygb-boton-flotante.posicion-izquierda:hover .ygb-boton-texto {
    max-width: 200px;
    opacity: 1;
    margin-left: 6px;
}

/* Posición derecha */
.ygb-boton-flotante.posicion-derecha {
    right: -10px;
    border-right: none;
    border-radius: 50px 0 0 50px;
    flex-direction: row-reverse;
}

.ygb-boton-flotante.posicion-derecha .ygb-boton-texto {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ygb-boton-flotante.posicion-derecha:hover {
    right: 0;
    box-shadow: -4px 4px 16px rgba(0, 0, 0, 0.2);
}

.ygb-boton-flotante.posicion-derecha:hover .ygb-boton-texto {
    max-width: 200px;
    opacity: 1;
    margin-right: 6px;
}

/* Hover color */
.ygb-boton-flotante:hover {
    background: var(--ygb-button-bg);
    color: var(--ygb-button-hover);
    border-color: var(--ygb-button-border);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .ygb-panel {
        max-height: 85vh;
    }
    
    .ygb-panel-contenido {
        padding: 15px;
        max-height: calc(85vh - 60px);
    }
    
    .ygb-grid-contenido {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* En móvil, centrar solo cuando hay 1 tarjeta */
    .ygb-grid-contenido:has(.ygb-item-card:only-child) {
        display: flex;
        justify-content: center;
    }
    
    .ygb-grid-contenido:has(.ygb-item-card:only-child) .ygb-item-card {
        max-width: 260px;
        width: 100%;
    }
    
    .ygb-item-card {
        max-width: none;
    }
    
    .ygb-item-imagen {
        max-height: 140px;
    }
    
    .ygb-item-titulo {
        font-size: 0.85rem;
    }
    
    .ygb-producto-precio {
        font-size: 0.95rem;
    }
    
    .boton-comprar {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    .ygb-boton-flotante {
        padding: 6px 12px;
        min-width: 42px;
    }
    
    .ygb-boton-icono {
        width: 32px;
        height: 32px;
    }
    
    .ygb-boton-icono i,
    .ygb-boton-icono .ygb-icono-emoji {
        font-size: 32px;
    }
    
    .ygb-boton-icono img,
    .ygb-boton-icono .ygb-icono-imagen {
        width: 32px !important;
        height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
    }
    
    .ygb-boton-flotante.posicion-izquierda {
        left: -5px;
    }
    
    .ygb-boton-flotante.posicion-derecha {
        right: -5px;
    }
}

@media (max-width: 480px) {
    .ygb-grid-contenido {
        grid-template-columns: 1fr;
    }
    
    .ygb-item-imagen {
        max-height: 180px;
    }
}

/* ===== MEJORA: Fallback para navegadores que no soportan :has() ===== */
@supports not (selector(:has)) {
    .ygb-grid-contenido {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    
    @media (max-width: 768px) {
        .ygb-grid-contenido {
            grid-template-columns: repeat(2, 1fr);
        }
    }
    
    @media (max-width: 480px) {
        .ygb-grid-contenido {
            grid-template-columns: 1fr;
        }
    }
}