/**
 * AO Search App - Minimal Structural CSS Only
 * ALL styling is applied via React inline styles from Design Admin settings
 * This file contains ONLY layout and structural CSS, no visual styling
 * 
 * @package Instant_Alter_Search
 * @version 5.0.0 - React-Driven Styling + Native Dialog
 */

/* ========================================
   Native HTML5 Dialog Modal
   Clean, single scrollbar implementation
   ALL SIZING controlled by JavaScript from admin settings
======================================== */
#ao-search-dialog {
    /* HIDDEN STATE - when [open] attribute is not present */
    display: none !important;
    visibility: hidden !important;
    position: fixed !important;
    top: -999999px !important;
    left: -999999px !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
    background: transparent !important;
    opacity: 0 !important;
    z-index: -999999 !important;
}

#ao-search-dialog[open] {
    /* VISIBLE STATE - when [open] attribute is present */
    /* NOTE: width, height, max-width, max-height controlled by JavaScript */
    display: flex !important;
    visibility: visible !important;
    position: fixed !important;
    inset: 0 !important;
    margin: auto !important;
    padding: 0 !important;
    border: none !important;
    flex-direction: column !important;
    font-family: inherit !important;
    overflow: hidden !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    z-index: 9999 !important;
}

/* Prevent body scroll when dialog is open */
html:has(#ao-search-dialog[open]),
body:has(#ao-search-dialog[open]) {
    overflow: hidden !important;
}

/* Dialog backdrop - native browser support
   NOTE: Dynamic backdrop styles are set via JavaScript (#ao-backdrop-style)
   based on admin settings for color, opacity, and blur */
#ao-search-dialog::backdrop {
    /* Fallback only - overridden by JavaScript */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Root container inside dialog */
#ao-search-root {
    /* Padding controlled by JavaScript from modalContentPadding settings */
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

/* ========================================
   Overlay - Full Screen Layout (Deprecated - for compatibility)
======================================== */
.ao-search-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    z-index: 999999;
    overflow: hidden;
}

.ao-search-overlay.visible {
    display: flex;
}

.ao-search-overlay.hidden {
    display: none;
}

/* ========================================
   Search Header - Structural Only
======================================== */
.ao-search-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    overflow: visible;
}

.ao-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: inherit;
}

.ao-search-input:focus {
    outline: none;
    border: none;
}

/* Focus handled by JavaScript dynamic styles */

/* ========================================
   Filters Sidebar
======================================== */
.ao-search-filters {
    flex: 0 0 auto;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(0,0,0,0.1);
}

/* ========================================
   Results Area - Structural
======================================== */
.ao-search-results {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.ao-search-hits {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Grid Layout - CRITICAL
======================================== */
.ao-instant-grid {
    display: grid;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    box-sizing: border-box;
    overflow: visible;
    /* grid-template-columns and gap set via React inline styles */
}

/* Force grid children to respect grid cell boundaries */
.ao-instant-grid > * {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* ========================================
   Product Card - Structural Only
======================================== */
.ao-product-card {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    /* All styling (bg, border, shadow, padding, border-radius) from React inline styles */
}

.ao-product-image {
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
    /* Aspect ratio and styling from React inline styles */
}

.ao-product-image img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

.ao-product-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    /* Padding, background, color from React inline styles */
}

.ao-product-title {
    margin: 0;
    padding: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Font size, weight, color, line-clamp from React inline styles */
}

.ao-product-button {
    display: inline-block;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    /* Background, color, padding, border-radius, font-size, transition from React inline styles */
}

/* ========================================
   Badges - Structural
======================================== */
.ao-sale-badge,
.ao-new-badge {
    position: absolute;
    font-weight: 700;
    font-size: 11px;
    /* Background, color, padding, border-radius, positioning from React inline styles */
}

/* ========================================
   Filter Elements - Structural
======================================== */
.ao-filter-group {
    border-bottom: 1px solid rgba(0,0,0,0.1);
    /* Padding, background from React inline styles */
}

.ao-filter-title {
    margin: 0;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    /* Font styling from React inline styles */
}

.ao-filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Padding from React inline styles */
}

.ao-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.ao-filter-checkbox input[type="checkbox"] {
    cursor: pointer;
}

/* ========================================
   Utilities
======================================== */
.ao-hidden {
    display: none !important;
}

.ao-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ao-loading-spinner {
    display: inline-block;
    animation: ao-spin 1s linear infinite;
}

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

/* ========================================
   Responsive - Only layout adjustments
   Specific column counts set via React inline styles
======================================== */

@media (max-width: 768px) {
    .ao-search-overlay {
        position: fixed;
        inset: 0;
    }
    
    .ao-search-filters {
        border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.1);
        max-height: 200px;
    }
}

/* ========================================
   Native Modal - Inherit WoodMart theme styling
======================================== */
#ao-native-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: block;
    background: white;
}

/* Native modal container - WoodMart classes for theme integration */
.ao-search-native-modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================
   Dialog Content Structure
======================================== */
.ao-search-wrapper {
    flex: 0 0 auto;
    overflow: visible;
    width: 100%;
    border-radius: 0 !important;
}

.ao-search-wrapper.ao-restoring-scroll {
    pointer-events: none;
}

/* Search topbar */
.ao-search-topbar {
    flex-shrink: 0;
    width: 100%;
    position: relative;
    z-index: 10;
    overflow: visible;
}

/* Search body */
.ao-search-body {
    flex: 1;
    overflow: hidden;
    width: 100%;
}

.wd-search-results-wrapper {
    scroll-behavior: auto !important;
    overflow-anchor: auto;
}

/* Search input styling - inherit from WoodMart but apply custom colors */
#ao-native-search-modal .s.wd-search-inited {
    width: 100%;
    padding: 12px 16px;
    height: 48px;
    box-sizing: border-box;
    font-size: 16px;
    border-width: 1px;
    border-style: solid;
}

/* Close button */
#ao-native-search-modal .ao-search-close-btn {
    z-index: 10001;
    transition: all 0.2s ease;
}

/* Print styles
======================================== */
@media print {
    .ao-search-overlay {
        display: none !important;
    }
}

