/* Base del sidebar */
.eventos-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: sticky;
    top: 2rem;
    height: fit-content;
    z-index: 10;
    overflow: visible !important; /* Critical - ensures dropdown isn't clipped */
}

/* Secciones */
.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    overflow: visible !important; /* Critical - allow dropdowns to be visible */
    position: relative;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-title {
    font-size: 1.25rem;
    color: #1a1a1a;
    margin-bottom: 1rem;
}

/* Buscador y contenedor - FIXED SEARCH ICON */
.search-section {
    padding: 1.5rem;
    box-sizing: border-box;
    position: relative;
    overflow: visible !important;
}

.search-wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
}

.search-input {
    width: 100%; 
    padding: 0.875rem 2.75rem 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #333;
    background: #f8f9fa;
    transition: all 0.2s ease;
    box-sizing: border-box;
    max-width: 100%;
}

/* Search icon fix - increased z-index to stay above results */
.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    z-index: 10 !important;
    height: 1rem;
    width: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Lista de items */
.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-list li {
    margin-bottom: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-list li:last-child {
    margin-bottom: 0;
}

.sidebar-list li a {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    color: #666;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-list li i {
    width: 20px;
    margin-right: 0.8rem;
    color: #e1af1a;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-list .count {
    margin-left: auto;
    font-size: 0.85rem;
    color: #999;
    background: #f5f7f9;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Estados activos y hover */
.sidebar-list li a:hover {
    background: rgba(225, 175, 26, 0.1);
    font-weight: 500;
}

/* Active item styling - different for light vs dark mode */
body:not(.dark-mode) .sidebar-list li.active a {
    color: #333 !important;
    font-weight: 600;
    background: rgba(225, 175, 26, 0.15);
}

body.dark-mode .sidebar-list li.active a {
    color: #e1af1a !important;
    font-weight: 600;
    background: rgba(225, 175, 26, 0.15);
}

.sidebar-list li a:hover,
.sidebar-list li.active a {
    border-left: 3px solid #e1af1a;
    padding-left: calc(0.75rem - 3px);
}

body:not(.dark-mode) .sidebar-list li a:hover {
    color: #333;
}

body.dark-mode .sidebar-list li a:hover {
    color: #e1af1a !important;
}

/* Search Results Overlay - Desktop Version */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    overflow-y: auto;
    max-height: 300px;
    z-index: 9;
    display: none;
    border: 1px solid #e5e7eb;
    width: 100%;
    box-sizing: border-box;
    margin-top: 5px;
}

.search-results.active {
    display: block !important;
}

.search-results-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.95);
    z-index: 1100;
    padding: 1rem;
    overflow-y: auto;
    flex-direction: column;
}

.search-results-overlay.active {
    display: flex;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: #222222;
    border-bottom: 1px solid #444;
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 8px 8px 0 0;
}

.search-title {
    font-size: 1rem;
    font-weight: 600;
    color: #f5f5f5;
}

.close-search {
    background: none;
    border: none;
    color: #f5f5f5;
    font-size: 1.2rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-search:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Base styling for search results that's shared across contexts */
.search-result-item {
    display: flex;
    align-items: flex-start;
    padding: 0.875rem;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease, border-left 0.2s ease;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    background-color: white;
}

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

.search-result-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    margin-right: 1rem;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.search-result-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.search-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    width: 100%;
}

.search-result-meta span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-meta i {
    font-size: 0.875rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Light mode specific styles */
body:not(.dark-mode) .search-results .search-result-item {
    background-color: white;
    border-bottom-color: #f0f0f0;
}

body:not(.dark-mode) .search-results .search-result-title {
    color: #333333;
}

body:not(.dark-mode) .search-results .search-result-meta {
    color: #666666;
}

body:not(.dark-mode) .search-results .search-result-meta i {
    color: #e1af1a;
}

/* Light mode hover */
body:not(.dark-mode) .search-results .search-result-item:hover {
    background-color: rgba(225, 175, 26, 0.1);
    border-left: 3px solid #e1af1a;
    padding-left: calc(0.875rem - 3px);
}

body:not(.dark-mode) .search-results .search-result-item:hover .search-result-title {
    color: #111111;
}

/* Overlay specific styles (both light and dark mode) */
.search-results-overlay .search-result-item {
    background-color: #222222;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border-bottom: none;
    border-left: none;
    padding-left: 0.875rem;
    border-color: #444;
}

.search-results-overlay .search-result-title {
    color: #ffffff;
}

.search-results-overlay .search-result-meta {
    color: #999999;
}

.search-results-overlay .search-result-meta i {
    color: #e1af1a;
}

.search-results-overlay .search-result-item:hover {
    background-color: #333333;
    border-left: none;
    padding-left: 0.875rem;
}

.no-results {
    padding: 1rem;
    text-align: center;
    color: #666;
    font-size: 0.95rem;
}

.search-results-overlay .no-results {
    color: #999;
}

.search-loader {
    position: absolute;
    right: 3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #e1af1a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
    z-index: 10 !important;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Fix for mobile display */
@media (max-width: 992px) {
    .eventos-sidebar {
        width: 100%;
        position: static;
        margin-bottom: 2rem;
    }

    .search-wrapper {
        max-width: 100%;
        margin: 0 auto;
    }

    .sidebar-section {
        padding: 1.25rem;
    }
}

/* Add body class to prevent scrolling when search is active */
body.search-active {
    overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .eventos-sidebar {
        width: 100%;
        position: static;
        margin-bottom: 2rem;
    }

    .search-wrapper {
        max-width: 100%;
        margin: 0 auto;
    }

    .sidebar-section {
        padding: 1.25rem;
    }
    
    /* Show overlay on tablet and mobile */
    .search-results {
        display: none !important; /* Force hide regular results */
    }
}

@media (max-width: 768px) {
    .eventos-sidebar {
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        overflow: visible !important;
    }

    .sidebar-section {
        background: white;
        margin-bottom: 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        width: 100%;
        box-sizing: border-box;
        overflow: visible !important;
    }

    .search-section {
        padding: 1rem;
        margin: 0 0 1rem 0;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        width: 100%;
        box-sizing: border-box;
        overflow: visible !important;
    }
    
    .search-wrapper {
        width: 100%;
        margin: 0;
        overflow: visible !important;
    }

    .search-input {
        font-size: 1rem;
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
    }
    
    .search-result-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-result-meta span {
        width: 100%;
    }
    
    .search-results-overlay .search-result-image {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 576px) {
    .eventos-sidebar {
        overflow: visible !important;
    }
    
    .sidebar-section,
    .search-section {
        padding: 1rem;
        margin: 0.5rem;
        width: calc(100% - 1rem);
        box-sizing: border-box;
        overflow: visible !important;
    }

    .search-input {
        font-size: 0.875rem;
        padding: 0.75rem 2.5rem 0.75rem 0.875rem;
        box-sizing: border-box;
        width: 100%;
        max-width: none;
    }

    .sidebar-list li a {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
    
    .search-section {
        padding: 0.875rem;
    }
    
    .search-result-image {
        width: 40px;
        height: 40px;
    }
    
    .search-results-overlay .search-result-image {
        width: 45px;
        height: 45px;
    }
    
    .search-results-overlay .search-result-title {
        font-size: 0.9rem;
    }
}