/* Modern Search Layout */
:root {
    /* Updated Palette */
    --accent-color: #1a88bc;
    --accent-gradient: radial-gradient(circle at 10% 15%,
            #16bd9c,
            #1a89bc);
    --footer-bg-color: #161f22;
    --footer-link-color: #ffffff;

    --primary-color: var(--accent-color);
    --secondary-color: #2c3e50;
    --text-color: #333;
    --light-bg: #f8f9fa;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Defensivo: si #view-transition aplica transform, iOS/Safari rompe position: fixed.
   Al abrir filtros en móvil (overlay), quitamos el transform para mantener el overlay fijo. */
body.filters-open #view-transition,
body.filters-open #footer-transition {
    transform: none !important;
}

.search-page-container {
    background-color: var(--light-bg);
    min-height: 100vh;
    padding-top: 1rem;
    padding-bottom: 4rem;
}

.search-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
}

/* Sidebar Styles */
.search-sidebar-wrapper {
    align-self: start;
    height: fit-content;
    position: sticky;
    top: calc(var(--navbar-offset, 70px) + 1.25rem);
}

.search-sidebar {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    height: fit-content;
    position: static;
    max-height: calc(100dvh - (var(--navbar-offset, 70px) + 2.75rem));
    overflow: auto;
    scrollbar-gutter: stable both-edges;
}

.search-sidebar h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
    font-size: 0.95rem;
}

.form-select.modern-select {
    height: 48px;
    border: 1px solid rgba(2, 6, 23, 0.10);
    border-radius: 50rem;
    padding: 0 18px;
    padding-right: 2.25rem;
    font-size: 1rem;
    transition: border-color .2s ease, box-shadow .2s ease;
    background-position: right .75rem 50% !important;
    background-size: 16px 12px;
}

.form-select.modern-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(26, 136, 188, 0.1);
}

.btn-filter-apply {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50rem;
    font-weight: 600;
    color: white;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Clear button for modern search inputs */
.location-input::-webkit-search-cancel-button,
.location-input::-webkit-search-decoration,
.location-input::-webkit-search-results-button,
.location-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.filter-group-inner {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-clear-filter {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #f1f5f9;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s ease;
    padding: 0;
    opacity: 0;
    visibility: hidden;
}

.btn-clear-filter:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: translateY(-50%) scale(1.1);
}

.btn-clear-filter.is-visible {
    opacity: 1;
    visibility: visible;
}

.btn-clear-filter i {
    font-size: 14px;
    line-height: 1;
}

/* Select2 Clear Button Overrides - Scoped to Sidebar Filters */
.sidebar-filters-form .select2-container--default .select2-selection--single .select2-selection__clear {
    cursor: pointer;
    float: right;
    font-weight: bold;
    height: 24px;
    width: 24px;
    margin-right: 0;
    position: absolute;
    right: 8px;
    /* Far right */
    top: 50%;
    transform: translateY(-50%);
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0;
    /* Hide default '×' text node */
    z-index: 2;
    transition: all 0.2s ease;
    border: none;
}

.sidebar-filters-form .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.sidebar-filters-form .select2-container--default .select2-selection--single .select2-selection__clear::after {
    content: '×';
    font-size: 18px;
    line-height: 1;
    display: block;
}

/* Force Arrow display and position it to the left of X */
.sidebar-filters-form .select2-container--default .select2-selection--single .select2-selection__arrow {
    display: block !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    right: 36px !important;
    /* Positioned left of the X (8px + 24px + 4px gap) */
    width: 20px !important;
}

/* Adjust text padding to prevent overlap */
.sidebar-filters-form .select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-right: 60px !important;
}

/* Adjust modern-select padding when clear is present */
.location-input {
    padding-right: 60px !important;
}

.btn-filter-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
    color: white;
}

/* Toggle Button for Mobile */
.btn-toggle-filters {
    display: none;
    width: 100%;
    margin-bottom: 1rem;
    background: var(--card-bg);
    border: 1px solid #e0e0e0;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    color: var(--accent-color);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.filters-sheet__handle {
    display: none;
}

.filters-sheet__grabber {
    display: block;
}

/* Results Field */
.results-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-count {
    color: #666;
    font-size: 0.95rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.search-results-sentinel {
    min-height: 1px;
    width: 100%;
}

/* Modern Card Styles */
.modern-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.35s ease;
    position: relative;
    border: none;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0);
}

.modern-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

body.search-media-pending .modern-card.is-media-pending {
    opacity: 0;
    transform: translateY(10px);
}

.card-header-image {
    height: 120px;
    background-color: #eee;
    background-size: cover;
    background-position: center;
    position: relative;
}

