/* ========================================
   WC Dynamic Search Menu - Frontend Styles
   ======================================== */

/* Main Wrapper - CONFIGURACIÓN CRÍTICA PARA ELEMENTOR */
.wc-dsm-menu-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0px;
    overflow: visible;
    clear: both;
    position: relative;
    z-index: 1;
    display: block !important;
    min-height: fit-content !important;
    height: auto !important;
}

/* Forzar que el wrapper respete su contenido en contenedores flex */
.wc-dsm-menu-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* Tabs Navigation */
.wc-dsm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    padding: 0;
    list-style: none;
    border-bottom: 2px solid #e0e0e0;
}

/* CRÍTICO: Mayor especificidad para sobrescribir Elementor */
.wc-dsm-menu-wrapper .wc-dsm-tabs .wc-dsm-tab,
.wc-dsm-menu-wrapper button.wc-dsm-tab {
    /* Resetear estilos de Elementor/Theme */
    all: unset;
    
    /* Aplicar estilos del plugin */
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    
    /* Usar padding global con fallback */
    padding-top: var(--global-tab-padding-top, 12px) !important;
    padding-right: var(--global-tab-padding-right, 24px) !important;
    padding-bottom: var(--global-tab-padding-bottom, 12px) !important;
    padding-left: var(--global-tab-padding-left, 24px) !important;
    
    /* Variables CSS para colores */
    background: var(--bg-color-default, transparent) !important;
    
    /* Bordes con variables CSS */
    border-top-width: var(--border-width-top, 0px) !important;
    border-top-style: var(--border-style, solid) !important;
    border-top-color: var(--border-color-default, transparent) !important;
    
    border-right-width: var(--border-width-right, 0px) !important;
    border-right-style: var(--border-style, solid) !important;
    border-right-color: var(--border-color-default, transparent) !important;
    
    border-bottom-width: var(--border-width-bottom, 3px) !important;
    border-bottom-style: var(--border-style, solid) !important;
    border-bottom-color: var(--border-color-default, transparent) !important;
    
    border-left-width: var(--border-width-left, 0px) !important;
    border-left-style: var(--border-style, solid) !important;
    border-left-color: var(--border-color-default, transparent) !important;
    
    /* Color de texto */
    color: var(--text-color-default, #333) !important;
    
    /* Tipografía con valor global */
    font-size: var(--global-tab-font-size, 16px) !important;
    font-weight: var(--text-weight, 500) !important;
    font-family: inherit !important;
    line-height: normal !important;
    text-align: center !important;
    text-decoration: none !important;
    
    /* Dimensiones */
    width: var(--tab-width, auto) !important;
    height: var(--tab-height, auto) !important;
    min-width: fit-content !important;
    box-sizing: border-box !important;
    
    /* Comportamiento */
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    bottom: -2px !important;
    
    /* Resetear márgenes y padding no deseados */
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    vertical-align: baseline !important;
}

/* Estado hover */
.wc-dsm-menu-wrapper .wc-dsm-tabs .wc-dsm-tab:hover,
.wc-dsm-menu-wrapper button.wc-dsm-tab:hover {
    color: var(--text-color-hover, #00a699) !important;
    background: var(--bg-color-hover, rgba(0, 166, 153, 0.05)) !important;
    border-top-color: var(--border-color-hover, transparent) !important;
    border-right-color: var(--border-color-hover, transparent) !important;
    border-bottom-color: var(--border-color-hover, transparent) !important;
    border-left-color: var(--border-color-hover, transparent) !important;
    transform: none !important;
}

/* Estado active */
.wc-dsm-menu-wrapper .wc-dsm-tabs .wc-dsm-tab.active,
.wc-dsm-menu-wrapper button.wc-dsm-tab.active {
    color: var(--text-color-active, #00a699) !important;
    background: var(--bg-color-active, transparent) !important;
    border-top-color: var(--border-color-active, transparent) !important;
    border-right-color: var(--border-color-active, transparent) !important;
    border-bottom-color: var(--border-color-active, #00a699) !important;
    border-left-color: var(--border-color-active, transparent) !important;
}

/* Icono del tab */
.wc-dsm-tab-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--global-tab-svg-size, 24px) !important;
    height: var(--global-tab-svg-size, 24px) !important;
    flex-shrink: 0 !important;
}

.wc-dsm-tab-icon svg {
    width: 100% !important;
    height: 100% !important;
    fill: currentColor !important;
}

/* Texto del tab */
.wc-dsm-tab-text {
    white-space: nowrap !important;
}

/* Tab Description */
.wc-dsm-tab-description-wrapper {
    text-align: center;
    margin-top: 0;
    margin-bottom: var(--description-margin-top, 20px);
    min-height: 24px;
}

.wc-dsm-tab-description {
    display: none;
    font-size: var(--description-font-size, 16px);
    color: var(--description-color, #666666);
    font-weight: var(--description-font-weight, 400);
    line-height: 1.5;
    margin: 0;
    padding: 0 20px;
    animation: fadeInDescription 0.4s ease;
}

.wc-dsm-tab-description.active {
    display: block;
}

@keyframes fadeInDescription {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para descripción */
@media screen and (max-width: 768px) {
    .wc-dsm-tab-description {
        font-size: calc(var(--description-font-size, 16px) * 0.875);
        padding: 0 15px;
    }
    
    .wc-dsm-tab-description-wrapper {
        margin-bottom: calc(var(--description-margin-top, 20px) * 0.75);
    }
}

@media screen and (max-width: 480px) {
    .wc-dsm-tab-description {
        font-size: calc(var(--description-font-size, 16px) * 0.75);
    }
}

/* Tab Contents */
.wc-dsm-tab-contents {
    position: relative;
    min-height: 400px;
    clear: both;
    overflow: visible;
    display: block !important;
}

.wc-dsm-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
    clear: both;
    overflow: visible;
}

.wc-dsm-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Wrapper */
.wc-dsm-search-wrapper {
    position: relative;
    margin-bottom: 30px;
    max-width: 800px;
    /* Usar la variable de posición */
    margin-left: var(--search-position-margin-left);
    margin-right: var(--search-position-margin-right);
}

/* Clases auxiliares para posicionamiento */
.wc-dsm-tab-content[style*="--search-position: left"] .wc-dsm-search-wrapper {
    --search-position-margin-left: 0;
    --search-position-margin-right: auto;
}

.wc-dsm-tab-content[style*="--search-position: center"] .wc-dsm-search-wrapper {
    --search-position-margin-left: auto;
    --search-position-margin-right: auto;
}

.wc-dsm-tab-content[style*="--search-position: right"] .wc-dsm-search-wrapper {
    --search-position-margin-left: auto;
    --search-position-margin-right: 0;
}

.wc-dsm-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.wc-dsm-search-input-wrapper:focus-within {
    border-color: var(--search-focus-color, #00a699);
    box-shadow: 0 4px 12px rgba(0, 166, 153, 0.15);
}

.wc-dsm-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    color: #666;
}

.wc-dsm-search-input {
    flex: 1;
    padding: 16px 20px 16px 0;
    border: none;
    outline: none;
    font-size: 16px;
    color: #333;
    background: transparent;
}

.wc-dsm-search-input::placeholder {
    color: #999;
}

/* Search Results Dropdown */
.wc-dsm-search-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    max-height: 400px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.wc-dsm-search-result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.wc-dsm-search-result-item:hover {
    background: #f9f9f9;
}

.wc-dsm-search-result-item:last-child {
    border-bottom: none;
}

.wc-dsm-search-result-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.wc-dsm-search-result-info {
    flex: 1;
    min-width: 0;
}

.wc-dsm-search-result-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wc-dsm-search-result-meta {
    font-size: 13px;
    color: #666;
}

.wc-dsm-search-no-results {
    padding: 30px 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

.wc-dsm-search-loading {
    padding: 30px 20px;
    text-align: center;
}

/* Products Grid */
.wc-dsm-products-wrapper {
    position: relative;
    clear: both;
    overflow: visible;
    display: block !important;
}

.wc-dsm-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
    clear: both;
}

/* Clearfix para el grid */
.wc-dsm-products-grid::after {
    content: "";
    display: table;
    clear: both;
}

.wc-dsm-product-card {
    background: var(--global-product-card-bg, #fff);
    border: var(--global-product-card-border-width, 1px) solid var(--global-product-card-border-color, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    margin-bottom: 0;
}

.wc-dsm-product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--global-product-card-hover-shadow, 0 8px 20px rgba(0, 0, 0, 0.1));
    border-width: var(--global-product-card-hover-border-width, 1px);
    border-color: var(--global-product-card-hover-border-color, #00a699);
}

.wc-dsm-product-image-wrapper {
    position: relative;
    padding-top: 100%;
    overflow: hidden;
    background: #f5f5f5;
}

.wc-dsm-product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.wc-dsm-product-card:hover .wc-dsm-product-image {
    transform: scale(1.05);
}

.wc-dsm-product-info {
    padding: 20px;
}

.wc-dsm-product-categories {
    font-size: 12px;
    color: var(--global-product-category-color, #00a699);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
    transition: color 0.3s ease;
}

.wc-dsm-product-card:hover .wc-dsm-product-categories {
    color: var(--global-product-category-hover-color, #008c7f);
}

.wc-dsm-product-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--global-product-title-color, #333);
    margin: 0 0 10px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wc-dsm-product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--global-product-price-color, #333);
    margin: 10px 0;
}

.wc-dsm-product-price del {
    font-size: 14px;
    color: #999;
    margin-right: 8px;
}

.wc-dsm-product-price ins {
    text-decoration: none;
    color: var(--global-product-category-color, #00a699);
}

.wc-dsm-product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #666;
}

.wc-dsm-product-rating .star-rating {
    margin: 0;
}

/* Loading State */
.wc-dsm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.wc-dsm-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top-color: #00a699;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.wc-dsm-loading p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

/* Pagination */
.wc-dsm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
    clear: both;
}

.wc-dsm-pagination-button {
    padding: 10px 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wc-dsm-pagination-button:hover:not(:disabled) {
    background: var(--pagination-hover-color, #00a699);
    color: #fff;
    border-color: var(--pagination-hover-color, #00a699);
}

.wc-dsm-pagination-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wc-dsm-pagination-button.active {
    background: var(--pagination-active-color, #00a699);
    color: #fff;
    border-color: var(--pagination-active-color, #00a699);
}

.wc-dsm-pagination-ellipsis {
    padding: 10px 5px;
    color: #999;
}

.wc-dsm-pagination-info {
    padding: 10px 20px;
    font-size: 14px;
    color: #666;
}

/* ============================================
   RESPONSIVE MOBILE STYLES - LIMPIO
   Solo propiedades técnicas, sin padding/margin bottom
   ============================================ */

@media screen and (max-width: 768px) {
    /* CRÍTICO: Forzar comportamiento de bloque en móviles */
    .wc-dsm-menu-wrapper {
        display: block !important;
        position: relative !important;
        z-index: 10 !important;
        padding: 15px !important;
        overflow: visible !important;
        clear: both !important;
        min-height: fit-content !important;
        height: auto !important;
        flex: none !important;
        flex-grow: 0 !important;
        flex-shrink: 0 !important;
        align-self: stretch !important;
    }
    
    /* Asegurar que el clearfix funcione - SIN altura adicional */
    .wc-dsm-menu-wrapper::after {
        content: "" !important;
        display: block !important;
        clear: both !important;
        visibility: hidden !important;
    }
    
    .wc-dsm-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        margin-bottom: 30px !important;
    }
    
    .wc-dsm-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .wc-dsm-menu-wrapper .wc-dsm-tabs .wc-dsm-tab,
    .wc-dsm-menu-wrapper button.wc-dsm-tab {
        padding-top: calc(var(--global-tab-padding-top, 12px) * 0.83) !important;
        padding-right: calc(var(--global-tab-padding-right, 24px) * 0.67) !important;
        padding-bottom: calc(var(--global-tab-padding-bottom, 12px) * 0.83) !important;
        padding-left: calc(var(--global-tab-padding-left, 24px) * 0.67) !important;
        font-size: calc(var(--global-tab-font-size, 16px) * 0.875) !important;
    }
    
    .wc-dsm-tab-icon {
        width: calc(var(--global-tab-svg-size, 24px) * 0.875) !important;
        height: calc(var(--global-tab-svg-size, 24px) * 0.875) !important;
    }
    
    .wc-dsm-tab-contents {
        display: block !important;
        clear: both !important;
        overflow: visible !important;
        min-height: 400px !important;
        position: relative !important;
    }
    
    .wc-dsm-tab-content {
        display: block !important;
        clear: both !important;
        overflow: visible !important;
        position: relative !important;
    }
    
    .wc-dsm-tab-content:not(.active) {
        display: none !important;
    }
    
    .wc-dsm-products-wrapper {
        display: block !important;
        clear: both !important;
        overflow: visible !important;
        position: relative !important;
    }
    
    .wc-dsm-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
        clear: both !important;
        display: grid !important;
    }
    
    .wc-dsm-product-card {
        margin-bottom: 0 !important;
    }
    
    .wc-dsm-product-info {
        padding: 15px;
    }
    
    .wc-dsm-product-name {
        font-size: 14px;
    }
    
    .wc-dsm-product-price {
        font-size: 16px;
    }
    
    .wc-dsm-pagination {
        margin-top: 15px !important;
        clear: both !important;
        position: relative !important;
    }
    
    .wc-dsm-pagination-button {
        padding: 8px 16px;
        font-size: 13px;
    }
}

@media screen and (max-width: 480px) {
    .wc-dsm-menu-wrapper {
        padding: 10px !important;
    }
    
    .wc-dsm-products-grid {
        grid-template-columns: 1fr;
    }
    
    .wc-dsm-search-input {
        font-size: 14px;
    }
}

/* Empty State */
.wc-dsm-no-products {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.wc-dsm-no-products p {
    font-size: 16px;
    margin: 0;
}

/* Accessibility */
.wc-dsm-menu-wrapper .wc-dsm-tabs .wc-dsm-tab:focus,
.wc-dsm-menu-wrapper button.wc-dsm-tab:focus,
.wc-dsm-search-input:focus,
.wc-dsm-pagination-button:focus {
    outline: var(--focus-outline-width, 2px) var(--focus-outline-style, solid) var(--focus-outline-color, #00a699) !important;
    outline-offset: 2px !important;
}

/* Print Styles */
@media print {
    .wc-dsm-tabs,
    .wc-dsm-search-wrapper,
    .wc-dsm-pagination {
        display: none;
    }
}
