/* ==========================================================================
   KnigaHub — модуль користувача (вхід, реєстрація, кабінет, полка)
   Палітра сайту: фон #191C1F, картки #3D3C3C border, поля #2D2F32,
   акцент #FDD932, приглушений текст #9F9F9F
   ========================================================================== */

/* ---------- Повідомлення ---------- */
.kh-alert {
    border: 1px solid #3D3C3C;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 21px;
    margin-bottom: 20px;
    color: #ddd;
}
.kh-alert--success { border-color: rgba(253,217,50,.45); background: rgba(253,217,50,.07); color: #FDD932 }
.kh-alert--error   { border-color: rgba(229,83,75,.5);  background: rgba(229,83,75,.08);  color: #ff9d97 }

/* ---------- Картка форми ---------- */
.kh-auth { max-width: 460px; margin-bottom: 40px }
.kh-auth .widget_border { padding: 30px 35px }
.kh-auth__title { font-size: 21px; font-weight: 700; line-height: 29px; margin-bottom: 6px }
.kh-auth__lead { color: #9F9F9F; font-size: 14px; line-height: 21px; margin-bottom: 22px }
.kh-auth__links {
    text-align: center;
    margin-top: 18px;
    font-size: 14px;
    line-height: 24px;
    color: #9F9F9F;
}
.kh-auth__links a, .kh-forgot a { color: #9F9F9F; text-decoration: underline !important }
.kh-auth__links a:hover, .kh-forgot a:hover { color: #FDD932 }
.kh-forgot { text-align: right; font-size: 13px; margin: -8px 0 16px }

.kh-benefits { margin: 0 0 22px; padding: 14px 16px; border-radius: 8px; background: #2D2F32; font-size: 13px; color: #ccc }
.kh-benefits li { padding-left: 22px; position: relative; line-height: 20px; margin-bottom: 4px }
.kh-benefits li:last-child { margin-bottom: 0 }
.kh-benefits li:before { content: '✓'; position: absolute; left: 0; color: #FDD932; font-weight: 700 }

/* ---------- Поля (bootstrap5 ActiveForm у темній темі) ---------- */
.kh-form .form-label { font-size: 13px; font-weight: 500; color: #9F9F9F; margin-bottom: 6px }
.kh-form .form-control,
.kh-form input[type='text'],
.kh-form input[type='email'],
.kh-form input[type='password'] {
    display: block;
    width: 100%;
    background: #2D2F32;
    border: 1px solid #383C3D;
    border-radius: 8px;
    height: 42px;
    padding: 0 16px;
    font-size: 14px;
    color: #fff;
    box-shadow: none !important;
    transition: border-color .15s;
}
.kh-form .form-control::placeholder { color: #6F6F6F }
.kh-form .form-control:focus { border-color: #FDD932; background: #2D2F32; color: #fff }
.kh-form .form-control.is-invalid { border-color: #e5534b; background-image: none; padding-right: 16px }
.kh-form .form-control.is-valid { border-color: #383C3D; background-image: none }
.kh-form .invalid-feedback { color: #ff8a82; font-size: 12.5px; margin-top: 5px }
.kh-form .form-text, .kh-form .hint-block { color: #6F6F6F; font-size: 12px; margin-top: 5px }
.kh-form .mb-3 { margin-bottom: 16px !important }

.kh-form .form-check-input {
    background-color: #2D2F32;
    border: 1px solid #6F6F6F;
    width: 17px; height: 17px;
    margin-top: 2px;
    box-shadow: none !important;
    cursor: pointer;
}
.kh-form .form-check-input:checked {
    background-color: #FDD932;
    border-color: #FDD932;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}
.kh-form .form-check-label { font-size: 14px; color: #ccc; cursor: pointer }

.kh-form .button { width: 100%; height: 44px; line-height: 42px; cursor: pointer; font-weight: 500 }

.kh-captcha { display: flex; gap: 10px; align-items: center }
.kh-captcha img { flex: none; height: 42px; border-radius: 8px; border: 1px solid #383C3D; cursor: pointer }
.kh-captcha .form-control { flex: 1 }
.kh-captcha-hint { color: #6F6F6F; font-size: 12px; margin-top: 5px }
.kh-captcha img { transition: opacity .15s }
/* помилка під капчею: інпут усередині .kh-captcha, тому bootstrap сам її не показує */
.kh-captcha ~ .invalid-feedback:not(:empty) { display: block }
.kh-captcha:has(.is-invalid) img { border-color: #e5534b }

/* honeypot — прихований від людей, але не display:none */
.kh-hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden }

/* ---------- Блок користувача в шапці ---------- */
.kh-hdr-wrap { display: flex; align-items: center; gap: 12px }
.kh-hdr { position: relative }
.kh-hdr__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid #3D3C3C;
    border-radius: 8px;
    background: none;
    color: #fff !important;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .15s, color .15s;
}
.kh-hdr__btn:hover, .kh-hdr.is-open .kh-hdr__btn { border-color: #FDD932; color: #FDD932 !important }
.kh-hdr__btn svg { width: 18px; height: 18px; flex: none }
.kh-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 6px;
    background: #FDD932;
    color: #000;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 2px 20px rgba(253,217,50,.25);
    flex: none;
}
.kh-hdr__name { max-width: 120px; overflow: hidden; text-overflow: ellipsis }
.kh-hdr__caret { width: 10px !important; height: 10px !important; opacity: .6 }

.kh-hdr__menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 230px;
    padding: 8px;
    background: #0F1113;
    border: 1px solid #3D3C3C;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.55);
    z-index: 30;
}
.kh-hdr.is-open .kh-hdr__menu { display: block }
.kh-hdr__who { padding: 8px 12px 10px; border-bottom: 1px solid #3D3C3C; margin-bottom: 6px }
.kh-hdr__who b { display: block; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis }
.kh-hdr__who span { display: block; font-size: 12px; color: #6F6F6F; overflow: hidden; text-overflow: ellipsis }
.kh-hdr__menu a,
.kh-hdr__menu button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 9px 12px;
    border-radius: 6px;
    background: none;
    font-size: 14px;
    color: #ddd;
    text-align: left;
    cursor: pointer;
}
.kh-hdr__menu a:hover, .kh-hdr__menu button:hover { background: #2D2F32; color: #FDD932 }
.kh-hdr__menu .bookshelf-count { color: #9F9F9F; font-size: 13px }
.kh-hdr__menu form { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid #3D3C3C }

header.fixed .kh-hdr__btn { background: rgba(25,28,31,.6) }

/* Шапка сайту — position:fixed без z-index, а .owl-carousel має z-index:10,
   тому випадне меню ховалося під каруселлю. Піднімаємо всю шапку
   (!important — щоб перекрити header.fixed { z-index: 5 } із knigastyle.css). */
header { z-index: 100 !important }

@media (max-width: 970px) {
    .kh-hdr__label, .kh-hdr__name, .kh-hdr__caret { display: none }
    .kh-hdr__btn { padding: 0 10px }
}
@media (max-width: 720px) {
    .kh-hdr-wrap { gap: 8px }
    .kh-hdr__btn { height: 34px; padding: 0 8px; border-radius: 6px }
    .kh-avatar { width: 22px; height: 22px; font-size: 12px }
    .kh-auth .widget_border { padding: 22px 18px }
}

/* ---------- Кабінет ---------- */
.kh-cab__head { display: flex; align-items: center; gap: 14px }
.kh-cab__head h1 { margin: 0 }
.kh-cab__avatar {
    display: flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; border-radius: 10px;
    background: #FDD932; color: #000;
    font-size: 24px; font-weight: 700; text-transform: uppercase;
    box-shadow: 0 2px 35px rgba(253,217,50,.2);
    flex: none;
}
.kh-cab__meta { color: #9F9F9F; font-size: 13px; margin-top: 3px }
.kh-cab .tabs_navi a { color: #9F9F9F }
.kh-cab .tabs_navi a:hover { color: #fff }
.kh-cab .tabs_navi a.active { color: #FDD932 }
.kh-cab .tabs_navi a .kh-badge {
    display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 5px;
    border-radius: 10px; background: #2D2F32; color: #ccc;
    font-size: 12px; line-height: 19px; text-align: center;
}
.kh-cab .tabs_navi a.active .kh-badge { background: #FDD932; color: #000 }

.kh-empty { text-align: center; padding: 50px 20px }
.kh-empty__ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 14px; margin-bottom: 18px;
    border: 1px solid #3D3C3C; color: #FDD932;
}
.kh-empty__ico svg { width: 28px; height: 28px }
.kh-empty__title { font-size: 18px; font-weight: 700; margin-bottom: 8px }
.kh-empty__text { color: #9F9F9F; font-size: 14px; line-height: 22px; max-width: 420px; margin: 0 auto 22px }

.kh-shelf .item { position: relative; transition: opacity .25s }
.kh-shelf .item.is-removed { opacity: .4 }
.kh-shelf .item .book_description.kh-full { float: none; width: 100% }
.kh-shelf .item .name_book { padding-right: 44px }
.kh-shelf__remove { position: absolute; top: 15px; right: 15px; margin: 0 !important }
.kh-shelf__added { font-size: 12px; color: #6F6F6F; margin-bottom: 8px }
.kh-shelf .mini_desc { margin-bottom: 0 !important }

.kh-profile dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 14px; margin: 0 }
.kh-profile dt { color: #9F9F9F; font-weight: 400 }
.kh-profile dd { margin: 0; word-break: break-all }
@media (max-width: 720px) {
    .kh-profile dl { grid-template-columns: 1fr; gap: 2px }
    .kh-profile dd { margin-bottom: 10px }
}

/* ---------- Кнопка «В полку» ---------- */
.kh-shelf-btn { cursor: pointer; font-family: inherit }
.kh-shelf-btn svg { width: 16px; height: 16px; flex: none }
.kh-shelf-btn.button {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    width: 100%; margin-top: 12px; padding: 0 10px;
    font-size: 14px; color: #fff; border-color: #6F6F6F;
}
.kh-shelf-btn.button:hover { border-color: #FDD932; color: #FDD932 }
.kh-shelf-btn.button.is-active {
    background: #FDD932; border-color: #FDD932; color: #000;
    box-shadow: 0 2px 35px rgba(253,217,50,.2);
}
.kh-shelf-btn.button.is-active:hover { background: #ffe25c }
.kh-shelf-btn.bookmarks { background: none; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: #B0B0B0 }
.kh-shelf-btn.bookmarks:hover { color: #FDD932 }
.kh-shelf-btn.bookmarks.active { color: #000 }
.kh-shelf-btn[disabled] { opacity: .6; pointer-events: none }

/* Закладка поверх обкладинки в списках книг (BookshelfButton, 'overlay' => true) */
.books .item { position: relative }
.kh-shelf-btn.bookmarks.kh-shelf-btn--overlay {
    position: absolute;
    top: 23px;                 /* padding картки 15px + 8px відступ */
    left: 23px;
    z-index: 3;
    margin: 0;
    width: 30px; height: 30px;
    border-color: rgba(255,255,255,.35);
    background: rgba(15,17,19,.65);
    color: #fff;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 10px rgba(0,0,0,.4);
    opacity: 0;                /* на ПК з'являється при наведенні на картку */
    transition: opacity .15s, background .15s, border-color .15s;
}
.books .item:hover .kh-shelf-btn--overlay,
.kh-shelf-btn--overlay:focus-visible,
.kh-shelf-btn.bookmarks.kh-shelf-btn--overlay.active { opacity: 1 }
.kh-shelf-btn.bookmarks.kh-shelf-btn--overlay:hover { border-color: #FDD932; color: #FDD932 }
.kh-shelf-btn.bookmarks.kh-shelf-btn--overlay.active { background: #FDD932; border-color: #FDD932; color: #000 }
@media (hover: none) {         /* на сенсорних екранах наведення немає — показуємо завжди */
    .kh-shelf-btn.bookmarks.kh-shelf-btn--overlay { opacity: 1 }
}
@media (max-width: 720px) {    /* на мобільних обкладинка в іншому місці — кнопка в правому куті картки */
    .kh-shelf-btn.bookmarks.kh-shelf-btn--overlay { top: 12px; left: auto; right: 12px }
    .books .item .book_description__head { padding-right: 40px }
}

/* ---------- Toast ---------- */
.kh-toast {
    position: fixed; left: 50%; bottom: 24px; z-index: 99999;
    transform: translate(-50%, 20px);
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    background: #0F1113; border: 1px solid #3D3C3C; border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.55);
    color: #fff; font-size: 14px;
    opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.kh-toast.is-show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto }
.kh-toast a { color: #FDD932; text-decoration: underline !important }
