/* ============================================================
   TAGS / THEMES — Verse Tagging Feature Styles
   ============================================================ */

/* --- Preset Color Palette --- */
:root {
    --tag-red:    #E57373;
    --tag-orange: #FFB74D;
    --tag-yellow: #F9A825;
    --tag-green:  #81C784;
    --tag-blue:   #64B5F6;
    --tag-purple: #BA68C8;
}

/* ============================================================
   VERSE TAG DOTS — colored dots before verse numbers
   ============================================================ */

.verse-tag-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 6px;
    vertical-align: middle;
}

.verse-tag-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: default;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ============================================================
   TAG VERSE BUTTON — 🏷 button on each verse
   ============================================================ */

/* In .verse-action-bar, base styling handled by .verse-action-btn */
/* Standalone .tag-verse-btn (study console) keeps own styles */
.tag-verse-btn:not(.verse-action-btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.35rem;
    background: var(--surface);
    border: 1px solid rgba(var(--border-rgb), 0.4);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.5;
    transition: all 0.2s ease;
    vertical-align: middle;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.verse-container:hover .tag-verse-btn:not(.verse-action-btn),
.tag-verse-btn:not(.verse-action-btn):focus {
    opacity: 1;
}

.tag-verse-btn:not(.verse-action-btn):hover {
    background: var(--highlight);
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(var(--primary-rgb), 0.15);
}

.tag-verse-btn:not(.verse-action-btn).has-tags {
    opacity: 1;
    border-color: rgba(var(--primary-rgb), 0.25);
    background: rgba(var(--primary-rgb), 0.04);
}

/* ============================================================
   TAG PICKER POPOVER
   ============================================================ */

.tag-picker {
    position: fixed;
    z-index: 25000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    width: 260px;
    padding: 0.75rem;
    display: none;
}

.tag-picker.visible {
    display: block;
}

.tag-picker-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Existing tag chips inside picker */
.tag-picker-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 0.75rem;
    min-height: 28px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px 3px 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, box-shadow 0.1s;
    color: #fff;
    user-select: none;
}

.tag-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Unassigned state — lighter / outline style */
.tag-chip.unassigned {
    opacity: 0.45;
    color: var(--text-primary);
    background: var(--background) !important;
    border-color: var(--border);
}

.tag-chip.unassigned:hover {
    opacity: 0.75;
}

.tag-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-chip-delete {
    margin-left: 2px;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    cursor: pointer;
}

.tag-chip:hover .tag-chip-delete {
    opacity: 0.7;
}

.tag-chip-delete:hover {
    opacity: 1 !important;
    color: #E57373;
}

.tag-picker-empty-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* New tag form */
.tag-picker-new {
    border-top: 1px solid var(--border);
    padding-top: 0.65rem;
    margin-top: 0.1rem;
}

.tag-picker-new-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.tag-picker-new-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tag-picker-name-input {
    flex: 1;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: inherit;
    background: var(--background);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.tag-picker-name-input:focus {
    border-color: var(--primary);
}

.tag-picker-add-btn {
    padding: 0.3rem 0.6rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
    white-space: nowrap;
}

.tag-picker-add-btn:hover {
    background: var(--primary-dark);
}

/* Color swatches */
.tag-picker-colors {
    display: flex;
    gap: 6px;
    margin: 0.4rem 0 0;
}

.tag-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.1s;
    flex-shrink: 0;
}

.tag-color-swatch:hover {
    transform: scale(1.2);
}

.tag-color-swatch.selected {
    border-color: var(--text-primary);
    transform: scale(1.15);
}

.tag-color-custom {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px dashed var(--text-secondary, #999);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s, border-color 0.1s;
}
.tag-color-custom:hover {
    transform: scale(1.2);
    border-color: var(--text-primary);
}
.tag-color-custom-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary, #999);
    pointer-events: none;
}
.tag-color-custom-input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* ============================================================
   SIDEBAR TAGS PANEL
   ============================================================ */

.tags-panel-empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem 1rem;
    line-height: 1.6;
}

.tag-group {
    margin-bottom: 1.25rem;
}

.tag-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.4rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.tag-group-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 7px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    flex: 1;
    min-width: 0;
}

.tag-group-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    flex-shrink: 0;
}

.tag-group-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.tag-group-edit,
.tag-group-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0 2px;
    line-height: 1;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s, opacity 0.15s;
    flex-shrink: 0;
    opacity: 0;
}
.tag-group-header:hover .tag-group-edit,
.tag-group-header:hover .tag-group-delete {
    opacity: 0.7;
}
@media (hover: none) {
    .tag-group-edit,
    .tag-group-delete { opacity: 0.7; }
}

