/**
 * WOA Search Modal - Styles
 * 
 * Full-screen modal search with WooCommerce product styling.
 * 
 * @package WebtronAuctionSite
 * @since 2.0.0
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    /* Modal colors - Light Mode */
    --woa-modal-bg: rgba(0, 0, 0, 0.5);
    --woa-modal-content-bg: #ffffff;
    --woa-modal-border: #e5e5e5;
    --woa-modal-text: #1a1a1a;
    --woa-modal-text-muted: #666666;
    --woa-modal-accent: #8b0000;
    --woa-modal-accent-light: rgba(139, 0, 0, 0.1);
    --woa-modal-hover-bg: #f5f5f5;
    --woa-modal-input-bg: #fafafa;
    
    /* Sizing */
    --woa-modal-max-width: 720px;
    --woa-modal-max-height: 80vh;
    --woa-modal-border-radius: 16px;
}


/* ============================================
   SEARCH TRIGGER BUTTON
   ============================================ */
.woa-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    color: #666666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.woa-search-trigger:hover {
    background: #fafafa;
    border-color: #cccccc;
    color: #333333;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.woa-search-trigger__icon {
    flex-shrink: 0;
    opacity: 0.5;
}

.woa-search-trigger__text {
    flex: 1;
    text-align: left;
}

.woa-search-trigger__kbd {
    display: flex;
    gap: 4px;
}

.woa-search-trigger__kbd kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #555555;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Compact variant */
.woa-search-trigger--compact {
    padding: 8px 12px;
    min-width: auto;
}

.woa-search-trigger--compact .woa-search-trigger__text {
    display: none;
}

/* Icon-only variant */
.woa-search-trigger--icon-only {
    padding: 10px;
    min-width: auto;
    border-radius: 50%;
}

.woa-search-trigger--icon-only .woa-search-trigger__text,
.woa-search-trigger--icon-only .woa-search-trigger__kbd {
    display: none;
}


/* ============================================
   MODAL BACKDROP
   ============================================ */
.woa-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 20px 20px;
    background: var(--woa-modal-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.woa-modal--open {
    opacity: 1;
    visibility: visible;
}

body.woa-modal-open {
    overflow: hidden;
}


/* ============================================
   MODAL CONTENT CONTAINER
   ============================================ */
.woa-modal__content {
    width: 100%;
    max-width: var(--woa-modal-max-width);
    max-height: var(--woa-modal-max-height);
    background: var(--woa-modal-content-bg);
    border: 1px solid var(--woa-modal-border);
    border-radius: var(--woa-modal-border-radius);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 10px 20px -5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(-10px);
    transition: transform 0.2s ease;
}

.woa-modal--open .woa-modal__content {
    transform: scale(1) translateY(0);
}


/* ============================================
   MODAL HEADER / SEARCH INPUT
   ============================================ */
.woa-modal__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--woa-modal-input-bg);
    border-bottom: 1px solid var(--woa-modal-border);
}

.woa-modal__icon {
    flex-shrink: 0;
    color: var(--woa-modal-text-muted);
}

.woa-modal__input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 18px;
    font-weight: 400;
    color: var(--woa-modal-text);
    caret-color: var(--woa-modal-accent);
}

.woa-modal__input::placeholder {
    color: #999999;
}

.woa-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    background: #f0f0f0;
    border: 1px solid var(--woa-modal-border);
    border-radius: 6px;
    color: var(--woa-modal-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.woa-modal__close:hover {
    background: #e5e5e5;
    color: var(--woa-modal-text);
}

.woa-modal__close kbd {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    font-weight: 500;
    text-transform: lowercase;
}


/* ============================================
   INCLUDE SOLD TOGGLE
   ============================================ */
.woa-search-modal__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #fafafa;
    border-bottom: 1px solid var(--woa-modal-border);
}

.woa-search-modal__toggle-control {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--woa-modal-text-muted);
    user-select: none;
    outline: none;
}

.woa-search-modal__toggle-control:focus-visible .woa-search-modal__toggle-switch {
    box-shadow: 0 0 0 2px var(--woa-modal-accent);
}

.woa-search-modal__toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: #cccccc;
    border-radius: 10px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.woa-search-modal__toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

/* Active state (checked) */
.woa-search-modal__toggle-control--active .woa-search-modal__toggle-switch {
    background: var(--woa-modal-accent);
}

.woa-search-modal__toggle-control--active .woa-search-modal__toggle-switch::after {
    transform: translateX(16px);
}

.woa-search-modal__toggle-text {
    line-height: 1.4;
    color: #000000;
    font-weight: 600;
}


/* ============================================
   MODAL BODY
   ============================================ */
.woa-modal__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 300px;
    max-height: 55vh;
}


/* ============================================
   LOADING STATE
   ============================================ */
.woa-modal__loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--woa-modal-text-muted);
    font-size: 14px;
}

.woa-modal--loading .woa-modal__loading {
    display: flex;
}

.woa-modal--loading .woa-modal__empty,
.woa-modal--loading .woa-modal__results {
    display: none;
}

.woa-modal__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e5e5;
    border-top-color: var(--woa-modal-accent);
    border-radius: 50%;
    animation: woa-spin 0.8s linear infinite;
}

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


/* ============================================
   EMPTY STATE
   ============================================ */
.woa-modal__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.woa-modal__empty-icon {
    margin-bottom: 16px;
    color: #cccccc;
}

.woa-modal__empty-text {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 500;
    color: var(--woa-modal-text);
}

.woa-modal__empty-hint {
    margin: 0;
    font-size: 13px;
    color: var(--woa-modal-text-muted);
}


/* ============================================
   SEARCH RESULTS
   ============================================ */
.woa-modal__results {
    padding: 8px;
}

