/* ===================================================================
   Shared bookmark drawer (window.BookmarkDrawer) - used by BOTH the
   web reader and the EPUB reader. Two rows: add / view.
   =================================================================== */
.bm-drawer {
    position: fixed;
    inset: 0;
    z-index: 100000;
    pointer-events: none;
    font-family: var(--font-content, 'Noto Kufi Arabic', 'Cairo', sans-serif);
}

.bm-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.bm-drawer--open .bm-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.bm-drawer-sheet {
    /* The container is pointer-events:none so clicks outside the sheet fall
       through to the backdrop. The sheet must re-enable pointer events or it
       inherits none and its buttons become click-through (drawer just closes). */
    pointer-events: auto;
    background: var(--bg-color, #fff);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
}

/* Mobile: slide-up bottom sheet */
.bm-drawer--mobile .bm-drawer-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    transform: translateY(100%);
}

.bm-drawer--mobile.bm-drawer--open .bm-drawer-sheet {
    transform: translateY(0);
    opacity: 1;
}

/* Desktop: compact popover (left/top set by JS from the trigger) */
.bm-drawer--desktop .bm-drawer-sheet {
    min-width: 232px;
    max-width: 300px;
    border-radius: 14px;
    transform: translateY(-6px) scale(0.98);
}

.bm-drawer--desktop.bm-drawer--open .bm-drawer-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.bm-drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 15px 18px;
    border: none;
    background: transparent;
    color: var(--text-color, #2c3e50);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    text-align: start;
    cursor: pointer;
    transition: background 0.15s ease;
}

.bm-drawer-item + .bm-drawer-item {
    border-top: 1px solid var(--border-color, #eee);
}

.bm-drawer-item:hover,
.bm-drawer-item:focus-visible {
    background: rgba(243, 156, 18, 0.1);
    outline: none;
}

.bm-drawer-item:active {
    background: rgba(243, 156, 18, 0.18);
}

.bm-drawer-item-icon {
    display: inline-flex;
    flex: 0 0 auto;
    color: #f39c12;
}

.bm-drawer-item-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.bm-drawer-item-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-drawer-count {
    flex: 0 0 auto;
    min-width: 22px;
    padding: 2px 8px;
    border-radius: 11px;
    background: #f39c12;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

[data-theme="dark"] .bm-drawer-sheet {
    background: var(--bg-dark, #2c3e50);
}

[data-theme="dark"] .bm-drawer-item {
    color: var(--text-color, #ecf0f1);
}

[data-theme="dark"] .bm-drawer-item + .bm-drawer-item {
    border-top-color: var(--border-color, #444);
}
