/* ==========================================================================
   Enhanced Search Form - Mobile-First Responsive Design
   ========================================================================== */

.enhanced-search-form {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem 1.5rem;
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.enhanced-search-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.08);
    pointer-events: none;
}

/* Progress Indicator */
.search-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.progress-step.active {
    opacity: 1;
}

.progress-step.completed {
    opacity: 1;
}

.step-number {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-bottom: 0.5rem;
}

.progress-step.active .step-number,
.progress-step.completed .step-number {
    background: white;
    color: #667eea;
    border-color: white;
}

.step-label {
    color: rgba(255,255,255,0.7);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.progress-step.active .step-label,
.progress-step.completed .step-label {
    color: white;
}

.progress-connector {
    width: 4rem;
    height: 2px;
    background: rgba(255,255,255,0.2);
    margin: 0 1rem;
    position: relative;
    top: -1.25rem;
}

/* Search Steps */
.search-step {
    display: none;
    animation: fadeIn 0.5s ease;
}

.search-step.active {
    display: block;
}

.step-header {
    color: white;
    margin-bottom: 2rem;
}

.step-header h3 {
    color: white;
    font-weight: 600;
}

/* Genre Grid */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.genre-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.genre-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.genre-card.selected {
    border-color: #28a745;
    background: #28a745;
    color: white;
}

.genre-card.selected .genre-icon {
    color: white;
}

.genre-icon {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.genre-name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
}

/* Loading Placeholders */
.loading-placeholder {
    pointer-events: none;
    opacity: 0.7;
}

.placeholder-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: #e0e0e0;
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Advanced Filters */
.advanced-filters {
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
}

.custom-select-wrapper {
    position: relative;
}

.custom-select, #tag1, #tag2, #tag3 {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: rgba(255, 255, 255, 0.95) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="none" stroke="%23333" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2 5l6 6 6-6"/></svg>') no-repeat right 1rem center;
    background-size: 16px 16px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 0.5rem;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    width: 100%;
    height: auto;
    min-height: 48px;
    line-height: 1.5;
}

.custom-select:focus, #tag1:focus, #tag2:focus, #tag3:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
    outline: none;
    background: rgba(255, 255, 255, 1) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="none" stroke="%2328a745" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2 5l6 6 6-6"/></svg>') no-repeat right 1rem center;
    background-size: 16px 16px;
}

/* Fix per container select */
.tag-filters-section .col-md-4 {
    padding-left: 15px;
    padding-right: 15px;
    margin-bottom: 1rem;
}

.tag-filters-section .form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

/* Book cover placeholder */
.book-cover-placeholder {
    width: 100%;
    height: 100%;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    position: relative;
    min-height: 200px;
}

.book-cover-placeholder .placeholder-icon {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.book-cover-placeholder .placeholder-text {
    font-size: 0.875rem;
    color: #6c757d;
    text-align: center;
    font-weight: 500;
}

/* Responsive placeholder */
@media (max-width: 768px) {
    .book-cover-placeholder {
        min-height: 150px;
    }
    .book-cover-placeholder .placeholder-icon {
        font-size: 2rem;
    }
}

.select-arrow {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.custom-select:focus + .select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Selected Filters */
.selected-filters {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e1e5e9;
    display: none;
}

.selected-filters.show {
    display: block;
}

.filters-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    background: #28a745;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-tag .remove-filter {
    color: white;
    cursor: pointer;
    font-weight: bold;
}

/* Quick Actions */
.quick-actions {
    margin-top: 1.5rem;
}

.quick-actions .btn-link {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 0.3s ease;
}

.quick-actions .btn-link:hover {
    color: white;
    text-decoration: underline;
}

/* Search Actions */
.search-actions {
    margin-top: 2rem;
}

.search-summary {
    color: rgba(255,255,255,0.9);
}

.search-button-group {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

#search-button {
    min-width: 200px;
    position: relative;
    overflow: hidden;
}

#search-button:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

.button-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Search Preview */
.search-preview .alert {
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .enhanced-search-form {
        padding: 1.5rem 1rem;
        border-radius: 0.75rem;
    }

    .search-progress {
        display: none !important;
    }

    .genre-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.75rem;
    }

    .genre-card {
        padding: 1rem 0.75rem;
    }

    .genre-icon {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }

    .genre-name {
        font-size: 0.85rem;
    }

    .step-header h3 {
        font-size: 1.25rem;
    }

    .search-button-group {
        justify-content: center;
    }

    #search-button {
        width: 100%;
        min-width: auto;
    }

    .advanced-filters {
        padding: 1rem !important;
    }
}

