/**
 * Unified Search Panel Styles
 * 
 * Shared CSS for the unified search/filter panel used across:
 * - /articles
 * - /models
 * - /images
 * - /dashboard (texter)
 * - /graphic/dashboard
 * - /shop/dashboard
 */

/* Filters Panel Container */
.filters-panel {
    margin-bottom: 2rem;
    border: 2px solid var(--primary-color);
    padding: 1rem;
    border-radius: 8px;
    background: rgba(var(--primary-color-rgb, 28, 76, 91), 0.05);
}

.filters-panel > div:first-child {
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
}

.filters-panel > div:first-child .material-icons-outlined {
    font-size: 16px;
    vertical-align: middle;
}

/* Filter Row - Main container for search and actions */
.filter-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Search Group - Contains the search input */
.search-group {
    position: relative;
    flex: 1;
    min-width: 300px;
}

/* Search Input Wrapper */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* Search Icon */
.search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-tertiary);
    pointer-events: none;
    z-index: 1;
    font-size: 1.2rem;
}

/* Search Input */
.search-input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 28, 76, 91), 0.1);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

/* Search Clear Button */
.search-clear {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    z-index: 2;
}

.search-clear:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.search-clear .material-icons-outlined {
    font-size: 1.2rem;
}

/* Filter Actions - Container for buttons on the right */
.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: nowrap; /* Prevent wrapping on larger displays */
}

/* Select dropdowns in filter actions - Make them smaller and compact */
.filter-actions select {
    padding: 0.375rem 0.625rem;
    min-width: 90px;
    max-width: 120px;
    font-size: 0.85rem;
    appearance: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.filter-actions select:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.filter-actions select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 28, 76, 91), 0.1);
}

/* Wider dropdowns for special cases (e.g., import_job with dates) */
.filter-actions select.wider {
    min-width: 110px;
    max-width: 150px;
}

/* Filter Group (for additional grouping if needed) */
.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Filter Buttons */
.btn-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-filter:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.btn-filter.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-filter .material-icons-outlined {
    font-size: 1.1rem;
}

/* View Toggle Buttons */
.btn-view-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-view-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-view-toggle.active {
    background: var(--primary-color);
    color: white;
}

.btn-view-toggle .material-icons-outlined {
    font-size: 1.1rem;
}

/* Search Suggestions / Autocomplete */
#search-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    margin-top: 4px;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#search-suggestions-list {
    padding: 0.5rem 0;
}

.autocomplete-item {
    padding: 0.875rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
    position: relative;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: var(--bg-secondary);
}

.autocomplete-item.selected {
    background-color: var(--primary-color);
    color: white;
}

.autocomplete-item.selected .material-icons-outlined,
.autocomplete-item.selected div {
    color: white !important;
}

.autocomplete-item strong {
    font-weight: 600;
    color: var(--primary-color);
}

.autocomplete-item.selected strong {
    color: white;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0 2px;
    border-radius: 2px;
}

/* Scrollbar styling for suggestions */
#search-suggestions::-webkit-scrollbar {
    width: 8px;
}

#search-suggestions::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

#search-suggestions::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

#search-suggestions::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Tablet Responsive Styles (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .filters-panel {
        padding: 0.875rem;
    }

    .filter-row {
        gap: 0.875rem;
    }

    .search-group {
        min-width: 250px;
        max-width: 100%;
    }

    .search-input {
        font-size: 0.875rem;
        padding: 0.45rem 2.25rem 0.45rem 2.25rem;
    }

    .search-icon {
        left: 0.625rem;
        font-size: 1.1rem;
    }

    .search-clear {
        right: 0.45rem;
        padding: 0.2rem;
    }

    .filter-actions {
        gap: 0.45rem;
        flex-wrap: wrap; /* Allow wrapping on tablets */
        justify-content: flex-start;
    }

    .filter-actions select {
        min-width: 90px;
        max-width: 130px;
        padding: 0.35rem 0.65rem;
        font-size: 0.8rem;
    }
    
    .filter-actions select.wider {
        min-width: 100px;
        max-width: 140px;
    }

    .btn-filter,
    .btn-view-toggle {
        padding: 0.45rem 0.875rem;
        font-size: 0.875rem;
    }

    .btn-filter .material-icons-outlined,
    .btn-view-toggle .material-icons-outlined {
        font-size: 1rem;
    }

    /* Adjust spacing for better tablet layout */
    .filters-panel > div:first-child {
        font-size: 0.8rem;
        margin-bottom: 0.45rem;
    }
}

/* Large displays (> 1024px) - Prevent wrapping */
@media (min-width: 1025px) {
    .filter-actions {
        flex-wrap: nowrap;
    }
    
    .filter-actions select {
        min-width: 90px;
        max-width: 120px;
    }
    
    .filter-actions select.wider {
        min-width: 110px;
        max-width: 150px;
    }
}

/* Mobile Responsive Styles (< 768px) */
@media (max-width: 767px) {
    .filters-panel {
        padding: 0.875rem;
        margin-bottom: 1.5rem;
    }

    .filters-panel > div:first-child {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.875rem;
    }

    .search-group {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .search-input {
        font-size: 0.875rem;
        padding: 0.5rem 2.25rem 0.5rem 2.25rem;
    }

    .filter-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 0.5rem;
        flex-wrap: wrap; /* Allow wrapping on mobile */
    }

    .filter-actions select {
        min-width: 0;
        max-width: 100%;
        width: 100%;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn-filter,
    .btn-view-toggle {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }

    /* Stack filter buttons on mobile if they wrap */
    .filter-actions .btn-filter,
    .filter-actions .btn-view-toggle {
        flex: 1 1 auto;
        min-width: 0;
    }
}