.tag-group-edit:hover {
    opacity: 1 !important;
    color: var(--text-primary, #2d3748);
}

.tag-group-delete:hover {
    opacity: 1 !important;
    color: #E57373;
    background: rgba(229, 115, 115, 0.1);
}

.tag-group-edit-input {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 10px;
    padding: 2px 8px;
    outline: none;
    min-width: 80px;
    max-width: 160px;
}

.tag-verse-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-left: 4px;
}

.tag-verse-ref {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: background 0.12s;
}

.tag-verse-ref:hover {
    background: var(--highlight);
    color: var(--primary);
}

.tag-verse-ref-label {
    font-weight: 500;
}

.tag-verse-unassign {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
    line-height: 1;
}

.tag-verse-ref:hover .tag-verse-unassign {
    opacity: 1;
}

.tag-verse-unassign:hover {
    color: #E57373;
}

/* ─── Collapsible Tag Groups ─── */

.tag-browse-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.tag-expand-all-btn,
.tag-collapse-all-btn {
    flex: 1;
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.tag-expand-all-btn:hover,
.tag-collapse-all-btn:hover {
    background: var(--highlight);
    color: var(--text-primary);
}

.tag-group-header {
    cursor: pointer;
    user-select: none;
}

.tag-group-arrow {
    font-size: 0.65rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 12px;
    text-align: center;
    transition: transform 0.15s;
}

.tag-verse-list-hidden {
    display: none !important;
}

.tag-group.collapsed .tag-group-header {
    margin-bottom: 0;
    padding-bottom: 0.3rem;
}

.tag-group.collapsed {
    margin-bottom: 0.5rem;
}

.tag-group.expanded {
    margin-bottom: 1.25rem;
}

/* ─── Tag Section Headers (Study / Bible / Lexicon) ─── */

.tag-section {
    margin-bottom: 0.5rem;
}

.tag-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.25rem;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    transition: background 0.12s;
}

.tag-section-header:hover {
    background: var(--highlight);
}

.tag-section-arrow {
    font-size: 0.6rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 12px;
    text-align: center;
}

.tag-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.tag-section-count {
    font-size: 0.65rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-left: auto;
}

.tag-section-body {
    padding-left: 0.25rem;
}

.tag-section-body-hidden {
    display: none;
}

/* ─── Word Tag Refs (Strong's numbers in Lexicon section) ─── */

.tag-word-ref {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: background 0.12s;
}

.tag-word-ref:hover {
    background: var(--highlight);
    color: var(--primary);
}

