/* AdbnPro Frontend Styles */

/* Base Banner Styles */
.adbnpro-banner {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
}

.adbnpro-banner img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Image with specific dimensions */
.adbnpro-banner img[style*="width"] {
    width: auto !important;
    max-width: 100% !important;
}

.adbnpro-banner img[style*="height"]:not([style*="auto"]) {
    object-fit: cover;
}

/* Lazy Loading Images */
.adbnpro-banner img.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.adbnpro-banner img.lazy.loaded {
    opacity: 1;
}

/* Image placeholders */
.adbnpro-image {
    background-color: #f0f0f0;
    min-height: 100px;
    object-fit: contain;
}

/* Ensure images respect container dimensions */
.adbnpro-content {
    width: 100%;
    height: 100%;
}

.adbnpro-content picture {
    display: block;
    width: 100%;
    height: 100%;
}

.adbnpro-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.adbnpro-content {
    position: relative;
}

.adbnpro-link {
    display: block;
    text-decoration: none;
}

/* Fixed Banner Styles */
.adbnpro-fixed {
    position: relative;
    display: block;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
}

/* Fixed banner with specific dimensions */
.adbnpro-fixed[style*="width"] {
    width: auto !important;
    display: inline-block;
}

.adbnpro-fixed[data-width] {
    max-width: attr(data-width);
}

.adbnpro-fixed .adbnpro-content {
    position: relative;
    width: 100%;
    height: 100%;
}

.adbnpro-fixed img {
    width: 100%;
    height: auto;
    display: block;
}

/* When banner has specific dimensions */
.adbnpro-fixed[style*="width"] img {
    max-width: 100%;
    height: auto;
}

