/* Bookly — main stylesheet */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue",
                 Helvetica, Arial, sans-serif;
    background: #f8f9fa;
}

/* Book cards on the library page */
.book-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid #e6e6e6;
}
.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.book-cover-wrap {
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 130px;
    border-right: 1px solid #e6e6e6;
}
.book-cover {
    width: 100%;
    height: 100%;
    max-height: 180px;
    object-fit: cover;
}
.book-cover-placeholder {
    width: 100%;
    font-size: 2.5rem;
}

/* Tag management page cards */
.tag-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid #e6e6e6;
}
.tag-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Drag & drop upload zone */
#filesList {
    min-height: 60px;
    transition: background 0.15s, border 0.15s;
}
#filesList.bookly-dragging {
    background: #e8f0fe;
    outline: 2px dashed #0d6efd;
    outline-offset: -2px;
}
.bookly-drop-hint {
    color: #6c757d;
    font-size: 0.85em;
    text-align: center;
    padding: 1.25rem 0;
    border: 1px dashed #ccc;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
}
.bookly-drop-hint:hover {
    background: #f8f9fa;
}

/* Photographed quotes */
.quote-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.6rem;
}
.quote-photo-item {
    position: relative;
    min-width: 0;
}
.quote-photo-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border: 1px solid #dee2e6;
    border-radius: 0.4rem;
    background: #eee;
    cursor: zoom-in;
}
.quote-photo-remove {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border-radius: 50%;
    line-height: 1;
    box-shadow: 0 1px 5px rgba(0,0,0,0.35);
}
.quote-photo-pending::after {
    content: "待上传";
    position: absolute;
    left: 0.3rem;
    bottom: 0.3rem;
    padding: 0.1rem 0.35rem;
    color: #fff;
    background: rgba(0,0,0,0.65);
    border-radius: 0.25rem;
    font-size: 0.7rem;
}
.quote-photo-modal-body {
    min-height: 70vh;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
}
.quote-photo-modal-body img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 8rem);
    margin: auto;
    object-fit: contain;
}
.quote-photo-nav {
    width: 2.75rem;
    height: 3.5rem;
    padding: 0;
    font-size: 2rem;
    line-height: 1;
}
@media (max-width: 575.98px) {
    .quote-photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }
    .quote-photo-modal-body {
        min-height: calc(100vh - 4rem);
        gap: 0.25rem;
        padding: 0.25rem;
    }
    .quote-photo-nav {
        width: 2.25rem;
        background: rgba(0,0,0,0.45);
    }
}

.pdf-page-wrap {
    position: relative;
    margin: 0 auto;
    display: inline-block;
}
.pdf-page-wrap canvas {
    display: block;
}
.textLayer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    line-height: 1.0;
    text-align: initial;
    transform-origin: 0 0;
    z-index: 2;
}
.textLayer span,
.textLayer br {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}
.textLayer ::selection {
    background: rgba(0, 100, 255, 0.25);
}
.textLayer span {
    left: 0;
    top: 0;
}
.textLayer .endOfContent {
    display: block;
    position: absolute;
    inset: 100% 0 0 0;
    z-index: -1;
    cursor: default;
    user-select: none;
}

/* Reader fullscreen: hide nav + header, keep only toolbar + book. */
.reader-fullscreen .navbar {
    display: none !important;
}
.reader-fullscreen #readerHeader {
    display: none !important;
}
.reader-fullscreen .reader-hint {
    display: none !important;
}
.reader-fullscreen #readerToolbar {
    border-radius: 0;
    margin-bottom: 0 !important;
}
.reader-fullscreen #readerContainer {
    max-height: calc(100vh - 70px) !important;
    height: calc(100vh - 70px) !important;
    background: #333 !important;
    border: none;
    border-radius: 0;
}
.reader-fullscreen #readerContent {
    max-width: 100% !important;
}

