/* =====================================================
   CONTROL FILTRE AVANSATE - drawer slide din dreapta
   Folosit pe: Lista-Clinici, Default, Harta-Clinici
   ===================================================== */

/* ===== Animatii ===== */

@keyframes fadeInOverlayFiltre {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
}

@keyframes fadeOutOverlayFiltre {
    from {
        opacity: 1;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
}

@keyframes slideInFromRightFiltre {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

@keyframes slideOutToRightFiltre {
    from { transform: translateX(0); }
    to   { transform: translateX(100%); }
}

/* ===== Container overlay (ascuns implicit) ===== */

.divFiltreAvansateContainer {
    display: none;
}

/* ===== Drawer panel (ascuns implicit) ===== */

.divFiltreParent {
    display: none;
    flex-direction: column;
    background: #FFF;
    padding: 40px 70px 30px 70px;
    border-radius: 10px;
    border: 1px solid #D9D9D9;
    box-shadow: 0px 2px 4px 0px rgba(16, 40, 16, 0.25);
    margin: auto;
    float: none;
    box-sizing: border-box;
    width: 100%;
}

/* ===== Header drawer (titlu + buton inchidere) ===== */

.divHeaderFiltreAvansate {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    min-height: 36px;
}

.titluFiltreAvansate {
    color: #7563F8;
    font-size: 22px;
    font-weight: 700;
    font-family: Raleway, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

.btnInchideFiltre {
    color: #7563F8;
    position: absolute;
    top: -20px;
    right: -100px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    border-radius: 50px;
    border: none;
    width: 60px;
    height: 60px;
    box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 10;
}

    .btnInchideFiltre i {
        font-size: 30px !important;
    }

/* ===== Layout categorii filtre ===== */

.filtreAvansateWrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: stretch;
}

.categorieGrup {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: stretch;
}

.categorieFiltre {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

    .categorieFiltre > * {
        width: 100%;
    }

.titluCategorieFiltre {
    color: #7563F8;
    font-size: 18px;
    font-weight: 600;
    line-height: normal;
    padding: 10px 15px 10px 0px;
    border-bottom: 1px solid #7563F8;
    margin-bottom: 15px;
}

/* Subliniere subtila a unui checkbox bifat */
.customChkContainer:has(input[type="checkbox"]:checked) .customChkText {
    color: #5544cc !important;
    font-weight: 600 !important;
}

/* ===== Butoane Sterge / Aplica ===== */

.divBtnFiltruWrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

.btnAplicaFiltre {
    padding: 10px 35px;
    border-radius: 5px;
    border: 1px solid #7563F8;
    background: #7563F8;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}

.btnStergeFiltre {
    outline: none;
    border-radius: 5px;
    border: 1px solid #AFA7EE;
    background: none;
    color: #7563F8;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 25px;
    cursor: pointer;
}

label {
    margin-bottom: 0 !important;
}

/* ===== Dropdown custom "Deschis dupa ora" ===== */

.dboBoxNativOra {
    display: none !important;
}

.customSelectOra {
    position: relative;
    width: 140px;
    height: 38px;
}

.customSelectOraTrigger {
    width: 100%;
    height: 100%;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: #50596c;
    font-family: Raleway, sans-serif;
    font-weight: 500;
    cursor: pointer;
    list-style: none;
    user-select: none;
    box-sizing: border-box;
    outline: none;
    background: #fff;
    border: 1px solid #b8c0d0;
    border-radius: 8px;
    transition: border-color 0.15s ease;
}

    .customSelectOraTrigger::-webkit-details-marker { display: none; }
    .customSelectOraTrigger::marker { content: ""; }

.customSelectOra:hover .customSelectOraTrigger {
    border-color: #7563F8;
}

.customSelectOra[open] .customSelectOraTrigger {
    border-color: #7563F8;
    box-shadow: 0 0 0 3px rgba(117, 99, 248, 0.15);
}

.customSelectOraLabel {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .customSelectOraLabel.placeholder {
        color: #b8c0d0;
        font-weight: 400;
    }

.customSelectOraChevron {
    width: 10px;
    height: 10px;
    fill: #7563F8;
    flex-shrink: 0;
    margin-left: 8px;
    transition: transform 0.2s ease;
}

.customSelectOra[open] .customSelectOraChevron {
    transform: rotate(180deg);
}

.customSelectOraPanel {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #b8c0d0;
    border-radius: 10px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    max-height: 260px;
    overflow-y: auto;
    z-index: 100;
    padding: 6px;
}

.customSelectOraItem {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #50596c;
    font-family: Raleway, sans-serif;
    border-radius: 6px;
    transition: background-color 0.15s, color 0.15s;
}

    .customSelectOraItem:hover {
        background-color: #f9f7ff;
        color: #7563F8;
    }

/* Stil filtru activ - cand e selectata o ora */
.customSelectOra:has(.customSelectOraLabel:not(.placeholder)) .customSelectOraTrigger {
    background: #f3eefe;
    border-color: #7563F8;
    color: #5544cc;
}

/* ===== Drawer DESKTOP (>= 768px) ===== */

@media (min-width: 768px) {
    /* Overlay full-screen pe desktop, ancorat la dreapta */
    .divFiltreAvansateContainer {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        margin: 0;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 1000;
        overflow: hidden;
        padding: 0;
        align-items: stretch;
        justify-content: flex-end;
        animation: fadeInOverlayFiltre 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
    }

        .divFiltreAvansateContainer .divFiltreParent {
            width: clamp(320px, calc((100vw - 1100px) / 2), 460px) !important;
            max-width: 460px !important;
            height: 100vh !important;
            margin: 0 !important;
            position: relative;
            overflow-y: hidden !important;
            border-radius: 0 !important;
            border: none !important;
            box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15) !important;
            padding: 28px 28px !important;
            animation: slideInFromRightFiltre 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
            display: flex !important;
            flex-direction: column;
        }

        /* Buton X inline cu titlul pe drawer-ul desktop */
        .divFiltreAvansateContainer .btnInchideFiltre {
            position: static;
            top: auto;
            right: auto;
            left: auto;
            transform: none;
            width: 36px !important;
            height: 36px !important;
            flex-shrink: 0;
        }

            .divFiltreAvansateContainer .btnInchideFiltre i {
                font-size: 20px !important;
            }

        .divFiltreAvansateContainer .divHeaderFiltreAvansate {
            flex-shrink: 0;
        }

        /* Scroll intern doar pe filtre */
        .divFiltreAvansateContainer .filtreAvansateWrapper {
            flex: 1 1 auto;
            overflow-y: auto;
            min-height: 0;
            padding-right: 8px;
            /* Scrollbar subtire (Firefox) */
            scrollbar-width: thin;
            scrollbar-color: #AFA7EE transparent;
        }

        /* Scrollbar subtire (Chrome / Edge / Safari) */
        .divFiltreAvansateContainer .filtreAvansateWrapper::-webkit-scrollbar {
            width: 6px;
        }

        .divFiltreAvansateContainer .filtreAvansateWrapper::-webkit-scrollbar-track {
            background: transparent;
        }

        .divFiltreAvansateContainer .filtreAvansateWrapper::-webkit-scrollbar-thumb {
            background-color: #AFA7EE;
            border-radius: 10px;
        }

            .divFiltreAvansateContainer .filtreAvansateWrapper::-webkit-scrollbar-thumb:hover {
                background-color: #7563F8;
            }

        /* Butoanele Aplica / Sterge raman fixate jos */
        .divFiltreAvansateContainer .divBtnFiltruWrapper {
            flex-shrink: 0;
            background: #FFF;
            padding-top: 20px;
            margin-top: 0;
            border-top: 1px solid #f0f0f0;
        }

        /* Animatie de iesire */
        .divFiltreAvansateContainer.is-closing {
            animation: fadeOutOverlayFiltre 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
        }

            .divFiltreAvansateContainer.is-closing .divFiltreParent {
                animation: slideOutToRightFiltre 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
            }
}

@media (min-width: 768px) {
    .btnStergeFiltre,
    .btnAplicaFiltre {
        width: 120px;
    }
}

/* ===== Drawer MOBILE (< 768px) ===== */

@media (max-width: 768px) {
    .divFiltreAvansateContainer {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 1000;
        animation: fadeInOverlayFiltre 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
    }

    .divFiltreParent {
        height: 100%;
        padding: 0;
        border: none;
        overflow-y: hidden !important;
        z-index: 1000;
        animation: slideInFromRightFiltre 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
        display: flex !important;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        scrollbar-width: none;
    }

        .divFiltreParent::-webkit-scrollbar { width: 0; }
        .divFiltreParent::-webkit-scrollbar-button { display: none; }

    .divFiltreAvansateContainer.is-closing {
        animation: fadeOutOverlayFiltre 0.25s cubic-bezier(0.4, 0, 0.6, 1) forwards;
    }

        .divFiltreAvansateContainer.is-closing .divFiltreParent {
            animation: slideOutToRightFiltre 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
        }

    .divHeaderFiltreAvansate {
        background: #F9FAFB;
        min-height: 80px;
        position: sticky;
        top: 0;
        z-index: 15000;
        flex-shrink: 0;
        padding: 20px 20px 0 20px;
    }

        .divHeaderFiltreAvansate.onScroll {
            box-shadow: 0 3px 4px 0px rgba(187, 187, 187, 0.30);
        }

    .titluFiltreAvansate {
        font-size: 20px;
    }

    .btnInchideFiltre {
        position: static !important;
        width: 40px !important;
        height: 40px !important;
        transform: none !important;
        background-color: #fff !important;
        box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.25) !important;
        flex-shrink: 0;
        margin-left: auto;
    }

        .btnInchideFiltre i {
            font-size: 22px !important;
        }

    .filtreAvansateWrapper {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
        background-color: #F9FAFB;
        padding: 20px 30px;
        flex-direction: column;
        gap: 20px;
        /* Scrollbar subtire (Firefox) */
        scrollbar-width: thin;
        scrollbar-color: #AFA7EE transparent;
    }

        /* Scrollbar subtire (Chrome / Edge / Safari) */
        .filtreAvansateWrapper::-webkit-scrollbar {
            width: 6px;
        }

        .filtreAvansateWrapper::-webkit-scrollbar-track {
            background: transparent;
        }

        .filtreAvansateWrapper::-webkit-scrollbar-thumb {
            background-color: #AFA7EE;
            border-radius: 10px;
        }

    .categorieGrup {
        flex-direction: column;
        gap: 20px;
        width: 100%;
        flex-wrap: nowrap;
    }

    .categorieGrup,
    .categorieFiltre {
        width: 100%;
        min-width: unset;
        flex: unset;
    }

    .divBtnFiltruWrapper {
        justify-content: space-between;
        align-items: center;
        margin-top: 0 !important;
        flex-shrink: 0;
        background: #fff;
        padding: 15px 20px;
        width: 100%;
        box-shadow: 0px -3px 4px 0px rgba(187, 187, 187, 0.30);
    }

    .btnStergeFiltre { width: 30%; }
    .btnAplicaFiltre { width: 70%; }
    .customChkRate { width: 180px; }
}

@media screen and (max-width: 1200px) {
    .filtreAvansateWrapper,
    .categorieGrup {
        gap: 25px;
    }
}

@media screen and (max-width: 992px) {
    .filtreAvansateWrapper {
        flex-direction: column;
        gap: 20px;
    }

    .categorieGrup {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 20px;
    }

    .categorieFiltre {
        min-width: 140px;
    }
}

/* =====================================================
   Override-uri defensive
   Filtru-DefaultSiHarta.css (folosit încă de Harta-Clinici) definește reguli
   pentru drawer-ul vechi (.divFiltreParent, .btnInchideFiltre, etc.) cu !important.
   Aici le anulăm explicit doar când drawer-ul nou e activ (selector cu prefix
   .divFiltreAvansateContainer pentru specificitate mai mare).
   ===================================================== */

.divFiltreAvansateContainer .divHeaderFiltreAvansate {
    height: auto !important;
}

.divFiltreAvansateContainer .filtreAvansateWrapper {
    flex-direction: column;
}

.divFiltreAvansateContainer .categorieGrup {
    flex-direction: column;
    gap: 30px;
}

.divFiltreAvansateContainer .categorieFiltre {
    min-width: 0;
}

/* FORțEAZĂ ordinea text -> checkmark.
   Pe Harta s-a observat că elementele apar inversate (checkmark stânga / text dreapta)
   probabil din cauza unei reguli moștenite. Forțăm explicit ordinea stânga→dreapta
   indiferent de orice override extern. */
.divFiltreAvansateContainer .customChkContainer {
    flex-direction: row !important;
}

    .divFiltreAvansateContainer .customChkContainer > .customChkText {
        order: 0 !important;
    }

    .divFiltreAvansateContainer .customChkContainer > .customCheckmark {
        order: 1 !important;
    }

/* DESKTOP-only overrides: drawer slide din dreapta, NU centrat ca modalul vechi.
   Vechiul CSS forțează top:50%, left:50%, transform:translate(-50%,-50%) care ar
   împinge drawer-ul în afara ecranului după ce animația se termină. */
@media (min-width: 768px) {
    .divFiltreAvansateContainer .divFiltreParent {
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none;
        max-height: none !important;
        border: none !important;
        border-radius: 0 !important;
    }

    .divFiltreAvansateContainer .btnInchideFiltre {
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        width: 36px !important;
        height: 36px !important;
        box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.25) !important;
    }

        .divFiltreAvansateContainer .btnInchideFiltre i {
            font-size: 20px !important;
        }
}

/* MOBILE-only overrides: drawer fullscreen ancorat la top:0, left:0.
   IMPORTANT: vechiul CSS pune .divBtnFiltruWrapper { position:fixed; bottom:0; height:100px }
   ceea ce scoate butoanele din flex flow și face să acopere conținutul. Le forțăm
   înapoi în flex layout (position:static, height:auto, flex-shrink:0). */
@media (max-width: 768px) {
    .divFiltreAvansateContainer .divFiltreParent {
        top: 0 !important;
        left: 0 !important;
        right: auto !important;
        bottom: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border: none !important;
        border-radius: 0 !important;
    }

    /* Header mai compact pe mobile - reduce min-height + padding-top + margin-bottom
       ca să tragă conținutul mai sus. */
    .divFiltreAvansateContainer .divHeaderFiltreAvansate {
        min-height: 56px !important;
        padding: 12px 20px 0 20px !important;
        margin-bottom: 0px !important;
    }

    .divFiltreAvansateContainer .btnInchideFiltre {
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        width: 40px !important;
        height: 40px !important;
        margin-left: auto;
    }

        .divFiltreAvansateContainer .btnInchideFiltre i {
            font-size: 22px !important;
        }

    .divFiltreAvansateContainer .filtreAvansateWrapper {
        flex-direction: column;
        gap: 20px;
        padding-top: 8px !important;
        padding-bottom: 20px !important;
    }

    .divFiltreAvansateContainer .categorieGrup {
        flex-direction: column;
        gap: 20px;
    }

    /* CRITIC: anulează position:fixed din vechiul CSS care scotea butoanele din flex flow. */
    .divFiltreAvansateContainer .divBtnFiltruWrapper {
        position: static !important;
        bottom: auto !important;
        height: auto !important;
        padding: 15px 20px !important;
    }
}
