/**
 * AMH Unified Filter System Styles
 * 
 * Styles for all 4 unified filter widgets
 * 
 * @package AMH_Elementor_Widgets
 * @since 2.0.0
 */

/* ==========================================================================
   Loading Bar Styles
   ========================================================================== */

/* Optional: Add subtle overlay on loop during loading */
.amh-loop-wrapper.amh-loading {
    position: relative;
    pointer-events: none;
}

.amh-loop-wrapper.amh-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 10;
    transition: opacity 0.3s ease;
}

/* ==========================================================================
   Base Widget Styles
   ========================================================================== */

.amh-filter-widget {
    position: relative;
}

.amh-widget-content {
    position: relative;
}

/* ==========================================================================
   AMH Loop Widget Styles
   ========================================================================== */

.amh-loop-wrapper {
    --grid-columns: 3;
    width: 100%;
}

.amh-loop-items {
    display: grid !important;
    grid-template-columns: repeat(var(--grid-columns, 3), 1fr) !important;
    gap: 20px;
    align-items: start;
}

/* Responsive fallbacks for when Elementor applies responsive selectors */
@media (max-width: 1024px) {
    .amh-loop-wrapper {
        --grid-columns: var(--grid-columns-tablet, 2);
    }
}

@media (max-width: 767px) {
    .amh-loop-wrapper {
        --grid-columns: var(--grid-columns-mobile, 1);
    }
}

.amh-loop-wrapper.amh-equal .amh-loop-items {
    align-items: stretch !important;
}

.amh-loop-item {
    display: block;
    height: 100%;
}

/* When equal height is enabled, make each grid item a flex column so inner content can stretch */
.amh-loop-wrapper.amh-equal .amh-loop-item {
    display: flex;
    flex-direction: column;
}

/* Ensure Elementor template root does not break the item height */
.amh-loop-wrapper.amh-equal .amh-loop-item > .elementor,
.amh-loop-wrapper.amh-equal .amh-loop-item > .elementor > .elementor-element {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    flex: 1 1 auto;
    flex-wrap: nowrap;
}

/* Some Elementor templates wrap content in section/column structures. Ensure they stretch as well */
.amh-loop-wrapper.amh-equal .elementor-section,
.amh-loop-wrapper.amh-equal .elementor-container,
.amh-loop-wrapper.amh-equal .elementor-row,
.amh-loop-wrapper.amh-equal .elementor-column,
.amh-loop-wrapper.amh-equal .elementor-widget-wrap {
    height: 100%;
}

.amh-loop-thumb {
    width: 100%;
    margin-bottom: 15px;
}

.amh-loop-thumb img {
    width: 100%;
    height: auto;
    display: block;
}

.amh-loop-title {
    margin: 0 0 10px;
    font-size: 20px;
    line-height: 1.4;
}

.amh-loop-title a {
    text-decoration: none;
    color: inherit;
}


.amh-pagination {
    margin-top: 30px;
    text-align: center;
}

.amh-pagination .page-numbers {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 5px;
}

.amh-pagination .page-numbers li {
    display: inline-block;
}

.amh-pagination .page-numbers a,
.amh-pagination .page-numbers span {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
}

.amh-pagination .page-numbers a:hover {
    background-color: #f5f5f5;
    border-color: #999;
}

