/* ============================================================
   FAB DE FILTRO (canto inferior ESQUERDO)
   ============================================================ */
#fab-filter {
    position: fixed !important;
    bottom: 84px !important;
    left: 18px !important;
    width: 58px !important;
    height: 58px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #333 0%, #1a1a1a 100%) !important;
    color: #fff !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.4) !important;
    z-index: 210 !important;
    transition: transform 0.15s ease, background 0.2s ease;
}
#fab-filter.visible { display: flex !important; }
#fab-filter:active { transform: scale(0.9); }
#fab-filter.active {
    background: linear-gradient(135deg, #E50914 0%, #b30008 100%) !important;
    border-color: rgba(229,9,20,0.6) !important;
    box-shadow: 0 8px 24px rgba(229,9,20,0.5), 0 4px 12px rgba(0,0,0,0.4) !important;
}

/* ⚡ Esconde o FAB quando qualquer tela de perfil estiver aberta */
body:has(#profileManageScreen) #fab-filter,
body:has(#profileCreateScreen) #fab-filter,
body:has(#profileSelectScreen) #fab-filter,
body:has(#detailsScreen) #fab-filter {
    display: none !important;
}

/* ============================================================
   OVERLAY
   ============================================================ */
#filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 220;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overscroll-behavior: contain;
}
#filter-overlay.visible { opacity: 1; pointer-events: auto; }

/* ⚡ Trava o scroll do body quando o filtro tá aberto */
body.filter-open {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
}
body.filter-open #app-container,
body.filter-open #bottom-nav {
    pointer-events: none;
}

/* ============================================================
   SHEET
   ============================================================ */
#filter-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85vh;
    background: #141414;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    z-index: 221;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    will-change: transform;
    touch-action: pan-y;
}
#filter-sheet.visible { transform: translateY(0); }
#filter-sheet.dragging { transition: none; }

.filter-handle-area {
    padding: 12px 0 6px 0;
    display: flex;
    justify-content: center;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
}
.filter-handle {
    width: 42px;
    height: 4px;
    background: rgba(255,255,255,0.28);
    border-radius: 2px;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 20px 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.filter-header h2 {
    font-size: 17px;
    font-weight: 800;
    color: #fff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.filter-header h2 i { color: #E50914; font-size: 15px; }

.filter-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}
.filter-close-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.15); }

/* ⚡ Body do filtro — overscroll contido pra não vazar pro fundo */
.filter-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 20px 20px 20px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.filter-group { margin-bottom: 22px; }
.filter-group:last-child { margin-bottom: 8px; }

.filter-label {
    font-size: 11px;
    font-weight: 800;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

.filter-pills-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-pills-row.filter-scroll-x {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
    overscroll-behavior-x: contain;
}
.filter-pills-row.filter-scroll-x::-webkit-scrollbar { display: none; }

.filter-pill {
    flex-shrink: 0;
    padding: 9px 16px;
    border-radius: 20px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #ccc;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.filter-pill:active { transform: scale(0.95); }
.filter-pill.active {
    background: #fff;
    color: #000;
    border-color: #fff;
    box-shadow: 0 4px 12px rgba(255,255,255,0.15);
}

.filter-actions {
    display: flex;
    gap: 10px;
    padding: 14px 20px 20px 20px;
    background: #141414;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.filter-btn-clear {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #ccc;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.filter-btn-clear:active { background: rgba(255,255,255,0.12); }

.filter-btn-apply {
    flex: 2;
    padding: 14px;
    border-radius: 12px;
    background: #E50914;
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 4px 16px rgba(229,9,20,0.4);
}
.filter-btn-apply:active { transform: scale(0.98); background: #c40812; }

@media (max-width: 600px) {
    #fab-filter { width: 54px !important; height: 54px !important; font-size: 20px !important; }
    .filter-header { padding: 6px 16px 12px 16px; }
    .filter-body { padding: 16px 16px 16px 16px; }
    .filter-actions { padding: 12px 16px 18px 16px; }
}