/* GitHub-style heatmap */
.bookly-heatmap-wrap {
    overflow-x: auto;
    padding: 0.25rem 0 0.6rem 0;
    scrollbar-width: thin;
}
.bookly-heatmap {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
}
.bookly-heatmap-side {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 0 0 auto;
}
.bookly-heatmap-side .heatmap-year-label {
    height: 1.3rem;
    line-height: 1.3rem;
    font-size: 11px;
    color: #666;
    font-weight: 500;
    text-align: right;
    padding-right: 0.3rem;
}
.bookly-heatmap-side .heatmap-weekday-spacer {
    height: 1.3rem;
}
.heatmap-weekdays {
    display: grid;
    font-size: 10px;
    color: #999;
    margin-right: 0;
    flex: 0 0 auto;
}
.weekday-label {
    display: block;
}
.heatmap-months {
    display: flex;
    flex: 0 0 auto;
    font-size: 11px;
    color: #666;
    height: 1.3rem;
}
.heatmap-months span {
    flex: 0 0 auto;
    text-align: left;
    white-space: nowrap;
    line-height: 1.2;
}
.heatmap-grid {
    display: grid;
    grid-auto-flow: column;
    flex: 0 0 auto;
}
.hm-cell {
    border-radius: 2px;
    background: #ebedf0;
    cursor: default;
}
.hm-cell.l1 { background: #9be9a8; }
.hm-cell.l2 { background: #40c463; }
.hm-cell.l3 { background: #30a14e; }
.hm-cell.l4 { background: #216e39; }
.hm-cell.outside { background: transparent; }
.hm-cell:hover { outline: 1px solid rgba(0,0,0,0.45); }
.hm-cell[data-count="0"] { background: #ebedf0; }
.hm-cell.is-today {
    outline: 1.5px solid #0d6efd;
    outline-offset: 0;
}
.bookly-heatmap-legend {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 11px;
    color: #666;
}
.bookly-heatmap-legend .hm-cell {
    display: inline-block;
    width: 12px;
    height: 12px;
}
.bookly-heatmap-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 12px;
    color: #555;
}
.bookly-heatmap-summary strong {
    color: #212529;
    font-weight: 600;
}
@media (max-width: 575.98px) {
    .bookly-heatmap-wrap {
        margin: 0 -0.5rem;
        padding: 0 0.5rem 0.6rem;
    }
}

/* Book form sections */
.book-form-section {
    border: 0;
    padding: 0.25rem 0 1rem 0;
    margin: 0 0 1rem 0;
    border-bottom: 1px solid #e6e9ee;
}
.book-form-section:first-of-type {
    padding-top: 0.5rem;
}
.book-form-section:last-of-type {
    border-bottom: 0;
    margin-bottom: 0.5rem;
}
.book-form-legend {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    font-weight: 700;
    color: #0d6efd;
    letter-spacing: 0.02em;
    margin: 0 0 0.85rem 0;
    padding: 0.25rem 0 0.3rem 0;
    border-bottom: 2px solid #0d6efd;
    text-transform: none;
}
.book-form-legend::before {
    content: "";
    width: 4px;
    height: 1rem;
    background: #0d6efd;
    border-radius: 2px;
    flex: 0 0 auto;
}

/* Tag combobox (book form) */
.tag-combo {
    position: relative;
    display: block;
    min-height: 2.5rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background: #fff;
    cursor: text;
}
.tag-combo:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,0.15);
}
.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.25rem;
}
.tag-empty {
    padding: 0.15rem 0.25rem;
}
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.4rem 0.15rem 0.55rem;
    background: #e7f1ff;
    color: #084298;
    border: 1px solid #b6d4fe;
    border-radius: 999px;
    font-size: 0.85rem;
    line-height: 1.4;
}
.tag-chip-remove {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0 0.1rem;
    line-height: 1;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.6;
}
.tag-chip-remove:hover {
    opacity: 1;
    color: #b02a37;
}
.tag-input {
    border: 0;
    outline: 0;
    width: 100%;
    min-width: 14rem;
    padding: 0.15rem 0;
    font-size: 0.95rem;
    background: transparent;
}
.tag-input:focus { box-shadow: none; }
.tag-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin: 0.15rem 0 0 0;
    padding: 0.25rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    max-height: 16rem;
    overflow-y: auto;
    z-index: 20;
}
.tag-suggestion {
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
}
.tag-suggestion.is-active,
.tag-suggestion:hover {
    background: #e7f1ff;
    color: #084298;
}

/* Generic helpers */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Book-detail status switcher: keep all four buttons the same width so the
 * long English labels ("Want to Read", "Reading", "Finished", "Shelved")
 * don't bloat the row. Width is ~ two CJK characters, which exactly fits
 * the Chinese labels (想读/在读/已读/搁置) and clips the English ones with
 * an ellipsis. The full label is shown in the native `title` tooltip. */
#statusSwitcher .bookly-status-btn {
    /* Make flex children share width evenly inside the btn-group */
    flex: 1 1 0;
    min-width: 0;
}
#statusSwitcher .bookly-status-btn-label {
    display: inline-block;
    /* ~ two CJK glyphs at the default font size; English gets ellipsised */
    max-width: 3.4em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}
