/* Minimal Search Dropdown Styles - ONLY dropdown specific styles */
/* This preserves all original search bar styling */

/* ============================================
   DROPDOWN CONTAINER - positioned from bubble-search-container
   ============================================ */
.search-dropdown {
    /* Positioning - absolute from parent container */
    position: fixed;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    z-index: 10000 !important;
    
    /* Styling */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    
    /* Behavior */
    max-height: 400px;
    overflow-y: auto;
    z-index: 10000;
}

/* ============================================
   DROPDOWN INTERNAL STRUCTURE
   ============================================ */
.search-dropdown-content {
    padding: 8px 0;
}

.dropdown-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.dropdown-section:last-child {
    border-bottom: none;
}

.dropdown-section-header {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   DROPDOWN ITEMS
   ============================================ */
.dropdown-item {
    display: block;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: #333;
}

.dropdown-item:hover {
    background-color: rgba(139, 92, 246, 0.1);
}

/* Category items */
.dropdown-item.category-item {
    padding: 10px 16px;
}

.category-tag {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
}

/* Book items */
.dropdown-item.book-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}


.book-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 12px;
    color: #999;
}

/* ============================================
   DROPDOWN STATES
   ============================================ */
.dropdown-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.dropdown-no-results {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ============================================
   SEARCH HIGHLIGHT
   ============================================ */
.search-highlight {
    background: rgba(255, 215, 0, 0.3);
    font-weight: 600;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .search-dropdown {
        max-height: 300px;
    }
    
    .dropdown-item {
        padding: 10px 12px;
    }
}

/* search-dropdown-overflow-fix.css */
/* ONLY fixes overflow to allow dropdown visibility */
/* Does NOT change any positioning or dimensions */

/* Allow dropdown to be visible outside sub-header bounds */
.search-subheader-wrapper {
    overflow: hidden !important;
    z-index: 99;
}

.search-subheader {
    overflow: visible !important;
}

.search-subheader-content {
    overflow: visible !important;
}

/* CRITICAL: Make bubble-search-container position:relative for dropdown positioning */
/* But do NOT change any other properties that affect layout */
.bubble-search-container {
    position: relative !important;  /* ONLY for dropdown positioning */
    overflow: visible !important;   /* ONLY for dropdown visibility */
    /* DO NOT add any width, margin, padding, or flex properties here */
}

/* FIXED POSITIONING FOR DROPDOWN OUTSIDE WRAPPER */

/* Keep original clipping for sub-header sliding */
.search-subheader-wrapper {
    overflow: hidden !important; /* Original behavior - clips when sliding */
    z-index: 99; /* Below main nav */
}

/* Dropdown now positioned with fixed positioning */
.search-dropdown {
    position: fixed; /* Fixed positioning since it's outside the wrapper */
    /* Position will be set by JavaScript */
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 99999; /* Above everything */
    max-height: 400px;
    overflow-y: auto;
    min-width: 300px;
    max-width: 600px;
}

/* Ensure main nav stays above sub-header */
.navbar,
nav {
    z-index: 100;
    position: relative;
}

/* Dark overlay that covers the entire page */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 9998; /* Just below the dropdown (9999) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

/* Active state when search is focused */
.search-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Ensure search elements stay above overlay */
.search-overlay-active .bubble-search-container {
    position: relative;
    z-index: 10000 !important;
}

.search-overlay-active .search-dropdown {
    z-index: 10001 !important;
}

/* Add glow effect to search bar when focused with overlay */
.search-overlay-active .bubble-search-input {
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 
        0 0 0 3px rgba(102, 126, 234, 0.3),
        0 10px 40px rgba(102, 126, 234, 0.3) !important;
}

/* Enhance the search button when overlay is active */
.search-overlay-active .bubble-search-button {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5) !important;
}

/* Subtle zoom effect on search container when focused */
@keyframes searchFocus {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.02);
    }
}

.search-overlay-active .bubble-search-container {
    animation: searchFocus 0.3s ease forwards;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .search-overlay {
        backdrop-filter: blur(1px);
        -webkit-backdrop-filter: blur(1px);
    }
}

