/* Book Highlights */

/* Highlight marks in text */
mark.book-hl,
mark.book-hl * {
    border-radius: 2px;
    cursor: pointer;
    -webkit-text-fill-color: inherit;
    color: inherit !important;
}
[data-theme="dark"] mark.book-hl,
[data-theme="dark"] mark.book-hl * {
    color: #d4d4d8 !important;
    -webkit-text-fill-color: #d4d4d8 !important;
}
.book-hl-yellow { background: rgba(250, 204, 21, 0.3); }
.book-hl-green { background: rgba(34, 197, 94, 0.3); }
.book-hl-blue { background: rgba(96, 165, 250, 0.3); }
.book-hl-pink { background: rgba(244, 114, 182, 0.3); }

[data-theme="dark"] .book-hl-yellow { background: rgba(250, 204, 21, 0.25); }
[data-theme="dark"] .book-hl-green { background: rgba(34, 197, 94, 0.25); }
[data-theme="dark"] .book-hl-blue { background: rgba(96, 165, 250, 0.25); }
[data-theme="dark"] .book-hl-pink { background: rgba(244, 114, 182, 0.25); }

/* Floating toolbar */
.book-hl-toolbar {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 9500;
    animation: hlToolbarIn 0.12s ease-out;
}

[data-theme="dark"] .book-hl-toolbar {
    background: rgba(40, 40, 60, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

@keyframes hlToolbarIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.book-hl-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    padding: 0;
}
.book-hl-dot:hover {
    transform: scale(1.2);
    border-color: rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .book-hl-dot:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.book-hl-dot-yellow { background: rgb(250, 204, 21); }
.book-hl-dot-green { background: rgb(34, 197, 94); }
.book-hl-dot-blue { background: rgb(96, 165, 250); }
.book-hl-dot-pink { background: rgb(244, 114, 182); }

.book-hl-dot-erase {
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #999;
    border: 1px solid rgba(0, 0, 0, 0.15);
}
.book-hl-dot-erase:hover { color: #e74c3c; border-color: #e74c3c; }
[data-theme="dark"] .book-hl-dot-erase { color: #777; border-color: rgba(255,255,255,0.15); }
[data-theme="dark"] .book-hl-dot-erase:hover { color: #e74c3c; border-color: #e74c3c; }

/* Note button in toolbar */
.book-hl-dot-note {
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #666;
    border: 1px solid rgba(0, 0, 0, 0.15);
}
.book-hl-dot-note:hover { color: #7c3aed; border-color: #7c3aed; }
[data-theme="dark"] .book-hl-dot-note { color: #888; border-color: rgba(255,255,255,0.15); }
[data-theme="dark"] .book-hl-dot-note:hover { color: #a78bfa; border-color: #a78bfa; }

/* Has-note indicator (small dot on highlighted text) */
mark.book-hl.has-note { position: relative; }
mark.book-hl.has-note::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7c3aed;
}
[data-theme="dark"] mark.book-hl.has-note::after { background: #a78bfa; }

/* Highlight popover (shown on click/tap of existing highlight) */
.book-hl-popover {
    position: absolute;
    min-width: 180px;
    max-width: 260px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9501;
    animation: hlToolbarIn 0.12s ease-out;
}
[data-theme="dark"] .book-hl-popover {
    background: rgba(40, 40, 60, 0.97);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.book-hl-popover-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}
.book-hl-popover-note {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--ch-text-primary, #374151);
    padding: 2px 0 6px;
    word-wrap: break-word;
}
[data-theme="dark"] .book-hl-popover-note { color: #d1d5db; }
.book-hl-popover-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(0,0,0,0.06);
    padding-top: 6px;
}
[data-theme="dark"] .book-hl-popover-actions { border-top-color: rgba(255,255,255,0.08); }
.book-hl-popover-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.book-hl-popover-btn:hover { color: #7c3aed; background: rgba(139,92,246,0.08); }
.book-hl-popover-btn-danger:hover { color: #e74c3c; background: rgba(231,76,60,0.08); }
[data-theme="dark"] .book-hl-popover-btn { color: #999; }
[data-theme="dark"] .book-hl-popover-btn:hover { color: #a78bfa; }
[data-theme="dark"] .book-hl-popover-btn-danger:hover { color: #e74c3c; }

/* Active color indicator on dots */
.book-hl-dot.active-color { border-color: rgba(0,0,0,0.4) !important; transform: scale(1.15); }
[data-theme="dark"] .book-hl-dot.active-color { border-color: rgba(255,255,255,0.5) !important; }

/* Note popover */
.book-hl-note-popover {
    position: absolute;
    width: 240px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9501;
    animation: hlToolbarIn 0.12s ease-out;
}
[data-theme="dark"] .book-hl-note-popover {
    background: rgba(40, 40, 60, 0.97);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.book-hl-note-input {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 8px;
    font-size: 0.82rem;
    font-family: inherit;
    resize: vertical;
    background: transparent;
    color: inherit;
    outline: none;
}
.book-hl-note-input:focus { border-color: #7c3aed; }
[data-theme="dark"] .book-hl-note-input { border-color: rgba(255,255,255,0.15); color: #e0e0e0; }
[data-theme="dark"] .book-hl-note-input:focus { border-color: #a78bfa; }
.book-hl-note-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.book-hl-note-save {
    padding: 4px 14px;
    border: none;
    border-radius: 6px;
    background: #7c3aed;
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}
.book-hl-note-save:hover { background: #6d28d9; }

@media print {
    .book-hl-toolbar, .book-hl-note-popover { display: none !important; }
    mark.book-hl.has-note::after { display: none; }
}
