/* ---------- Library page ---------- */

/* ---------- Secondary nav (reuse productivity pattern) ---------- */

.sub-nav {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border: 1px solid #d4d0c8;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}

.sub-nav-tab {
    padding: 0.5rem 1.6rem;
    border: none;
    background: #fff;
    color: #666;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border-right: 1px solid #d4d0c8;
}

.sub-nav-tab:last-child { border-right: none; }
.sub-nav-tab:hover { background: #f5f3ee; }
.sub-nav-tab.active { background: #1a1a1a; color: #fff; }
.sub-panel.hidden { display: none; }

/* ---------- Bookmarks header ---------- */

.bk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #db1b1b;
}

.bk-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1a1a;
}

.bk-count {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    color: #999;
}

/* ---------- Add bookmark form ---------- */

.bk-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.bk-search-wrap {
    flex: 1;
    position: relative;
}

.bk-input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid #d4d0c8;
    border-radius: 6px;
    font-family: "Georgia", "Times New Roman", serif;
    font-size: 0.9rem;
    color: #1a1a1a;
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.bk-input:focus { border-color: #db1b1b; }
.bk-input::placeholder { color: #bbb; font-style: italic; }

.bk-submit {
    padding: 0.55rem 1.2rem;
    border: none;
    border-radius: 6px;
    background: #db1b1b;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.bk-submit:hover { background: #a01010; }

/* ---------- Search dropdown ---------- */

.bk-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d4d0c8;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.bk-dropdown.hidden { display: none; }

.bk-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
}

.bk-loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid #d4d0c8;
    border-top-color: #db1b1b;
    border-radius: 50%;
    animation: bk-spin 0.6s linear infinite;
}

@keyframes bk-spin {
    to { transform: rotate(360deg); }
}

.bk-dd-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    transition: background 0.1s;
}

.bk-dd-item:hover { background: #f5f3ee; }

.bk-dd-cover {
    width: 32px;
    height: 44px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

.bk-dd-cover-placeholder {
    width: 32px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0ede6;
    border-radius: 2px;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.bk-dd-info { min-width: 0; }

.bk-dd-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bk-dd-author {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.1rem;
}

.bk-dd-empty {
    padding: 1rem;
    text-align: center;
    color: #bbb;
    font-size: 0.85rem;
    font-style: italic;
}

/* ---------- Genre groups ---------- */

.bk-genre-group {
    margin-bottom: 1.5rem;
}

.bk-genre-heading {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #888;
    margin-bottom: 0.4rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e0ddd5;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.bk-toggle-icon {
    font-size: 0.6rem;
    transition: transform 0.2s;
    display: inline-block;
}

.bk-genre-heading.collapsed .bk-toggle-icon {
    transform: rotate(-90deg);
}

.bk-genre-heading.collapsed + .bk-genre-items {
    display: none;
}

.bk-genre-count {
    font-size: 0.65rem;
    font-weight: 600;
    color: #bbb;
    background: #f0ede6;
    padding: 0.1rem 0.45rem;
    border-radius: 8px;
}

/* ---------- Progress chart ---------- */

.bk-chart-wrap {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: #faf9f6;
    border: 1px solid #e8e5dd;
    border-radius: 6px;
    height: 200px;
}

/* ---------- Bookmark list ---------- */

.bk-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.bk-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e0ddd5;
}

.bk-item:last-child { border-bottom: none; }

.bk-cover-wrap {
    flex-shrink: 0;
}

.bk-cover {
    width: 36px;
    height: 50px;
    object-fit: cover;
    border-radius: 3px;
}

.bk-icon {
    flex-shrink: 0;
    width: 36px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #db1b1b;
    background: #fdf0f0;
    border-radius: 3px;
}

.bk-info {
    flex: 1;
    min-width: 0;
}

.bk-title {
    font-size: 1rem;
    color: #1a1a1a;
    line-height: 1.4;
    word-break: break-word;
}

.bk-author {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.1rem;
}

.bk-meta {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.7rem;
    color: #999;
    margin-top: 0.15rem;
}

/* ---------- Page editor & progress ---------- */

.bk-page-editor {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
    min-width: 80px;
}

.bk-progress {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    user-select: none;
}

.bk-progress-bar {
    width: 100%;
    height: 4px;
    background: #e8e5dd;
    border-radius: 2px;
    overflow: hidden;
}

.bk-progress-fill {
    height: 100%;
    background: #1a8a4a;
    border-radius: 2px;
    transition: width 0.3s;
}

.bk-page-edit {
    width: 60px;
    padding: 0.25rem 0.4rem;
    border: 1px solid #d4d0c8;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.8rem;
    color: #1a1a1a;
    text-align: center;
    outline: none;
    display: none;
}

.bk-page-edit:focus { border-color: #db1b1b; }

/* ---------- Delete ---------- */

.bk-delete {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: #ccc;
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.bk-delete:hover { color: #cc2222; background: #fdf0f0; }

/* ---------- Finish / Unfinish ---------- */

.bk-finish-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: #ccc;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.bk-finish-btn:hover { color: #1a8a4a; background: #edf7f0; }

.bk-unfinish-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: #ccc;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.bk-unfinish-btn:hover { color: #db1b1b; background: #fdf0f0; }

/* ---------- Finished section ---------- */

.bk-finished-section {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 2px solid #e0ddd5;
}

.bk-finished-heading {
    color: #1a8a4a !important;
}

.bk-item-finished {
    opacity: 0.7;
}

.bk-item-finished .bk-cover {
    filter: grayscale(30%);
}

/* ---------- Empty state ---------- */

.empty-state {
    text-align: center;
    color: #777;
    padding: 3rem 0;
    font-size: 1rem;
}

.empty-state a {
    color: #db1b1b;
    text-decoration: none;
    font-weight: 600;
}

.empty-state a:hover {
    text-decoration: underline;
}