/* Search Overlay Effect - Fixed z-index hierarchy */

/* Dark overlay that covers the entire page EXCEPT search elements */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 998; /* Below search elements */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

/* Active state when search is focused */
.search-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* CRITICAL: Keep search sub-header ABOVE overlay */
.search-subheader-wrapper {
    z-index: 999 !important; /* Above overlay (998) */
}

.search-subheader {
    z-index: 999 !important;
}

.search-subheader-content {
    z-index: 1000 !important;
}

/* Search container stays ABOVE overlay and glows */
.bubble-search-container {
    position: relative;
    z-index: 1001 !important; /* Above overlay */
}

/* When overlay is active, enhance the search bar */
.search-overlay.active ~ .search-subheader-wrapper .bubble-search-input,
body.search-overlay-active .bubble-search-input {
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 
        0 0 0 3px rgba(102, 126, 234, 0.3),
        0 10px 40px rgba(102, 126, 234, 0.3) !important;
    transform: scale(1.02);
    transition: all 0.3s ease;
}

/* Enhance the search button when overlay is active */
.search-overlay.active ~ .search-subheader-wrapper .bubble-search-button,
body.search-overlay-active .bubble-search-button {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5) !important;
    transform: translateY(-50%) scale(1.05);
}

/* Dropdown stays ABOVE overlay */
.search-dropdown {
    z-index: 1002 !important; /* Above everything */
}

/* Remove animation that might interfere */
@keyframes searchFocus {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.01);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .search-overlay {
        backdrop-filter: blur(1px);
        -webkit-backdrop-filter: blur(1px);
    }
}

/* Minimal Search Dropdown Styles - ONLY dropdown specific styles */
/* This preserves all original search bar styling */

/* ============================================
   DROPDOWN CONTAINER - positioned from bubble-search-container
   ============================================ */
.search-dropdown {
    /* Positioning - absolute from parent container */
    position: fixed;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    z-index: 10000 !important;
    
    /* Styling */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    
    /* Behavior */
    max-height: 400px;
    overflow-y: auto;
    z-index: 10000;
    
    /* FIX: Adjust scrollbar position to appear more leftward */
    padding-right: 5px;
    margin-right: 5px;
}

/* Custom scrollbar styling for webkit browsers */
.search-dropdown::-webkit-scrollbar {
    width: 8px;
    margin-left: -4px;
}

.search-dropdown::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    margin: 8px 0;
}

.search-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.search-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   DROPDOWN INTERNAL STRUCTURE
   ============================================ */
.search-dropdown-content {
    padding: 8px 0;
}

.dropdown-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.dropdown-section:last-child {
    border-bottom: none;
}

.dropdown-section-header {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.5) !important;  /* FIX: Ensure dark text */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left !important;  /* FIX: Force left alignment */
}

/* ============================================
   DROPDOWN ITEMS
   ============================================ */
.dropdown-item {
    display: block;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: #333 !important;  /* FIX: Ensure dark text color */
    text-align: left !important;  /* FIX: Force left alignment */
}

.dropdown-item:hover {
    background-color: rgba(139, 92, 246, 0.1);
}

/* Category items - UPDATED STYLING */
.dropdown-item.category-item {
    padding: 12px 16px;  /* Slightly increased padding */
    transition: background-color 0.2s ease;  /* FIX: Remove transform transition */
    transform: none !important;  /* FIX: Prevent any movement on hover */
}

/* FIX: Remove any hover transform effects */
.dropdown-item.category-item:hover {
    transform: none !important;
    background-color: rgba(139, 92, 246, 0.1);
}

.category-tag {
    display: inline-block;
    padding: 6px 12px;  /* Increased padding for larger appearance */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    border-radius: 12px;
    font-size: 16px;  /* FIX: Larger text size */
    font-weight: 500;
    text-align: left !important;  /* FIX: Left align text */
    line-height: 1.2;
}

