/* ================================
   Публичен списък (prefix: .pl-)
   ================================ */

/* Обвивка */
.pl-wrap {
    padding-top: 12px;
    padding-bottom: 24px;
}

/* ---------- ХЕДЪР ---------- */

/* Хедър като 3-колонен grid:
   [owner/meta] | [title center] | [actions-right] */
.pl-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    width: 100%;

    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 16px;
}

/* Ляв блок: собственик/мета */
.pl-owner {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Авaтар */
.pl-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: #f7f7f7;
    display: block;
}

.pl-avatar.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--txt);
}

/* Метаданни ляво */
.pl-meta {
    display: grid;
    gap: 4px;
}

.pl-owner-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pl-owner-name {
    font-weight: 600;
    color: var(--txt-dim);
    font-size: 0.95rem;
}

.pl-sub {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--txt-dim);
    font-size: 0.95rem;
}

.pl-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 0.85rem;
}

.pl-badge.public {
    border-color: hsl(var(--p-h) 50% 60%);
    background: var(--primary-soft);
}

.pl-badge.private {
    background: #f3f3f3;
}

.pl-count {
    font-size: 0.95rem;
}

/* Център: заглавие на списъка */
.pl-center {
    text-align: center;
}

.pl-list-title {
    margin: 0;
    font-size: clamp(1.2rem, 2.4vw, 2rem);
    line-height: 1.2;
    font-weight: 800;
    color: black;
}

/* Дясно: действия */
.pl-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-self: end;
}

.pl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 12px;
    margin: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--txt);
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}

.pl-btn:hover {
    background: var(--primary-soft);
    border-color: hsl(var(--p-h) 50% 60%);
    box-shadow: 0 4px 12px hsl(var(--p-h) var(--p-s) 25% / .15);
}

.pl-btn:active {
    transform: translateY(1px);
}

.pl-btn.outline {
    background: #fff;
}

/* Мобилен хедър */
@media (max-width: 640px) {
    .pl-header {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .pl-actions {
        justify-self: center;
    }

    .pl-owner {
        justify-content: center;
    }
}

/* ---------- ГРИД С КНИГИ ---------- */

.pl-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

@media (max-width: 1280px) {
    .pl-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1024px) {
    .pl-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 820px) {
    .pl-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 560px) {
    .pl-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Карта на книга */
.pl-card {
    display: grid;
    grid-template-rows: auto auto;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
    text-decoration: none;
    color: var(--txt);
    transition: transform .1s ease, box-shadow .15s ease, border-color .15s ease;
}

.pl-card:hover {
    transform: translateY(-2px);
    border-color: hsl(var(--p-h) 50% 60%);
    box-shadow: 0 10px 22px rgba(0, 0, 0, .07);
}

/* Корицa */
.pl-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fafafa;
    overflow: hidden;
}

.pl-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pl-cover .ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--txt-dim);
    font-size: .9rem;
}

/* Инфо под корицaта */
.pl-info {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.pl-book-title {
    font-weight: 700;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* до 2 реда */
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pl-authors {
    color: var(--txt-dim);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- ПРАЗНО СЪСТОЯНИЕ ---------- */

.pl-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40vh;
}

.pl-empty-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 18px;
    text-align: center;
}

.pl-empty-emoji {
    font-size: 2rem;
}

.pl-empty-text {
    color: var(--txt-dim);
    margin-top: 6px;
}

/* ---------- ФИЛТРИ (ако има) ---------- */

.pli-filters .pli-row {
    display: grid;
    grid-template-columns: 1fr 220px auto;
    gap: 10px;
    align-items: end;
}

@media (max-width: 720px) {
    .pli-filters .pli-row {
        grid-template-columns: 1fr;
    }
}

.pli-field {
    display: grid;
    gap: 6px;
}

.pli-label {
    font-size: 0.9rem;
    color: var(--txt);
    font-weight: 600;
}

.pli-input,
.pli-select {
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 10px;
    background: #fff;
    color: var(--txt) !important; /* по-тъмен текст за четимост */
}

.pli-input::placeholder {
    color: var(--txt-dim); /* по-четим placeholder */
    opacity: 1;
}

.pli-select {
    appearance: auto;
    background-image: none;
}

.pli-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pli-input:focus,
.pli-select:focus {
    outline: none;
    border-color: hsl(var(--p-h) 50% 60%);
    box-shadow: 0 0 0 3px hsl(var(--p-h) 90% 85% / .7);
}

/* ---------- ПАГИНАЦИЯ (по желание) ---------- */

.pl-pager {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 18px 0 6px;
}

.pl-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--txt);
    font-size: .95rem;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    text-decoration: none;
}

.pl-page-link:hover {
    background: var(--primary-soft);
    border-color: hsl(var(--p-h) 50% 60%);
}

.pl-page-link.is-current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    pointer-events: none;
}

.pl-page-link.is-disabled {
    color: var(--txt-dim);
    background: #f4f4f4;
    pointer-events: none;
}

/* ---------- Аксесибилити дреболии ---------- */

.pl-btn:focus-visible,
.pl-page-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--p-h) 90% 85% / .85);
}

.card-end-text {
    text-align: right; /* <-- подравнява съдържанието вдясно */
    margin-top: 8px;
    font-size: 0.6em /* малко отстояние от горния елемент */
}

