/**
 * Lexicon Study Modal — Full-screen two-panel layout
 * Left: word list (My Words / Browse / Collections tabs)
 * Right: WordStudyPanel (reuses word-study-modal.css classes)
 */

/* Backdrop — covers the full screen */
.lex-study-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10100;
    display: none;
    align-items: center;
    justify-content: center;
}

.lex-study-backdrop.visible {
    display: flex;
}

/* Modal container */
.lex-study-modal {
    width: 95vw;
    height: 92vh;
    background: var(--background);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 0 0 0.5px rgba(0, 0, 0, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.14),
        0 24px 60px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}

/* Header — clean white (matches account modal) */
.lex-study-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    flex-shrink: 0;
    cursor: grab;
}

.lex-study-header-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.lex-study-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* inject button uses shared .frosted-header-btn */
.lex-study-inject-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* close button now uses shared .frosted-close-btn in styles.css */

/* Body — two-panel layout */
.lex-study-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* Left panel — word list */
.lex-study-left {
    width: 360px;
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.09);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--highlight);
}

/* Left panel tabs */
.lex-study-left-tabs {
    display: flex;
    border-bottom: 2px solid var(--border, #e2e8f0);
    flex-shrink: 0;
}

.lex-study-left-tab {
    flex: 1;
    padding: 0.6rem 0.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary, #718096);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.lex-study-left-tab:hover {
    color: var(--text-primary, #2d3748);
}

.lex-study-left-tab.active {
    color: #007aff;
    border-bottom-color: #007aff;
}

/* Left panel content (scrollable) */
.lex-study-left-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Search bars */
.lex-study-search-bar {
    padding: 0.5rem;
    flex-shrink: 0;
}

.lex-study-search-input,
.lex-study-browse-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text-primary, #2d3748);
    box-sizing: border-box;
}

.lex-study-search-input:focus,
.lex-study-browse-search:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.14);
}

/* Language toggle */
.lex-study-lang-toggle {
    display: flex;
    gap: 0.25rem;
    padding: 0 0.5rem 0.5rem;
}

.lex-study-lang-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-secondary, #718096);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.lex-study-lang-btn.active {
    background: #007aff;
    color: white;
    border-color: #007aff;
}

.lex-study-lang-btn:hover:not(.active) {
    background: var(--highlight);
}

/* Browse header */
.lex-study-browse-header {
    flex-shrink: 0;
}

/* Word list */
.lex-study-word-list {
    padding: 0.25rem;
}

/* Word card */
.lex-study-word-card {
    padding: 0.6rem 0.75rem;
    margin: 0.25rem 0.25rem;
    background: var(--surface);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.lex-study-word-card:hover {
    border-color: #007aff;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.12);
}

.lex-study-word-card.active {
    border-color: #007aff;
    background: rgba(0, 122, 255, 0.05);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

.lex-study-word-card-top {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.lex-study-word-num {
    font-size: 0.7rem;
    font-weight: 700;
    color: #007aff;
    background: rgba(0, 122, 255, 0.08);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.lex-study-word-lemma {
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary, #2d3748);
}

.lex-study-word-translit {
    font-size: 0.8rem;
    color: var(--text-secondary, #718096);
    font-style: italic;
}

.lex-study-word-def {
    font-size: 0.78rem;
    color: var(--text-secondary, #718096);
    margin-top: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Tag dots */
.lex-study-tag-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lex-study-note-icon {
    font-size: 0.7rem;
    flex-shrink: 0;
}

/* Load More button */
.lex-study-load-more {
    display: block;
    width: calc(100% - 0.5rem);
    margin: 0.5rem 0.25rem;
    padding: 0.6rem;
    background: #007aff;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.lex-study-load-more:hover {
    background: #0066dd;
}

/* Empty state */
.lex-study-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary, #718096);
}

.lex-study-hint {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    color: var(--text-secondary, #a0aec0);
}

/* Collections */
.lex-study-collection-list {
    padding: 0.5rem;
}

.lex-study-collection-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.lex-study-collection-card:hover {
    border-color: #007aff;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.12);
}

.lex-study-collection-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lex-study-collection-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary, #2d3748);
}

.lex-study-collection-count {
    font-size: 0.75rem;
    color: var(--text-secondary, #a0aec0);
}

/* Collection detail */
.lex-study-collection-detail {
    padding: 0.5rem;
}

.lex-study-back-btn {
    background: none;
    border: 1px solid var(--border, #e2e8f0);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: #007aff;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: background 0.2s;
}

.lex-study-back-btn:hover {
    background: rgba(0, 122, 255, 0.06);
}

.lex-study-collection-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border, #e2e8f0);
    margin-bottom: 0.5rem;
}

/* Right panel — WordStudyPanel renders here */
.lex-study-right {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    min-height: 0;
}

.lex-study-right-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary, #a0aec0);
    font-size: 1rem;
}

/* Study word study injection block */
/* Shared injected block style (word study + commentary quotes in study text) */
.study-injected-block {
    display: inline-block;
    width: 100%;
    position: relative;
    margin: 0.5em 0;
    padding: 0.5em 1.8em 0.5em 0.5em;
    border-left: 3px solid #007aff;
    background: rgba(0, 122, 255, 0.04);
    border-radius: 4px;
    user-select: text;
    vertical-align: top;
}
.study-injected-block p {
    margin: 0.2em 0 0;
}
.study-quote-ref {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
    margin-top: 0.1em;
}
.study-block-remove {
    position: absolute;
    top: 0.25em;
    right: 0.25em;
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary, #999);
    padding: 0 0.25em;
}
.study-block-remove:hover {
    color: var(--danger, #e53e3e);
}
.study-word-study {
    /* inherits from .study-injected-block */
}
.study-block-dragging {
    opacity: 0.4;
}
.study-drop-line {
    height: 3px;
    background: #007aff;
    border-radius: 2px;
    margin: 2px 0;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .lex-study-modal {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }

    .lex-study-body {
        flex-direction: column;
    }

    .lex-study-left {
        width: 100%;
        height: 40%;
        border-right: none;
        border-bottom: 1px solid var(--border, #e2e8f0);
    }

    .lex-study-right {
        height: 60%;
    }
}

@media (max-width: 480px) {
    .lex-study-left {
        height: 35%;
    }

    .lex-study-right {
        height: 65%;
        padding: 0.75rem;
    }

    .lex-study-left-tab {
        font-size: 0.72rem;
        padding: 0.5rem 0.3rem;
    }

    .lex-study-word-card {
        padding: 0.5rem 0.6rem;
        min-height: 44px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .lex-study-header {
        padding: 0.5rem 0.75rem;
    }

    .frosted-close-btn {
        min-width: 36px;
        min-height: 36px;
    }
}

/* ─── Collection Source Badges ─── */

.lex-study-collection-source {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ─── Verse Reference Links (Bible/Study collections) ─── */

.lex-study-verse-ref {
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--primary, #4a6fa5);
    transition: background 0.15s;
}

.lex-study-verse-ref:hover {
    background: var(--hover-bg, rgba(74, 111, 165, 0.08));
}