.tag-word-ref-num {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(91,75,138,0.1);
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

.tag-word-ref-lemma {
    font-weight: 400;
    font-size: 0.85rem;
    font-family: 'Times New Roman', Georgia, 'Arial Hebrew', serif;
}

.tag-word-ref-translit {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.tag-word-unassign {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
    line-height: 1;
    margin-left: auto;
    flex-shrink: 0;
}

.tag-word-ref:hover .tag-word-unassign {
    opacity: 1;
}

.tag-word-unassign:hover {
    color: #E57373;
}

/* ─── Commentary Tag Refs (source + verse in Commentary section) ─── */

.tag-commentary-ref {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: background 0.12s;
}

.tag-commentary-ref:hover {
    background: var(--highlight);
    color: var(--primary);
}

.tag-commentary-ref-source {
    font-size: 0.68rem;
    font-weight: 700;
    color: #D4A017;
    background: rgba(212,160,23,0.1);
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

.tag-commentary-unassign {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
    line-height: 1;
    margin-left: auto;
    flex-shrink: 0;
}

.tag-commentary-ref:hover .tag-commentary-unassign {
    opacity: 1;
}

.tag-commentary-unassign:hover {
    color: #E57373;
}

/* ─── Dual-Layer Tag Styles ─── */

/* Study-layer tag dots — open ring with dashed border */
.verse-tag-dot.study-layer {
    background: transparent !important;
    border: 2px dashed;
    box-sizing: border-box;
    box-shadow: none;
    width: 11px;
    height: 11px;
}

/* Study-layer tag chips — dashed border */
.tag-chip.study-layer {
    border-style: dashed !important;
}

/* Tag picker layer badge */
.tag-picker-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tag-picker-layer {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: auto;
}

.tag-picker-layer.permanent {
    background: var(--primary);
    color: #fff;
}

.tag-picker-layer.study {
    background: var(--tag-orange);
    color: #fff;
    border: 1px dashed rgba(255,255,255,0.5);
}

/* Sidebar tag verse layer indicators */
.tag-verse-layer {
    font-size: 0.55rem;
    font-weight: 700;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.tag-verse-layer.study {
    background: var(--primary);
    color: #fff;
}

.tag-verse-layer.study {
    background: var(--tag-orange);
    color: #fff;
    border: 1px dashed rgba(255,255,255,0.4);
}

/* ─── TagPicker Auto-Close Countdown ─── */

.tag-picker-autoclose {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.tag-picker-autoclose-text {
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.3rem;
}

.tag-picker-autoclose-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.tag-picker-autoclose-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 100%;
}

/* ============================================================
   WORD STUDY — Save/Open button in Strong's display
   ============================================================ */

.strongs-word-study-btn {
    display: block;
    width: calc(100% - 1rem);
    margin: 0 0.5rem 0.75rem;
    padding: 0.35rem 0.75rem;
    background: var(--highlight);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.strongs-word-study-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.strongs-word-study-btn.has-study {
    color: var(--primary);
    border-color: var(--primary-light);
    background: rgba(91, 75, 138, 0.06);
}

.strongs-word-study-btn.has-study:hover {
    background: var(--primary);
    color: #fff;
}

/* ============================================================
   WORD STUDY PANEL — inline notes below Strong's definition
   ============================================================ */

.word-study-panel {
    border-top: 2px solid var(--primary);
    padding: 0.75rem;
    background: var(--surface);
    flex-shrink: 0;
}

.word-study-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.word-study-panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}

.word-study-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    border-radius: 3px;
    transition: color 0.12s;
}

.word-study-delete-btn:hover {
    color: #E57373;
}

.word-study-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--text-primary);
    background: var(--background);
    resize: vertical;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.15s;
}

.word-study-textarea:focus {
    border-color: var(--primary);
}

.word-study-panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.4rem;
}

.word-study-updated {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.word-study-save-btn {
    padding: 0.25rem 0.65rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.word-study-save-btn:hover {
    background: var(--primary-dark);
}

/* ============================================================
   WORD STUDY LIST — in the Dictionary sidebar tab
   ============================================================ */

.word-study-list-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
}

.word-study-list-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.word-study-list-item {
    padding: 0.5rem 0.6rem;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 4px;
    border: 1px solid var(--border);
}

.word-study-list-item:hover {
    background: var(--highlight);
}

.word-study-list-ref {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 3px;
}

.word-study-list-num {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(91,75,138,0.1);
    padding: 1px 5px;
    border-radius: 3px;
}

.word-study-list-lemma {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.word-study-list-translit {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.word-study-list-preview {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 3px;
}

.word-study-list-preview.empty {
    font-style: italic;
    opacity: 0.6;
}

.word-study-list-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.word-study-list-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0 2px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
}

.word-study-list-item:hover .word-study-list-delete {
    opacity: 1;
}

.word-study-list-delete:hover {
    color: #E57373;
}

.word-study-add-study {
    margin-left: auto;
    background: none;
    border: 1px solid #667eea;
    color: #667eea;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.word-study-add-study:hover {
    background: #667eea;
    color: #fff;
}

.word-study-add-study:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ─── Word Tag "W" Dots (Row below verse) ─── */

.verse-word-tag-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 2px 0 0 20px;
    flex-wrap: wrap;
}

.verse-tag-dot.word-layer {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    cursor: default;
}

/* Tag picker word-layer badge */
.tag-picker-layer.word {
    background: #7986CB;
    color: #fff;
}

/* ── Strong's Sidebar Inline Tag/Note Controls ── */
.strongs-number-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.strongs-inline-tag-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
/* Strong's inline tag/note buttons use .verse-action-btn from styles.css */

/* ────────────────────────────────────────────────────────────────────────────
   MOBILE — center tag picker in viewport instead of anchoring to element
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .tag-picker.visible {
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%);
        width: min(300px, 92vw);
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* ────────────────────────────────────────────────────────────────────────────
   TOUCH DEVICES — show hover-only action buttons at reduced opacity
   ──────────────────────────────────────────────────────────────────────────── */
@media (hover: none) {
    .tag-verse-btn { opacity: 0.7; }
    .tag-chip-delete { opacity: 0.7; }
    .tag-verse-unassign { opacity: 0.7; }
    .tag-word-unassign { opacity: 0.7; }
    .word-study-list-delete { opacity: 0.7; }
}