/* Обвивка на карта + чекбокс */
.pl-card-wrap {
    position: relative;
}

/* чекбокс контейнер */
.pl-select {
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 5;
    display: none; /* по подразбиране скрито */
    align-items: center;
    justify-content: center;
}

/* чекбоксите да са по-големи */
.pl-select input[type="checkbox"],
.pl-select-all input[type="checkbox"] {
    width: 18px;
    height: 18px;
    transform: translateY(1px); /* леко изравняване по вертикала */
    accent-color: hsl(var(--p-h) var(--p-s) 45%); /* по желание – в тон с темата */
}

/* оформление на контейнера "Маркирай всички" */
.pl-select-all {
    display: none; /* по дефолт скрито – показва се само в режим Редакция */
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--txt-dim);
}

.pl-select-all label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* чекбоксите до всяка книга – по дефолт скрити */
.pl-edit-form .pl-select {
    display: none;
    margin-bottom: 4px;
}

/* бутоните за изтриване – по дефолт скрити */
.pl-edit-actions {
    display: none;
}

/* когато формата е в режим .pl-editing – показваме всичко */
.pl-edit-form.pl-editing .pl-select {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pl-edit-form.pl-editing .pl-select-all {
    display: inline-flex;
}

.pl-edit-form.pl-editing .pl-edit-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}


/* форма за редакция */
.pl-edit-form {
    width: 100%;
}

/* бутон за изтриване по подразбиране скрит */
.pl-delete-btn {
    display: none;
    margin-top: 10px;
}

/* Когато сме в режим редакция */
.pl-edit-form.pl-editing .pl-select {
    display: flex;
}

/* да не се отварят линковете към книгата при режим редакция */
.pl-edit-form.pl-editing .pl-card {
    pointer-events: none;
    opacity: 0.95;
}

/* показваме бутона за изтриване */
.pl-edit-form.pl-editing .pl-delete-btn {
    display: inline-flex;
}

/* стил за danger бутон (ако нямаш такъв) */
.pl-btn.danger {
    background: #c0392b;
    color: #fff;
}

.pl-btn.danger:hover {
    background: #e74c3c;
}

/* всяка клетка в грид-а да е равна */
.pl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

/* контейнерът около всяка карта + чекбокса */
.pl-card-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* самата карта да запълва */
.pl-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* корица стабилна */
.pl-cover img,
.pl-cover .ph {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
}

/* инфо зоната – расте, но не чупи височината */
.pl-info {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* заглавие — максимум 2 реда */
.pl-book-title {
    font-weight: 600;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* автори — максимум 1 ред */
.pl-authors {
    font-size: .85em;
    color: var(--txt-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* позициониране горе вляво */
.pl-card-wrap {
    position: relative;
}

/* form контейнер */
.pl-fav-form {
    position: absolute;
    left: 6px;
    top: 6px;
    z-index: 5;
}

/* бутон ♥ */
.pl-fav-btn {
    border: none;
    background: rgba(255, 255, 255, .9);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    color: #888;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    transition: background .2s, color .2s, transform .15s;
}

.pl-fav-btn:hover {
    background: white;
    color: crimson;
    transform: scale(1.05);
}

/* активна любима */
.pl-fav-btn.is-active {
    color: crimson;
}


/* контейнер около карта + иконки */
.pl-card-wrap {
    /* може да остане flex, ако искаш, но не е задължително */
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* вътрешен контейнер – тук закачаме absolute елементите */
.pl-card-inner {
    position: relative;
    height: 100%;
}

/* самата карта да запълва контейнера */
.pl-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* чекбокс и сърце вече са позиционирани спрямо .pl-card-inner */
.pl-select {
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 5;
    /* ... останалото както си го имаш ... */
}

/* вътрешен контейнер – reference за absolute */
.pl-card-inner {
    position: relative;
    height: 100%;
}

/* бутон ♥ – горе вляво върху картата */
.pl-fav-btn {
    position: absolute;
    left: 6px;
    top: 6px;
    z-index: 5;

    border: none;
    background: rgba(255, 255, 255, .9);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    color: #888;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    transition: background .2s, color .2s, transform .15s;
}

.pl-fav-btn:hover {
    background: #fff;
    color: crimson;
    transform: scale(1.05);
}

.pl-fav-btn.is-active {
    color: crimson;
}

.pl-year-groups {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.pl-year-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pl-year-divider {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px 0 6px;
}

.pl-year-divider::before {
    content: "";
    position: absolute;
    inset: 50% 0 auto 0;
    height: 1px;
    transform: translateY(-50%);
    background: linear-gradient(
            90deg,
            transparent 0%,
            rgba(180, 150, 90, 0.35) 10%,
            rgba(180, 150, 90, 0.8) 50%,
            rgba(180, 150, 90, 0.35) 90%,
            transparent 100%
    );
}

.pl-year-label {
    position: relative;
    z-index: 1;
    padding: 6px 18px;
    border-radius: 999px;
    background: linear-gradient(180deg, #fffaf0 0%, #f3e7c8 100%);
    border: 1px solid rgba(170, 135, 70, 0.35);
    color: #7a5a1e;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    text-transform: uppercase;
}