/**
    * Estilos del Carrusel - Frontend
    * Dynamic Banner Carousel Plugin
    * 
    * Inspirado en el diseño de Eneba
    * Optimizado para performance y accesibilidad
    * 
    * Colores del plugin:
    * --dbc-primary: #155728 (Verde oscuro)
    * --dbc-secondary: #669F30 (Verde claro)
    * --dbc-accent: #FFFFFF (Blanco)
    * 
    * @package DynamicBannerCarousel
    * @subpackage Public/CSS
    * @since 1.0.0
*/

/* ========================================
    VARIABLES CSS
======================================== */
:root {
    /* Colores del plugin */
    --dbc-primary-color: #155728;
    --dbc-secondary-color: #669F30;
    --dbc-accent-color: #FFFFFF;
    
    /* Dimensiones de imágenes */
    --dbc-base-width: 200px;
    --dbc-base-height: 400px;
    --dbc-expanded-width: 1500px;
    --dbc-expanded-height: 400px;
    
    /* Animaciones */
    --dbc-animation-duration: 400ms;
    --dbc-animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Efectos */
    --dbc-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --dbc-shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.2);
    --dbc-overlay-color: rgba(21, 87, 40, 0.1);
}

/* ========================================
    WRAPPER PRINCIPAL DEL CARRUSEL
======================================== */
.dbc-carousel-wrapper {
    width: 100%;
    overflow: hidden;
    position: relative;
    margin: 0 auto;
    padding: 20px 0;
}

/* ========================================
    LISTA DEL CARRUSEL
======================================== */
.dbc-carousel-list {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    width: fit-content;
    margin: 0 auto;
}

/* ========================================
    ITEM INDIVIDUAL DEL CARRUSEL
======================================== */
.dbc-carousel-item {
    position: relative;
    width: var(--dbc-base-width);
    height: var(--dbc-base-height);
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--dbc-animation-duration) var(--dbc-animation-easing),
                box-shadow var(--dbc-animation-duration) var(--dbc-animation-easing);
    cursor: pointer;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: var(--dbc-shadow);
}

/* Estado expandido */
.dbc-carousel-item.dbc-expanded {
    width: var(--dbc-expanded-width);
    cursor: default;
    box-shadow: var(--dbc-shadow-hover);
    z-index: 10;
}

/* Hover en items no expandidos */
.dbc-carousel-item:not(.dbc-expanded):hover {
    box-shadow: var(--dbc-shadow-hover);
    transform: translateY(-2px);
}

/* ========================================
    LINK OVERLAY (Área clickeable del expandido)
======================================== */
.dbc-link-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: block;
    text-decoration: none;
    background: transparent;
    transition: background-color 0.3s ease;
}

/* Hover en el link del item expandido */
.dbc-carousel-item.dbc-expanded .dbc-link-overlay:hover {
    background-color: var(--dbc-overlay-color);
}

/* Efecto de focus para accesibilidad */
.dbc-link-overlay:focus {
    outline: 3px solid var(--dbc-secondary-color);
    outline-offset: -3px;
}

/* ========================================
    BOTÓN TRIGGER (Imagen base clickeable)
======================================== */
.dbc-trigger-button {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--dbc-base-width);
    height: var(--dbc-base-height);
    border: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    z-index: 3;
    padding: 0;
    margin: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
}

/* Ocultar botón cuando el item está expandido */
.dbc-carousel-item.dbc-expanded .dbc-trigger-button {
    opacity: 0;
    pointer-events: none;
}

/* Hover en el botón trigger */
.dbc-trigger-button:hover {
    transform: scale(1.02);
}

/* Focus en el botón para accesibilidad */
.dbc-trigger-button:focus {
    outline: 3px solid var(--dbc-secondary-color);
    outline-offset: -3px;
    z-index: 4;
}

/* ========================================
    INDICADOR VISUAL DE EXPANSIÓN
======================================== */
.dbc-trigger-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dbc-trigger-button::after {
    content: '\f065'; /* Font Awesome expand icon */
    font-family: 'Font Awesome 5 Free', 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--dbc-primary-color);
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.dbc-trigger-button:hover::before,
.dbc-trigger-button:hover::after {
    opacity: 1;
}

/* ========================================
    TEXTO PARA SCREEN READERS
======================================== */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
    ANIMACIONES DE CARGA
======================================== */
@keyframes dbc-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dbc-carousel-item {
    animation: dbc-fade-in 0.5s ease-out;
}

/* Delay progresivo para cada item */
.dbc-carousel-item:nth-child(1) {
    animation-delay: 0s;
}

.dbc-carousel-item:nth-child(2) {
    animation-delay: 0.1s;
}

.dbc-carousel-item:nth-child(3) {
    animation-delay: 0.2s;
}

.dbc-carousel-item:nth-child(4) {
    animation-delay: 0.3s;
}

/* ========================================
    LOADING STATE
======================================== */
.dbc-carousel-wrapper.dbc-loading .dbc-carousel-item {
    opacity: 0.5;
    pointer-events: none;
}

.dbc-carousel-wrapper.dbc-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid var(--dbc-primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: dbc-spin 0.8s linear infinite;
}

@keyframes dbc-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ========================================
    ESTADO VACÍO
======================================== */
.dbc-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border-radius: 8px;
    margin: 20px auto;
    max-width: 600px;
}

.dbc-empty-icon {
    font-size: 64px;
    color: #cbd5e1;
    margin-bottom: 20px;
}

.dbc-empty-state h3 {
    font-size: 24px;
    color: #1e293b;
    margin-bottom: 10px;
}

.dbc-empty-state p {
    color: #64748b;
    margin-bottom: 20px;
}