/* Book items */
.dropdown-item.book-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* With these specific ones: */
.search-dropdown .book-title {
    font-weight: 600;
    color: #1a1a1a !important;
    margin-bottom: 4px;
    text-align: left !important;
}

.search-dropdown .book-author {
    font-size: 13px;
    color: #666 !important;
    text-align: left !important;
}

.search-dropdown .book-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 12px;
    color: #999 !important;
    text-align: left !important;
}

.book-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 12px;
    color: #999 !important;  /* FIX: Ensure gray text */
    text-align: left !important;  /* FIX: Force left alignment */
}

.search-dropdown .dropdown-item * {
    text-align: left !important;
}

/* ============================================
   DROPDOWN STATES
   ============================================ */
.dropdown-loading {
    padding: 20px;
    text-align: center !important;  /* Loading can stay centered */
    color: #666 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8B5CF6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.dropdown-no-results {
    padding: 20px;
    text-align: center !important;  /* No results can stay centered */
    color: #999 !important;
    font-size: 14px;
}

/* ============================================
   SEARCH HIGHLIGHT
   ============================================ */
.search-highlight {
    background: rgba(255, 215, 0, 0.3);
    font-weight: 600;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .search-dropdown {
        max-height: 300px;
    }
    
    .dropdown-item {
        padding: 10px 12px;
    }
    
    .category-tag {
        font-size: 14px;  /* Slightly smaller on mobile */
    }
}

/* ============================================
   OVERFLOW FIX SECTION
   ============================================ */

/* Allow dropdown to be visible outside sub-header bounds */
.search-subheader-wrapper {
    overflow: hidden !important;
    z-index: 99;
}

.search-subheader {
    overflow: visible !important;
}

.search-subheader-content {
    overflow: visible !important;
}

/* CRITICAL: Make bubble-search-container position:relative for dropdown positioning */
.bubble-search-container {
    position: relative !important;
    overflow: visible !important;
}

/* Keep original clipping for sub-header sliding */
.search-subheader-wrapper {
    overflow: hidden !important;
    z-index: 99;
}

/* Dropdown positioned with fixed positioning */
.search-dropdown {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 99999;
    max-height: 400px;
    overflow-y: auto;
    min-width: 300px;
    max-width: 600px;
}

/* Dark overlay that covers the entire page */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

/* Active state when search is focused */
.search-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Keep search elements ABOVE overlay */
.search-subheader-wrapper {
    z-index: 999 !important;
}

.search-subheader {
    z-index: 999 !important;
}

.search-subheader-content {
    z-index: 1000 !important;
}

.bubble-search-container {
    position: relative;
    z-index: 1001 !important;
}

/* Enhanced search bar when overlay is active */
.search-overlay.active ~ .search-subheader-wrapper .bubble-search-input,
body.search-overlay-active .bubble-search-input {
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 
        0 0 0 3px rgba(102, 126, 234, 0.3),
        0 10px 40px rgba(102, 126, 234, 0.3) !important;
    transform: scale(1.02);
    transition: all 0.3s ease;
}

/* Enhanced search button when overlay is active */
.search-overlay.active ~ .search-subheader-wrapper .bubble-search-button,
body.search-overlay-active .bubble-search-button {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5) !important;
    transform: translateY(-50%) scale(1.05);
}

/* Dropdown stays ABOVE everything */
.search-dropdown {
    z-index: 1002 !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .search-overlay {
        backdrop-filter: blur(1px);
        -webkit-backdrop-filter: blur(1px);
    }
}

/* Category items alignment fixes */
.search-dropdown .dropdown-item.category-item {
    padding: 12px 16px;
    display: flex;
    justify-content: flex-start;  /* Align content to left */
    align-items: center;
    text-align: left !important;
}

.search-dropdown .category-tag {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    text-align: left !important;
    line-height: 1.2;
    margin: 0;  /* Remove any default margins */
}

/* Ensure dropdown items don't center their content */
.search-dropdown .dropdown-items {
    text-align: left !important;
}

.search-dropdown #categoryResults {
    text-align: left !important;
}

/* Add to search-dropdown.css */
#categoriesSection {
    display: none !important;
}