.card-body-content {
    padding: 1.5rem;
    padding-top: 3rem;
    /* Space for the overlapping avatar */
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-avatar-container {
    position: absolute;
    top: -40px;
    /* Overlap header */
    left: 1.5rem;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: visible;
}

.card-avatar-frame {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #fff;
    overflow: hidden;
}

.card-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.verified-badge {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: var(--accent-gradient, var(--accent-color));
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
    box-shadow: 0 6px 16px rgba(26, 136, 188, 0.35);
    z-index: 2;
}

.verified-badge img {
    width: 16px;
    height: 16px;
}

/* Floating "Ver Video" Button */
.btn-video-floating {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 2;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-video-floating i {
    color: var(--accent-color);
    font-size: 1.1rem;
}

.btn-video-floating:hover {
    background: #fff;
    transform: scale(1.05);
}

.card-user-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.25rem;
    text-decoration: none;
    display: block;
    line-height: 1.2;
}

.card-user-name:hover {
    color: var(--accent-color);
}

.card-specialty {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.card-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1.5rem;
    background: #fcfcfc;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

.card-detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-detail-item i {
    width: 20px;
    text-align: center;
    color: #999;
}

.verified-text {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.card-footer-action {
    margin-top: auto;
    display: flex;
    gap: 0.75rem;
}

.btn-view-profile {
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--accent-color);
    background: transparent;
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    border-radius: 8px;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: block;
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-view-profile:hover {
    background: var(--accent-color);
    color: white;
}

.btn-contact-profile {
    padding: 0.75rem 0.5rem;
    border: 2px solid transparent;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    border-radius: 8px;
    transition: all 0.2s;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-contact-profile:hover {
    transform: translateY(-1px);
    filter: brightness(1.02);
    color: #fff;
}

.modern-card[data-card-link] {
    cursor: pointer;
}

.modern-card[data-card-link]:focus-visible {
    outline: 3px solid rgba(26, 136, 188, 0.35);
    outline-offset: 3px;
}

/* Price Tag */
.price-tag {
    font-weight: 800;
    color: #333;
    font-size: 1.1rem;
}

/* Select2 overrides for modern look */
.select2-container--default:not(.select2-encuentra-container) .select2-selection--single {
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    height: auto !important;
    padding: 0.4rem !important;
}

.select2-container--default:not(.select2-encuentra-container) .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
}

.select2-dropdown:not(.select2-encuentra) {
    border-color: #e0e0e0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 991px) {
    .search-grid {
        grid-template-columns: 1fr;
    }

    .btn-toggle-filters {
        display: block;
    }

    .search-sidebar {
        margin-bottom: 0;
        position: static;
        max-height: none;
        overflow: visible;
    }

    /* Filter Overlay Mobile */
    .search-sidebar-wrapper {
        position: fixed;
        /* Position below navbar */
        top: var(--navbar-offset, 70px);
        left: 0;
        right: 0;
        bottom: auto;
        height: calc(var(--filters-vh, 1vh) * 100 - var(--navbar-offset, 70px));
        z-index: 1040;
        padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
        background: transparent;
        overflow: visible;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }

    .search-sidebar-wrapper::before {
        content: "";
        position: fixed;
        top: var(--navbar-offset, 70px);
        left: 0;
        right: 0;
        bottom: auto;
        height: calc(var(--filters-vh, 1vh) * 100 - var(--navbar-offset, 70px));
        background:
            radial-gradient(circle at 15% 20%, rgba(226, 243, 255, 0.78), rgba(226, 243, 255, 0.12)),
            radial-gradient(circle at 85% 30%, rgba(255, 224, 186, 0.48), rgba(255, 224, 186, 0)),
            rgba(15, 23, 42, 0.18);
        backdrop-filter: blur(16px) saturate(130%);
        -webkit-backdrop-filter: blur(16px) saturate(130%);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
        opacity: 0;
        transition: opacity 0.22s ease;
    }

    .search-sidebar-wrapper.is-open {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
    }

    .search-sidebar-wrapper.is-open::before {
        opacity: 1;
    }

    .search-sidebar-wrapper.is-open.is-closing {
        opacity: 0;
        pointer-events: none;
    }

    .search-sidebar-wrapper.is-open.is-closing::before {
        opacity: 0;
    }

    /* Hide the duplicate "blue" header from partials on mobile */
    .search-sidebar h3 {
        display: none;
    }

    .filters-sheet {
        height: 100%;
        max-width: 920px;
        margin: 0 auto;
        background: rgba(255, 255, 255, 0.98);
        border-radius: 18px;
        box-shadow: none;
        border: 1px solid rgba(2, 6, 23, 0.08);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        transform: translateY(10px);
        opacity: 0;
        transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.24s ease;
        will-change: transform;
    }

    .search-sidebar-wrapper.is-open .filters-sheet {
        transform: translateY(0);
        opacity: 1;
    }

    .search-sidebar-wrapper.is-open.is-closing .filters-sheet {
        transform: translateY(-110%);
        opacity: 0;
    }

    .filters-sheet__handle {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 0 0.25rem;
        touch-action: none;
    }

    .filters-sheet__grabber {
        width: 44px;
        height: 5px;
        border-radius: 999px;
        background: rgba(15, 23, 42, 0.18);
    }

    .filters-sheet__header {
        padding: 0.75rem 1rem 0.85rem;
        border-bottom: 1px solid rgba(2, 6, 23, 0.08);
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .sidebar-column-container {
        /* Fixed Trigger Button */
        display: block;
        margin-bottom: 0;
        position: fixed;
        top: var(--navbar-offset, 70px);
        left: 0;
        right: 0;
        z-index: 1035;
        padding: 0.75rem 1rem 0rem 1rem;
        /* Adjust padding to sit nicely */
        margin: 0;
        pointer-events: none;
        /* Button re-enables events */
        transform: translateZ(0);
        /* Force GPU layer */
    }

    /* Spacer for flow content */
    .sidebar-column-wrapper {
        min-height: 76px;
    }

    .sidebar-column-container .btn-toggle-filters {
        pointer-events: auto;
        /* Re-enable clicks on button */
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        border: 1px solid rgba(0, 0, 0, 0.05);
        color: var(--secondary-color);
        border-radius: 50rem;
        /* Pill shape */
        padding: 0.75rem 1.25rem;
        transition: transform 0.2s ease, opacity 0.2s;
    }

    .sidebar-column-container .btn-toggle-filters:active {
        transform: scale(0.98);
    }

    .sidebar-content {
        display: block;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        position: relative;
        padding: 1rem 1rem 1.25rem;
    }

    .search-sidebar-wrapper .search-sidebar {
        /* Reset styles inside overlay */
        box-shadow: none;
        background: transparent;
        padding: 0;
        margin: 0;
    }

    .filters-sheet .filter-group {
        margin-bottom: 0.9rem;
        padding: 0.9rem;
        border-radius: 14px;
        border: 1px solid rgba(2, 6, 23, 0.08);
        background: rgba(248, 250, 252, 0.92);
    }

    .filters-sheet .filter-label {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }

    /* GLOBAL LOCATION INLINE RESULTS (Hero & Search Page) */
    .location-inline-results {
        position: absolute;
        left: 0;
        right: 0;
        top: calc(100% + 4px);
        z-index: 1060;
        /* Higher than glass panels */
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        padding: 0;
        overflow: hidden;
    }

    .location-inline-results .select2-results__option {
        padding: 10px 14px;
        font-size: 0.95rem;
        color: #333;
        border-bottom: 1px solid #f5f5f5;
        cursor: pointer;
    }

    .location-inline-results .select2-results__option:last-child {
        border-bottom: none;
    }

    .location-inline-results .select2-results__option--highlighted {
        background-color: #f0f9ff;
        color: #1a88bc;
    }

    .location-inline-results .select2-results__message {
        color: #666;
        font-size: 0.9rem;
        text-align: center;
        padding: 16px;
        font-style: italic;
    }

    /* Scoped overrides if needed */
    .filters-sheet .location-inline-results {
        z-index: 6;
    }

    .filters-sheet .filter-group.location-inline-group {
        position: relative;
        z-index: 1;
    }

    .filters-sheet .filter-group.location-inline-group.is-open {
        z-index: 5;
    }

    .filters-sheet .location-inline-results {
        position: absolute;
        left: 0;
        right: 0;
        top: calc(100% + 8px);
        z-index: 6;
        /* Match Select2 styles */
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        padding: 0;
    }

    .filters-sheet .location-inline-results .select2-results__option {
        padding: 8px 12px;
        font-size: 0.95rem;
        color: #333;
    }

    .filters-sheet .location-inline-results .select2-results__option--highlighted {
        background-color: #f0f0f0;
        color: #333;
    }

    .filters-sheet .location-inline-results .select2-results__message {
        color: #999;
        font-size: 0.9rem;
        text-align: center;
        padding: 12px;
    }

    .filters-sheet .location-inline-input::placeholder {
        color: rgba(15, 23, 42, 0.45);
    }

    body.em-location-inline-open .search-page-container .filters-sheet .sidebar-content {
        overflow-y: auto;
        overflow-x: visible;
    }

    /* En el sheet móvil, los estilos "hero" de .pianist-search-form (max-width centrado) rompen la alineación.
       Aquí deben ocupar todo el ancho del grupo de filtro. */
    .filters-sheet .pianist-search-form .form-select,
    .filters-sheet .pianist-search-form .form-control,
    .filters-sheet .pianist-search-form .btn-search,
    .filters-sheet .select2-encuentra-container {
        max-width: none !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .btn-toggle-filters {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes premiumFadeIn {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@media (min-width: 992px) {
    .search-sidebar h3 {
        display: block;
    }
}

@media (max-width: 991px) {
    body.em-select2-open--location .search-page-container .select2-container--open.select2-encuentra-container--location .select2-selection--single {
        opacity: 0;
    }
}

.search-hero-title {
    background: linear-gradient(135deg, var(--accent-color) 0%, #2c3e50 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: inline-block;
}