/**
 * Purp Search Modal - Styles
 * Prefix: ozs- (OZ Search)
 * Based on beat-license-preview modal styles for 100% site-wide consistency
 */

/* ==========================================================================
   CSS Reset for Modal Elements (Prevent Elementor/Theme Bleed)
   ========================================================================== */

.ozs-modal-overlay,
.ozs-modal-overlay * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Modal Overlay
   ========================================================================== */

.ozs-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 999998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2.5px);
    -webkit-backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.ozs-modal-overlay.ozs-active {
    display: flex;
    opacity: 1;
}

/* ==========================================================================
   Modal Container
   ========================================================================== */

.ozs-modal-container {
    position: relative;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    background-color: #111;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.ozs-modal-overlay.ozs-active .ozs-modal-container {
    transform: translateY(0);
}

/* ==========================================================================
   Modal Header
   ========================================================================== */

.ozs-modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ozs-modal-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 22px;
    font-weight: 625;
    color: #D8D8D8;
    margin: 0;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Close Button
   ========================================================================== */

.ozs-modal-close {
    background: transparent !important;
    border: none !important;
    color: #d8d8d8 !important;
    font-size: 28px !important;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    margin-bottom: 8px;
}

.ozs-modal-close:focus,
.ozs-modal-close:active,
.ozs-modal-close:focus-visible,
.ozs-modal-close:focus-within {
    background: transparent !important;
    border: none !important;
    color: #d8d8d8 !important;
    outline: none !important;
    box-shadow: none !important;
}

/* ==========================================================================
   Modal Body
   ========================================================================== */

.ozs-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    position: relative;
    min-height: 200px;
    max-height: calc(90vh - 100px);
}

/* ==========================================================================
   Search Results Content
   ========================================================================== */

.ozs-results-content {
    color: rgba(255, 255, 255, 0.9);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.7;
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

.ozs-modal-body::-webkit-scrollbar {
    width: 8px;
}

.ozs-modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.ozs-modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.ozs-modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Loading State (Circular Spinner - matches beat-license-preview)
   ========================================================================== */

.ozs-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    padding: 40px;
}

.ozs-spinner {
    width: 35px;
    height: 35px;
    border: 7px solid rgba(255, 255, 255, 0.1);
    border-top-color: #d8d8d8;
    border-radius: 50%;
    animation: ozs-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Error State
   ========================================================================== */

.ozs-error {
    color: #fca5a5;
    background-color: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    padding: 16px;
    border-radius: 4px;
    text-align: center;
}

/* ==========================================================================
   No Results State
   ========================================================================== */

.ozs-no-results {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
}

.ozs-no-results p {
    margin: 0;
    font-size: 16px;
}

.ozs-no-results strong {
    color: #d8d8d8;
}

/* ==========================================================================
   Search Results Grid
   ========================================================================== */

.ozs-results-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Search Result Item
   ========================================================================== */

.ozs-result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: #1a1a1a;
    border-radius: 2px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.ozs-result-item:hover {
    background: #222;
    border-color: rgba(216, 216, 216, 0.2);
    text-decoration: none;
    color: inherit;
}

.ozs-result-item:active {
    background: #252525;
}

/* Thumbnail */
.ozs-result-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 2px;
    overflow: hidden;
    background: #0a0a0a;
}

.ozs-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Info */
.ozs-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ozs-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #d8d8d8;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    transition: text-decoration 0.2s ease;
}

/* Title underline on hover - only when hovering directly on title */
.ozs-result-title:hover {
    text-decoration: underline;
}

.ozs-result-meta {
    font-size: 14px;
    font-weight: 500;
    color: #d8d8d8;
    opacity: 0.8;
}

/* Arrow indicator */
.ozs-result-arrow {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: rgba(216, 216, 216, 0.4);
    transition: color 0.2s ease, transform 0.2s ease;
}

.ozs-result-item:hover .ozs-result-arrow {
    color: #d8d8d8;
}

/* ==========================================================================
   Results Count
   ========================================================================== */

.ozs-results-count {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   End of Results Indicator
   ========================================================================== */

.ozs-end-of-results {
    text-align: center;
    padding: 20px 16px;
    margin-top: 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.05em;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Mobile Responsive - Slide Up from Bottom
   ========================================================================== */

@media (max-width: 768px) {
    .ozs-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    
    .ozs-modal-container {
        width: 100%;
        max-width: 100%;
        max-height: 70vh; /* Reduced from 85vh to keep AJAX loader visible */
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    
    .ozs-modal-overlay.ozs-active .ozs-modal-container {
        transform: translateY(0);
    }
    
    .ozs-modal-header {
        padding: 20px;
    }
    
    .ozs-modal-title {
        font-size: 18px;
    }
    
    .ozs-modal-body {
        padding: 20px;
        max-height: calc(70vh - 80px); /* Adjusted to match container */
    }
    
    .ozs-results-content {
        font-size: 13px;
    }
    
    .ozs-result-item {
        gap: 12px;
        padding: 10px;
    }
    
    .ozs-result-thumb {
        width: 50px;
        height: 50px;
    }
    
    .ozs-result-title {
        font-size: 14px;
    }
    
    .ozs-result-price {
        font-size: 13px;
    }
}

/* ==========================================================================
   Body Scroll Lock (Applied via JS)
   ========================================================================== */

body.ozs-modal-open {
    overflow: hidden !important;
}

/* ==========================================================================
   Accessibility - Focus States
   ========================================================================== */

.ozs-modal-overlay:focus {
    outline: none;
}

.ozs-modal-container:focus {
    outline: none;
}

/* Focus trap indicator */
.ozs-modal-container:focus-within {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(216, 216, 216, 0.3);
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ozs-modal-overlay {
        display: none !important;
    }
}