/* ========================================
    RESPONSIVE - TABLET
======================================== */
@media (max-width: 1024px) {
    .dbc-carousel-wrapper {
        padding: 15px 0;
    }

    .dbc-carousel-item.dbc-expanded {
        width: calc(var(--dbc-expanded-width) * 0.8);
    }

    :root {
        --dbc-animation-duration: 300ms;
    }
}

/* ========================================
    RESPONSIVE - MOBILE
    Solo mostrar imágenes base sin expansión
======================================== */
@media (max-width: 768px) {
    .dbc-carousel-wrapper {
        padding: 10px 0;
    }

    .dbc-carousel-list {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .dbc-carousel-item {
        width: var(--dbc-base-width);
        cursor: default;
        pointer-events: none;
    }

    /* Forzar ancho base en móviles */
    .dbc-carousel-item.dbc-expanded {
        width: var(--dbc-base-width) !important;
        cursor: default;
        box-shadow: var(--dbc-shadow);
    }

    /* Ocultar overlay de link en móviles */
    .dbc-link-overlay {
        pointer-events: none;
        display: none;
    }

    /* Ocultar botón trigger en móviles */
    .dbc-trigger-button {
        display: none;
        pointer-events: none;
    }

    /* Ajustar dimensiones para pantallas muy pequeñas */
    @media (max-width: 480px) {
        :root {
            --dbc-base-width: 160px;
            --dbc-base-height: 320px;
        }

        .dbc-carousel-list {
            gap: 8px;
        }
    }
}

/* ========================================
    OPTIMIZACIONES DE PERFORMANCE
======================================== */

/* GPU acceleration para animaciones */
.dbc-carousel-item,
.dbc-trigger-button,
.dbc-link-overlay {
    will-change: transform, width, opacity;
}

/* Reducir will-change después de la animación */
.dbc-carousel-item.dbc-animation-complete {
    will-change: auto;
}

/* Optimización de rendering de imágenes */
.dbc-carousel-item,
.dbc-trigger-button {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* ========================================
    ACCESIBILIDAD - PREFERS REDUCED MOTION
======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .dbc-carousel-item {
        animation: none;
    }

    :root {
        --dbc-animation-duration: 0ms;
    }
}

/* ========================================
    HIGH CONTRAST MODE
======================================== */
@media (prefers-contrast: high) {
    .dbc-carousel-item {
        border: 2px solid currentColor;
    }

    .dbc-link-overlay:focus,
    .dbc-trigger-button:focus {
        outline: 4px solid currentColor;
        outline-offset: 2px;
    }
}

/* ========================================
    DARK MODE SUPPORT
======================================== */
@media (prefers-color-scheme: dark) {
    .dbc-empty-state {
        background: #1e293b;
    }

    .dbc-empty-state h3 {
        color: #f1f5f9;
    }

    .dbc-empty-state p {
        color: #94a3b8;
    }

    .dbc-empty-icon {
        color: #475569;
    }
}

/* ========================================
    PRINT STYLES
======================================== */
@media print {
    .dbc-carousel-wrapper {
        page-break-inside: avoid;
    }

    .dbc-carousel-list {
        flex-wrap: wrap;
    }

    .dbc-carousel-item {
        width: var(--dbc-base-width);
        page-break-inside: avoid;
    }

    .dbc-carousel-item.dbc-expanded {
        width: 100%;
        max-width: var(--dbc-expanded-width);
    }

    .dbc-trigger-button,
    .dbc-link-overlay::after {
        display: none;
    }
}

/* ========================================
    FOCUS VISIBLE (Mejora de accesibilidad)
======================================== */
.dbc-link-overlay:focus-visible,
.dbc-trigger-button:focus-visible {
    outline: 3px solid var(--dbc-secondary-color);
    outline-offset: 2px;
}

/* Remover outline en focus normal (solo visible en focus-visible) */
.dbc-link-overlay:focus:not(:focus-visible),
.dbc-trigger-button:focus:not(:focus-visible) {
    outline: none;
}

/* ========================================
    CONTENEDOR CON MÁXIMO ANCHO
======================================== */
.dbc-carousel-container-limited {
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 20px;
}

.dbc-carousel-container-limited .dbc-carousel-wrapper {
    width: 100%;
}

/* ========================================
    VARIACIONES DE ESTILO (Para futuras versiones)
======================================== */

/* Variación con bordes redondeados */
.dbc-carousel-wrapper.dbc-rounded .dbc-carousel-item {
    border-radius: 8px;
    overflow: hidden;
}

/* Variación con separación entre items */
.dbc-carousel-wrapper.dbc-spaced .dbc-carousel-list {
    gap: 10px;
}

/* Variación con efecto de escala en hover */
.dbc-carousel-wrapper.dbc-scale-hover .dbc-carousel-item:not(.dbc-expanded):hover {
    transform: scale(1.05);
}

/* ========================================
    COMPATIBILIDAD CON NAVEGADORES ANTIGUOS
======================================== */

/* Fallback para navegadores sin soporte de CSS variables */
@supports not (--css: variables) {
    .dbc-carousel-item {
        width: 200px;
        height: 400px;
    }

    .dbc-carousel-item.dbc-expanded {
        width: 1500px;
    }

    .dbc-trigger-button {
        width: 200px;
        height: 400px;
    }
}

/* Fallback para navegadores sin soporte de flexbox */
@supports not (display: flex) {
    .dbc-carousel-list {
        display: block;
        text-align: center;
    }

    .dbc-carousel-item {
        display: inline-block;
        vertical-align: top;
    }
}

/* ========================================
    UTILIDADES
======================================== */

/* Ocultar elemento */
.dbc-hidden {
    display: none !important;
}

/* Ocultar visualmente pero mantener para screen readers */
.dbc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* No seleccionable */
.dbc-no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}