.adbnpro-fixed[style*="height"] img {
    width: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Floating Banner Styles */
.adbnpro-floating {
    position: fixed;
    z-index: var(--adbnpro-z-index-floating, 9999);
    transition: all var(--adbnpro-animation-speed, 300ms) ease;
    /* Respetar dimensiones configuradas */
    width: var(--banner-width, auto);
    max-width: var(--banner-max-width, 400px);
    height: var(--banner-height, auto);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

/* Floating Banner Positions - Desktop */
.adbnpro-position-top-left {
    top: 20px;
    left: 20px;
}

.adbnpro-position-top-center {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.adbnpro-position-top-right {
    top: 20px;
    right: 20px;
}

.adbnpro-position-middle-left {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.adbnpro-position-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.adbnpro-position-middle-right {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.adbnpro-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.adbnpro-position-bottom-center {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.adbnpro-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

/* Legacy position support */
.adbnpro-position-top {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.adbnpro-position-bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.adbnpro-position-left {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.adbnpro-position-right {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

/* Close Button */
.adbnpro-close,
.adbnpro-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 100;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.adbnpro-close:hover,
.adbnpro-fullscreen-close:hover {
    background: rgba(255, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Fullscreen Banner */
.adbnpro-fullscreen,
.adbnpro-fullscreen-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--adbnpro-z-index-fullscreen, 99999);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Body overflow when fullscreen is active */
body.adbnpro-fullscreen-active {
    overflow: hidden;
}

.adbnpro-fullscreen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.adbnpro-fullscreen-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    z-index: 1;
}

.adbnpro-fullscreen-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

/* Timer Bar - Optimized and subtle */
.adbnpro-fullscreen-timer {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 4px;
    min-width: 150px;
    text-align: center;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.adbnpro-timer-text {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    display: block;
}

.adbnpro-timer-count {
    font-weight: bold;
    color: #007cba;
}

.adbnpro-timer-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin: 0;
}

.adbnpro-timer-progress {
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    transition: width linear;
    width: 100%;
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
}

/* Carousel Styles - Optimized for high quality */
.adbnpro-carousel,
.adbnpro-carousel-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.adbnpro-carousel-inner {
    position: relative;
    width: 100%;
    overflow: hidden;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.adbnpro-carousel-item {
    display: none;
    width: 100%;
    position: relative;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    will-change: opacity;
    transform: translateZ(0); /* GPU acceleration */
    backface-visibility: hidden; /* Fix flickering */
}

.adbnpro-carousel-item.active {
    display: block !important;
    opacity: 1 !important;
    z-index: 1;
}

/* Fade transition (default) */
.adbnpro-carousel[data-transition="fade"] .adbnpro-carousel-item {
    transition: opacity 0.4s ease-in-out;
}

/* Slide transition */
.adbnpro-carousel[data-transition="slide"] .adbnpro-carousel-item {
    transition: transform 0.4s ease-in-out, opacity 0.2s ease-in-out;
}

.adbnpro-carousel[data-transition="slide"] .adbnpro-carousel-item.next {
    transform: translateX(100%);
}

.adbnpro-carousel[data-transition="slide"] .adbnpro-carousel-item.prev {
    transform: translateX(-100%);
}

.adbnpro-carousel[data-transition="slide"] .adbnpro-carousel-item.active {
    transform: translateX(0);
}

/* Preload next slide */
.adbnpro-carousel-item.next {
    display: block;
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

.adbnpro-carousel-item img,
.adbnpro-carousel-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}

/* Remove caption styles - we don't want titles in carousel */

/* Hide all carousel controls - Multiple ads rotate automatically */
.adbnpro-carousel-control,
.adbnpro-carousel-prev,
.adbnpro-carousel-next,
.adbnpro-carousel-indicators,
.adbnpro-carousel-indicator {
    display: none !important;
}

/* Animations */
.adbnpro-animation-fade {
    animation: adbnpro-fade-in 0.5s ease;
}

.adbnpro-animation-slide {
    animation: adbnpro-slide-in 0.5s ease;
}

.adbnpro-animation-bounce {
    animation: adbnpro-bounce-in 0.6s ease;
}

.adbnpro-animation-zoom {
    animation: adbnpro-zoom-in 0.5s ease;
}

@keyframes adbnpro-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes adbnpro-slide-in {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes adbnpro-bounce-in {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes adbnpro-zoom-in {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Hide Animation */
.adbnpro-hiding {
    animation: adbnpro-fade-out 0.3s ease forwards;
}

@keyframes adbnpro-fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .adbnpro-floating-banner {
        max-width: calc(100% - 40px);
    }
    
    /* Mobile specific positions */
    .adbnpro-mobile-top {
        top: 10px !important;
        bottom: auto !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
    
    .adbnpro-mobile-bottom {
        bottom: 10px !important;
        top: auto !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
    
    .adbnpro-mobile-center {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
    
    .adbnpro-fullscreen-content {
        max-width: 100%;
        padding: 20px;
    }
    
    /* Carousel mobile optimizations */
    .adbnpro-carousel-control,
    .adbnpro-carousel-prev,
    .adbnpro-carousel-next {
        padding: 8px;
        font-size: 16px;
        min-width: 35px;
        height: 50px;
        background: rgba(0, 0, 0, 0.3);
    }
    
    .adbnpro-carousel-control[data-slide="prev"],
    .adbnpro-carousel-prev {
        left: 5px;
    }
    
    .adbnpro-carousel-control[data-slide="next"],
    .adbnpro-carousel-next {
        right: 5px;
    }
    
    .adbnpro-carousel-control-icon {
        font-size: 20px;
    }
    
    .adbnpro-carousel-indicators {
        bottom: 10px;
        gap: 5px;
    }
    
    .adbnpro-carousel-indicator {
        width: 8px;
        height: 8px;
    }
    
    /* Improve touch targets */
    .adbnpro-carousel-control,
    .adbnpro-carousel-indicator {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Optimize carousel images for mobile */
    .adbnpro-carousel-item img,
    .adbnpro-carousel-image {
        max-height: 70vh;
        object-fit: contain;
    }
}

/* Accessibility */
.adbnpro-banner:focus-within,
.adbnpro-floating-banner:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Loading State */
.adbnpro-loading {
    position: relative;
    min-height: 100px;
}

.adbnpro-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: adbnpro-spin 1s linear infinite;
}

@keyframes adbnpro-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Rotating Floating Banners */
.adbnpro-rotating-floating-container {
    position: fixed;
    z-index: var(--adbnpro-z-index-floating, 9999);
    /* Respetar dimensiones configuradas, con fallback a 400px */
    width: var(--banner-width, auto);
    max-width: var(--banner-max-width, 400px);
    height: var(--banner-height, auto);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.adbnpro-rotating-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

.adbnpro-rotating-item {
    display: none;
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.5s ease-in-out;
}

.adbnpro-rotating-item.active {
    display: block;
    opacity: 1;
    position: relative;
}

/* Optimización de imágenes SOLO para banners flotantes rotativos */
.adbnpro-rotating-floating-container .adbnpro-floating-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Mantener proporciones sin recorte */
    image-rendering: auto; /* Dejar que el navegador optimice la calidad */
    max-width: 100%;
    max-height: 100%;
}

/* Asegurar que el contenido use todo el espacio disponible */
.adbnpro-rotating-floating-container .adbnpro-floating-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.adbnpro-rotating-floating-container .adbnpro-link {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

/* Fade transition for rotating items */
.adbnpro-rotating-floating-container[data-transition="fade"] .adbnpro-rotating-item {
    transition: opacity 0.5s ease-in-out;
}

/* Slide transition for rotating items */
.adbnpro-rotating-floating-container[data-transition="slide"] .adbnpro-rotating-item {
    transition: transform 0.5s ease-in-out, opacity 0.3s ease-in-out;
}

.adbnpro-rotating-floating-container[data-transition="slide"] .adbnpro-rotating-item.next {
    transform: translateX(100%);
    opacity: 0;
}

.adbnpro-rotating-floating-container[data-transition="slide"] .adbnpro-rotating-item.prev {
    transform: translateX(-100%);
    opacity: 0;
}

.adbnpro-rotating-floating-container[data-transition="slide"] .adbnpro-rotating-item.active {
    transform: translateX(0);
    opacity: 1;
}

/* Rotation Indicators */
.adbnpro-rotating-indicators {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
}

.adbnpro-rotating-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.adbnpro-rotating-indicator:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: scale(1.2);
}

.adbnpro-rotating-indicator.active {
    background: white;
    width: 20px;
    border-radius: 4px;
}

/* OCULTAR INDICADORES SOLO EN BANNERS FLOTANTES ROTATIVOS */
.adbnpro-rotating-floating-container .adbnpro-rotating-indicators {
    display: none !important; /* Ocultar completamente los indicadores en flotantes */
}

/* Mobile optimizations for rotating floating banners */
@media (max-width: 768px) {
    .adbnpro-rotating-floating-container {
        max-width: calc(100% - 20px);
        margin: 10px;
    }
}

/* RTL Support */
[dir="rtl"] .adbnpro-close,
[dir="rtl"] .adbnpro-fullscreen-close {
    right: auto;
    left: 10px;
}

[dir="rtl"] .adbnpro-carousel-prev {
    left: auto;
    right: 10px;
}

[dir="rtl"] .adbnpro-carousel-next {
    right: auto;
    left: 10px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .adbnpro-close,
    .adbnpro-fullscreen-close {
        background: black;
        color: white;
        border: 2px solid white;
    }
    
    .adbnpro-carousel-prev,
    .adbnpro-carousel-next {
        background: black;
        border: 2px solid white;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .adbnpro-animation-fade,
    .adbnpro-animation-slide,
    .adbnpro-animation-bounce,
    .adbnpro-animation-zoom {
        animation: none;
    }
    
    .adbnpro-floating-banner,
    .adbnpro-fullscreen-banner {
        transition: none;
    }
}

/* SOLUCIÓN: Ocultar banners flotantes cuando posición está vacía (opción "No mostrar") */
/* Desktop: Ocultar cuando data-position-desktop está vacío */
.adbnpro-floating-banner[data-position-desktop=""],
.adbnpro-rotating-floating-container[data-position-desktop=""] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Tablet: Ocultar cuando data-position-tablet está vacío */
@media (min-width: 769px) and (max-width: 1024px) {
    .adbnpro-floating-banner[data-position-tablet=""],
    .adbnpro-rotating-floating-container[data-position-tablet=""] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Mobile: Ocultar cuando data-position-mobile está vacío */
@media (max-width: 768px) {
    .adbnpro-floating-banner[data-position-mobile=""],
    .adbnpro-rotating-floating-container[data-position-mobile=""] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Asegurar que la clase de posición vacía también oculte el banner */
.adbnpro-position- {
    display: none !important;
    visibility: hidden !important;
}

/* Advanced Image Sizing and Aspect Ratio Controls */
.adbnpro-banner[data-width] {
    width: auto;
    max-width: 100%;
}

.adbnpro-banner[data-height] {
    height: auto;
}

/* Container-based sizing */
.adbnpro-banner .adbnpro-content {
    display: inline-block;
    position: relative;
    max-width: 100%;
}

/* Responsive image sizing */
.adbnpro-banner img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* When specific dimensions are set via inline styles */
.adbnpro-banner[style*="width"] .adbnpro-content {
    width: 100%;
}

.adbnpro-banner[style*="height"]:not([style*="auto"]) .adbnpro-content {
    height: 100%;
}

/* Object-fit for different banner types */
.adbnpro-fixed img[style*="height"]:not([style*="auto"]) {
    object-fit: cover;
    width: 100%;
}

.adbnpro-floating img {
    object-fit: contain;
}

.adbnpro-carousel img {
    object-fit: cover;
    width: 100%;
}

/* Responsive sizing for high-quality images */
@media (max-width: 768px) {
    .adbnpro-banner[style*="width"] {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .adbnpro-banner img[style*="width"] {
        width: 100% !important;
        height: auto !important;
    }
}

/* Aspect ratio preservation */
.adbnpro-banner.aspect-16-9 {
    aspect-ratio: 16 / 9;
}

.adbnpro-banner.aspect-4-3 {
    aspect-ratio: 4 / 3;
}

.adbnpro-banner.aspect-1-1 {
    aspect-ratio: 1 / 1;
}

.adbnpro-banner.aspect-21-9 {
    aspect-ratio: 21 / 9;
}

/* Center images in their containers */
.adbnpro-banner .adbnpro-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.adbnpro-banner .adbnpro-content picture {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}