@media (max-width: 480px) {
    .genre-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .genre-card {
        padding: 0.75rem 0.5rem;
    }

    .genre-icon {
        font-size: 1.75rem;
    }

    .genre-name {
        font-size: 0.8rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .genre-card {
        border-color: #000;
    }

    .genre-card.selected {
        border-color: #000;
        background: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .genre-card,
    .progress-step,
    .step-number,
    .step-label,
    .custom-select,
    .select-arrow {
        transition: none;
    }

    .search-step {
        animation: none;
    }

    @keyframes shimmer {
        0%, 100% { background-position: 0 0; }
    }
}

/* ==========================================================================
   Enhanced Categories Section
   ========================================================================== */

.enhanced-categories-section {
    margin-top: 3rem;
}

.section-header h3 {
    color: white !important;
    font-weight: 600;
}

/* Category Tabs */
.categories-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.tabs-wrapper {
    display: flex;
    background: rgba(255,255,255,0.1);
    border-radius: 50px;
    padding: 4px;
    backdrop-filter: blur(10px);
}

.category-tab {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.category-tab:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.category-tab.active {
    color: #667eea;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Category Panels */
.categories-content {
    position: relative;
    min-height: 300px;
}

.category-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.category-panel.active {
    display: block;
}

/* Enhanced Categories Grid */
.enhanced-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.category-card {
    background: rgba(255,255,255,0.95);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(40, 167, 69, 0.05);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-card:hover::before {
    opacity: 1;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: rgba(102, 126, 234, 0.3);
}

.category-card.selected {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.category-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #28a745;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    flex-shrink: 0;
}

.category-icon i {
    font-size: 1.5rem;
    color: white;
}

.category-info {
    flex: 1;
}

.category-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.25rem;
}

.category-meta {
    font-size: 0.85rem;
    color: #6b7280;
}

.category-count {
    background: #28a745;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Loading states for categories */
.category-card.loading-placeholder .category-icon {
    background: #f0f0f0;
}

.category-card.loading-placeholder .placeholder-icon {
    width: 30px;
    height: 30px;
    background: #e8e8e8;
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 50%;
}

.category-card.loading-placeholder .placeholder-text {
    height: 18px;
    background: #e8e8e8;
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 6px;
    width: 70%;
}

.category-card.loading-placeholder .placeholder-meta {
    height: 14px;
    background: #e8e8e8;
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    width: 50%;
}

/* Mobile optimizations for categories */
@media (max-width: 768px) {
    .enhanced-categories-section {
        margin-top: 2rem;
    }

    .tabs-wrapper {
        flex-direction: column;
        width: 100%;
    }

    .category-tab {
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
        border-radius: 8px;
    }

    .category-tab:last-child {
        margin-bottom: 0;
    }

    .enhanced-categories-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .category-card {
        padding: 1rem;
    }

    .category-icon {
        width: 50px;
        height: 50px;
    }

    .category-icon i {
        font-size: 1.25rem;
    }

    .category-name {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .tabs-wrapper {
        padding: 2px;
    }

    .category-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .category-card {
        padding: 0.75rem;
        flex-direction: column;
        text-align: center;
    }

    .category-icon {
        margin-right: 0;
        margin-bottom: 0.75rem;
        width: 60px;
        height: 60px;
    }
}

/* Legacy dropdown styles for compatibility */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1000;
    min-width: 200px;
    padding: 0.5rem 0;
    margin: 0;
    background-color: #fff;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.175);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: #16181b;
    background-color: #f8f9fa;
}

.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid #dee2e6;
}

.dropdown-toggle::after {
    display: inline-block;
    margin-left: 0.255em;
    vertical-align: 0.255em;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}