.woa-modal__results:empty {
    display: none;
}


/* ============================================
   RESULT ITEM - PRODUCT CARD STYLE
   ============================================ */
.woa-modal__result {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--woa-modal-text);
    transition: background 0.15s ease;
    border: 1px solid transparent;
}

.woa-modal__result:hover,
.woa-modal__result.woa-modal__result--focused {
    background: #f8f8f8;
    border-color: #e5e5e5;
}

/* Product Image */
.woa-modal__result-image {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
}

.woa-modal__result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Product Content */
.woa-modal__result-content {
    flex: 1;
    min-width: 0;
}

.woa-modal__result-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.woa-modal__result-title mark {
    background: rgba(255, 215, 0, 0.4);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

.woa-modal__result-excerpt {
    font-size: 13px;
    color: var(--woa-modal-text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.woa-modal__result-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Price */
.woa-modal__result-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--woa-modal-accent);
}

.woa-modal__result-price del {
    color: #999999;
    font-weight: 400;
    margin-right: 6px;
}

/* Category */
.woa-modal__result-category {
    display: inline-block;
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    color: #666666;
    font-size: 11px;
    font-weight: 500;
}

/* Stock Badge */
.woa-modal__result-stock {
    flex-shrink: 0;
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.woa-modal__result-stock.in-stock {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.woa-modal__result-stock.sold {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}


/* ============================================
   NO RESULTS
   ============================================ */
.woa-modal__no-results {
    padding: 60px 20px;
    text-align: center;
    color: var(--woa-modal-text-muted);
    font-size: 14px;
}


/* ============================================
   VIEW ALL LINK
   ============================================ */
.woa-modal__view-all {
    display: block;
    padding: 12px 16px;
    margin: 8px;
    background: #fafafa;
    border: 1px solid var(--woa-modal-border);
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    color: var(--woa-modal-text);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.woa-modal__view-all:hover {
    background: #f0f0f0;
    border-color: var(--woa-modal-accent);
    color: var(--woa-modal-accent);
}

.woa-modal__view-all span {
    color: var(--woa-modal-text-muted);
    font-weight: 400;
}


/* ============================================
   MODAL FOOTER
   ============================================ */
.woa-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--woa-modal-border);
    background: #fafafa;
    font-size: 12px;
    color: var(--woa-modal-text-muted);
}

.woa-modal__footer-shortcuts {
    display: flex;
    gap: 16px;
}

.woa-modal__footer-shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
}

.woa-modal__footer-shortcut span {
    color: #000000;
    font-weight: 600;
}

.woa-modal__footer-shortcut kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 10px;
    color: #888888;
}

/* Close button X icon - hidden on desktop */
.woa-modal__close-icon {
    display: none;
}


/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet and below */
@media (max-width: 768px) {
    .woa-modal {
        padding: 5vh 12px 12px;
    }
    
    .woa-modal__content {
        max-height: 90vh;
        border-radius: 12px;
    }
    
    .woa-modal__header {
        padding: 14px 16px;
    }
    
    .woa-modal__input {
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .woa-search-modal__toggle {
        padding: 10px 16px;
    }
    
    .woa-modal__body {
        max-height: 60vh;
    }
    
    .woa-modal__results {
        padding: 6px;
    }
    
    .woa-modal__result {
        padding: 10px;
        gap: 12px;
    }
    
    .woa-modal__result-image {
        width: 56px;
        height: 56px;
    }
    
    .woa-modal__result-title {
        font-size: 14px;
    }
    
    .woa-modal__result-excerpt {
        font-size: 12px;
        -webkit-line-clamp: 1;
        line-clamp: 1;
    }
    
    .woa-modal__result-meta {
        gap: 6px;
    }
    
    .woa-modal__result-price {
        font-size: 13px;
    }
    
    .woa-modal__result-stock {
        padding: 3px 8px;
        font-size: 10px;
    }
    
    .woa-modal__footer {
        padding: 10px 16px;
    }
    
    .woa-modal__footer-shortcuts {
        gap: 12px;
    }
    
    /* Hide keyboard shortcuts on mobile/touch devices */
    .woa-modal__footer-shortcuts {
        display: none;
    }
    
    /* Show X icon, hide esc kbd on mobile */
    .woa-modal__close-kbd {
        display: none;
    }
    
    .woa-modal__close-icon {
        display: block;
        color: #666666;
    }
    
    .woa-modal__close:hover .woa-modal__close-icon {
        color: #000000;
    }
}

/* Mobile small */
@media (max-width: 480px) {
    .woa-modal {
        padding: 0;
        align-items: stretch;
    }
    
    .woa-modal__content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100%;
    }
    
    .woa-modal__body {
        max-height: calc(100vh - 180px);
        flex: 1;
    }
    
    .woa-modal__header {
        padding: 12px;
        gap: 10px;
    }
    
    .woa-modal__result {
        padding: 8px;
        gap: 10px;
    }
    
    .woa-modal__result-image {
        width: 48px;
        height: 48px;
        border-radius: 6px;
    }
    
    .woa-modal__result-title {
        font-size: 13px;
        white-space: normal;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .woa-modal__result-excerpt {
        display: none;
    }
    
    .woa-modal__result-meta {
        flex-wrap: nowrap;
    }
    
    .woa-modal__result-category {
        display: none;
    }
    
    .woa-modal__view-all {
        margin: 6px;
        padding: 10px 12px;
    }
    
    .woa-modal__footer {
        flex-direction: column;
        gap: 8px;
    }
    
    .woa-modal__footer-shortcuts {
        width: 100%;
        justify-content: center;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .woa-modal__result:active {
        background: #f0f0f0;
    }
    
    .woa-search-trigger__kbd {
        display: none;
    }
}