.amh-pagination .page-numbers .current {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* ==========================================================================
   Search Filter Widget Styles
   ========================================================================== */

.amh-search-filter {
    position: relative;
    width: 100%;
}

.amh-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.amh-search-field {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1.4;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.amh-search-field:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.amh-search-field::placeholder {
    color: #999;
}

.amh-search-button {
    padding: 12px 20px;
    border: 1px solid #007cba;
    border-radius: 4px;
    background-color: #007cba;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-family: inherit;
}

.amh-search-button:hover {
    background-color: #005a87;
    border-color: #005a87;
}

.amh-search-button:active {
    transform: translateY(1px);
}

/* Legacy class names for backward compatibility */
.amh-search-filter-widget .amh-search-form {
    position: relative;
}

.amh-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.amh-search-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1.4;
    transition: border-color 0.3s ease;
}

.amh-search-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.amh-clear-button {
    padding: 12px 20px;
    border: 1px solid #6c757d;
    border-radius: 4px;
    background-color: #6c757d;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.amh-clear-button:hover {
    background-color: #545b62;
    border-color: #545b62;
}

/* ==========================================================================
   Taxonomy Filters Widget Styles
   ========================================================================== */

.amh-taxonomy-filters-widget .amh-taxonomy-section {
    margin-bottom: 24px;
}

.amh-taxonomy-section:last-child {
    margin-bottom: 0;
}

.amh-taxonomy-heading {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body .amh-taxonomy-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

body .amh-taxonomy-button {
    padding: 5px 15px;
    border: 1px solid #5c2d91;
    border-radius: 20px;
    background-color: #fff;
    color: #5c2d91;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: initial;
}

body .amh-taxonomy-button:hover,
body .amh-taxonomy-button.active {
    background-color: #5c2d91;
    color: #fff;
}

/* ==========================================================================
   Filter Counter Widget Styles
   ========================================================================== */

.amh-filter-counter-widget .amh-filter-counter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f8f9fa;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.amh-filter-count-number {
    font-weight: 600;
    color: #007cba;
}

/* ==========================================================================
   Reset Button Widget Styles
   ========================================================================== */

.amh-reset-button-widget .amh-reset-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid #dc3545;
    border-radius: 4px;
    background-color: #dc3545;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.amh-reset-button:hover {
    background-color: #c82333;
    border-color: #c82333;
}

.amh-reset-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

.amh-button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.amh-button-text {
    display: inline-block;
}

/* ==========================================================================
   Loading Animation Styles
   ========================================================================== */

.amh-unified-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 999999;
    opacity: 0;
    background: var(--e-global-color-accent);
    visibility: hidden;
}

.amh-unified-loader.active {
    opacity: 1;
    visibility: visible;
}

.amh-loader-bar {
    width: 100%;
    height: 7px;
    position: relative;
    background: linear-gradient(
        to right, 
        var(--e-global-color-accent) 0%,
        var(--e-global-color-secondary) 20%,
        var(--e-global-color-5b8171d) 40%,  
        var(--e-global-color-secondary) 60%,
        var(--e-global-color-accent) 100%
    );
    animation: amh-loader-progress 1.5s cubic-bezier(0.15, 0.65, 0.95, 0.5) infinite;
}

/* Animation */
@keyframes amh-loader-progress {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Loading states for widgets */
.amh-taxonomy-filters.amh-loading {
    opacity: 0.7;
    pointer-events: none;
}

.amh-taxonomy-filters.amh-loading .amh-taxonomy-button {
    opacity: 0.5;
}

.amh-search-filter.amh-loading {
    opacity: 0.7;
    pointer-events: none;
}

.amh-search-filter.amh-loading .amh-search-field {
    opacity: 0.5;
}

.amh-reset-button.amh-loading {
    opacity: 0.7;
    pointer-events: none;
    cursor: not-allowed;
}

.elementor-widget-loop-grid.amh-loading {
    position: relative;
}

.elementor-widget-loop-grid.amh-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.elementor-widget-loop-grid.amh-loading::before {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    font-size: 14px;
    color: #007cba;
    font-weight: 500;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .amh-search-input-wrapper {
        flex-direction: column;
        gap: 8px;
    }
    
    .amh-search-input {
        width: 100%;
    }
    
    .amh-search-button,
    .amh-clear-button {
        width: 100%;
        justify-content: center;
    }
    
    .amh-taxonomy-buttons {
        gap: 6px;
    }
    
    .amh-taxonomy-button {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .amh-reset-button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .amh-taxonomy-buttons {
        flex-direction: column;
        gap: 4px;
    }
    
    .amh-taxonomy-button {
        width: 100%;
        text-align: center;
    }
}