/**
 * Advanced Search Modal Styles
 * Mobile-first design with Netflix/YouTube patterns
 */

.vh-search-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s ease;
}

.vh-search-modal[aria-hidden="false"] {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.3s ease;
}

.vh-search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.vh-search-modal-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100vh;
    background: var(--vh-bg-secondary, #181818);
    display: flex;
    flex-direction: column;
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.vh-search-modal[aria-hidden="false"] .vh-search-modal-container {
    transform: translateY(0);
    opacity: 1;
}

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

.vh-search-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--vh-text-primary, #fff);
    margin: 0;
}

.vh-search-modal-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--vh-text-secondary, rgba(255, 255, 255, 0.7));
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.vh-search-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--vh-text-primary, #fff);
}

.vh-search-modal-close svg {
    width: 24px;
    height: 24px;
}

.vh-search-modal-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.vh-search-modal-input-wrapper {
    position: relative;
    padding: 16px 20px;
    flex-shrink: 0;
}

.vh-search-modal-input-icon {
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--vh-text-secondary, rgba(255, 255, 255, 0.5));
    pointer-events: none;
}

.vh-search-modal-input {
    width: 100%;
    height: 52px;
    padding: 0 48px;
    background: var(--vh-bg-tertiary, rgba(255, 255, 255, 0.1));
    border: 2px solid transparent;
    border-radius: 26px;
    font-size: 16px;
    color: var(--vh-text-primary, #fff);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.vh-search-modal-input::placeholder {
    color: var(--vh-text-secondary, rgba(255, 255, 255, 0.5));
}

.vh-search-modal-input:focus {
    border-color: var(--vh-accent, #e50914);
    background: var(--vh-bg-primary, #141414);
}

.vh-search-modal-clear {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--vh-text-secondary, rgba(255, 255, 255, 0.5));
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s, background 0.2s, color 0.2s;
}

.vh-search-modal-clear.vh-visible {
    opacity: 1;
    visibility: visible;
}

.vh-search-modal-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--vh-text-primary, #fff);
}

.vh-search-modal-clear svg {
    width: 18px;
    height: 18px;
}

.vh-search-modal-filters {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
    -webkit-overflow-scrolling: touch;
}

.vh-search-filter-group {
    margin-bottom: 24px;
}

.vh-search-filter-group:last-child {
    margin-bottom: 0;
}

.vh-search-filter-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--vh-text-secondary, rgba(255, 255, 255, 0.7));
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.vh-search-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.vh-filter-chip {
    display: inline-flex;
    cursor: pointer;
}

.vh-filter-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.vh-filter-chip-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--vh-bg-tertiary, rgba(255, 255, 255, 0.1));
    border: 1px solid transparent;
    border-radius: 20px;
    font-size: 14px;
    color: var(--vh-text-secondary, rgba(255, 255, 255, 0.7));
    transition: all 0.2s ease;
}

.vh-filter-chip:hover .vh-filter-chip-text {
    background: rgba(255, 255, 255, 0.15);
    color: var(--vh-text-primary, #fff);
}

.vh-filter-chip input:checked + .vh-filter-chip-text {
    background: var(--vh-accent, #e50914);
    border-color: var(--vh-accent, #e50914);
    color: #fff;
}

.vh-filter-chip input:focus-visible + .vh-filter-chip-text {
    outline: 2px solid var(--vh-accent, #e50914);
    outline-offset: 2px;
}

.vh-tag-count {
    font-size: 12px;
    opacity: 0.7;
}

.vh-search-filter-tags .vh-tag-chips {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 8px;
}

.vh-search-modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--vh-border, rgba(255, 255, 255, 0.1));
    flex-shrink: 0;
    background: var(--vh-bg-secondary, #181818);
}

.vh-search-reset-btn {
    flex: 0 0 auto;
    padding: 14px 20px;
    background: transparent;
    border: 1px solid var(--vh-border, rgba(255, 255, 255, 0.3));
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--vh-text-secondary, rgba(255, 255, 255, 0.7));
    cursor: pointer;
    transition: all 0.2s ease;
}

.vh-search-reset-btn:hover {
    border-color: var(--vh-text-primary, #fff);
    color: var(--vh-text-primary, #fff);
}

.vh-search-submit-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--vh-accent, #e50914);
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.vh-search-submit-btn:hover {
    background: var(--vh-accent-hover, #f40612);
}

.vh-search-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.vh-search-result-count {
    font-weight: 400;
    opacity: 0.9;
}

.vh-search-result-count:empty {
    display: none;
}

.vh-search-result-count::before {
    content: '(';
}

.vh-search-result-count::after {
    content: ')';
}

@media (min-width: 768px) {
    .vh-search-modal {
        padding: 60px 20px;
        align-items: flex-start;
    }
    
    .vh-search-modal-container {
        max-width: 640px;
        max-height: calc(100vh - 120px);
        height: auto;
        border-radius: 12px;
        box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    }
    
    .vh-search-modal-header {
        padding: 20px 24px;
    }
    
    .vh-search-modal-title {
        font-size: 20px;
    }
    
    .vh-search-modal-input-wrapper {
        padding: 20px 24px;
    }
    
    .vh-search-modal-input-icon {
        left: 44px;
    }
    
    .vh-search-modal-clear {
        right: 44px;
    }
    
    .vh-search-modal-filters {
        padding: 0 24px 24px;
        max-height: 400px;
    }
    
    .vh-search-modal-footer {
        padding: 20px 24px;
    }
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .vh-search-modal-backdrop {
        background: rgba(0, 0, 0, 0.6);
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-container {
        background: #fff;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-title {
        color: #1a1a1a;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-close {
        color: #666;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-close:hover {
        background: rgba(0, 0, 0, 0.05);
        color: #1a1a1a;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-input {
        background: #f5f5f5;
        color: #1a1a1a;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-input::placeholder {
        color: #999;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-input:focus {
        background: #fff;
        border-color: var(--vh-accent, #e50914);
    }
    
    :root:not([data-theme="dark"]) .vh-search-filter-label {
        color: #666;
    }
    
    :root:not([data-theme="dark"]) .vh-filter-chip-text {
        background: #f0f0f0;
        color: #333;
    }
    
    :root:not([data-theme="dark"]) .vh-filter-chip:hover .vh-filter-chip-text {
        background: #e5e5e5;
        color: #1a1a1a;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-header,
    :root:not([data-theme="dark"]) .vh-search-modal-footer {
        border-color: #e0e0e0;
    }
    
    :root:not([data-theme="dark"]) .vh-search-modal-footer {
        background: #fff;
    }
    
    :root:not([data-theme="dark"]) .vh-search-reset-btn {
        border-color: #ccc;
        color: #666;
    }
    
    :root:not([data-theme="dark"]) .vh-search-reset-btn:hover {
        border-color: #333;
        color: #333;
    }
}

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

.vh-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: vh-spin 0.8s linear infinite;
}

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

/* Applied Filters Chips */
.vh-applied-filters {
    padding: 12px 20px;
    border-bottom: 1px solid var(--vh-border, rgba(255, 255, 255, 0.1));
    background: rgba(99, 102, 241, 0.05);
}

.vh-filters-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.vh-filter-chip-removable {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--vh-primary, #6366f1);
    color: #fff;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.vh-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.vh-chip-remove:hover {
    opacity: 1;
}

.vh-chip-remove svg {
    width: 14px;
    height: 14px;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .vh-applied-filters {
        background: rgba(99, 102, 241, 0.08);
    }
}
