/**
 * Finnish Book Wishlist Light - Frontend Styles
 *
 * Heart uses <div role="button"> not <button> — immune to theme button overrides.
 */

/* ── Heart Wrapper Positioning ── */

.fbw-heart-wrapper {
    position: absolute !important;
    z-index: 100 !important;
}
.fbw-heart-wrapper.fbw-loop {
    top: 10px !important;
    left: 10px !important;
}
.fbw-heart-wrapper.fbw-single {
    top: 20px !important;
    left: 20px !important;
}

/* Ensure parent allows absolute positioning */
.woocommerce ul.products li.product,
ul.products li.product,
li.product,
.product-small,
.box-image,
.woocommerce div.product div.images {
    position: relative !important;
}

/* ── Heart Button (div, not button — theme-proof) ── */

.fbw-heart-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    background: rgba(255,255,255,.95) !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 50px !important;
    cursor: pointer !important;
    transition: all .2s ease !important;
    font-size: 14px !important;
    line-height: 1 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.1) !important;
    color: #333 !important;
    text-decoration: none !important;
    position: relative !important;
    z-index: 10 !important;
    pointer-events: auto !important;
    -webkit-user-select: none;
    user-select: none;
    box-sizing: border-box;
}
.fbw-heart-btn:hover {
    background: #fff !important;
    border-color: #ff4757 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.15) !important;
    transform: translateY(-1px) !important;
}
.fbw-heart-btn:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(255,71,87,.2) !important;
}

.fbw-heart-btn.fbw-loading {
    pointer-events: none;
    opacity: .6;
}
.fbw-heart-btn.fbw-loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 16px; height: 16px;
    border: 2px solid #ff4757;
    border-top-color: transparent;
    border-radius: 50%;
    animation: fbw-spin .6s linear infinite;
}
@keyframes fbw-spin { to { transform: translate(-50%,-50%) rotate(360deg); } }

/* ── Heart Icon ── */

.fbw-heart-icon {
    position: relative;
    width: 20px; height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.fbw-heart-icon svg {
    width: 20px !important; height: 20px !important;
    transition: all .2s ease;
    display: block !important;
}
.fbw-ho {
    color: #333 !important;
    stroke: #333 !important;
    fill: none !important;
}
.fbw-hf {
    position: absolute; top: 0; left: 0;
    color: #ff4757 !important;
    fill: #ff4757 !important;
    stroke: none !important;
    opacity: 0;
    transform: scale(.8);
}

/* Active state */
.fbw-heart-btn.fbw-active {
    border-color: #ff4757 !important;
}
.fbw-heart-btn.fbw-active .fbw-ho { opacity: 0 !important; }
.fbw-heart-btn.fbw-active .fbw-hf {
    opacity: 1 !important;
    transform: scale(1) !important;
    animation: fbw-pop .3s ease;
}
@keyframes fbw-pop {
    0% { transform: scale(.8); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ── Count Badge ── */

.fbw-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 2px 6px;
    background: #ff4757;
    color: #fff !important;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}
.fbw-heart-btn:hover .fbw-count { background: #ff3142; }

/* Text label (single product) */
.fbw-text { font-weight: 500; color: #333 !important; white-space: nowrap; }
.fbw-heart-btn.fbw-active .fbw-text { color: #ff4757 !important; }

/* Compact loop style */
.fbw-loop .fbw-heart-btn { padding: 6px 8px !important; }
.fbw-loop .fbw-text { display: none; }
.fbw-loop .fbw-heart-icon svg { width: 18px; height: 18px; }

/* ── Wishlist Page ── */

.fbw-wishlist-page { max-width: 1200px; margin: 0 auto; }
.fbw-wishlist-page h2 { margin-bottom: 20px; }

.fbw-wl-meta { position: relative; margin-top: 8px; }

.fbw-remove {
    position: absolute;
    top: 10px; right: 10px;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.95);
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px; line-height: 1;
    color: #999;
    opacity: 0; transform: scale(.8);
    transition: all .2s ease;
    padding: 0; z-index: 10;
}
li.product:hover .fbw-remove { opacity: 1; transform: scale(1); }
.fbw-remove:hover { background: #ff4757; border-color: #ff4757; color: #fff; }

/* Wishlist Pagination */
.fbw-pagination { margin: 30px 0 10px; text-align: center; }
.fbw-pagination ul { list-style: none; padding: 0; margin: 0; display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.fbw-pagination li { display: inline-block; }
.fbw-pagination a,
.fbw-pagination span {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: all .2s ease;
}
.fbw-pagination a:hover { border-color: #ff4757; color: #ff4757; }
.fbw-pagination .current { background: #ff4757; border-color: #ff4757; color: #fff; font-weight: 600; }

/* ── Toast Notifications ── */

.fbw-toast {
    position: fixed;
    bottom: -100px; left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    background: #333; color: #fff;
    border-radius: 50px;
    font-size: 14px; font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
    z-index: 10000;
    transition: bottom .3s ease;
    white-space: nowrap;
}
.fbw-toast.fbw-show { bottom: 30px; }
.fbw-toast-success { background: #2ecc71; }
.fbw-toast-error { background: #e74c3c; }

/* ── Login Modal ── */

.fbw-login-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .3s ease;
}
.fbw-login-overlay.fbw-show { opacity: 1; }

.fbw-login-modal {
    background: #fff;
    border-radius: 8px;
    max-width: 500px; width: 90%;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
    transform: translateY(-20px);
    transition: transform .3s ease;
}
.fbw-login-overlay.fbw-show .fbw-login-modal { transform: translateY(0); }

.fbw-login-close {
    position: absolute; top: 15px; right: 15px;
    background: transparent; border: none;
    font-size: 28px; cursor: pointer; color: #999;
    padding: 0; width: 30px; height: 30px;
}
.fbw-login-close:hover { color: #333; }

.fbw-login-modal h3 { margin: 0 0 15px; font-size: 24px; color: #333; }
.fbw-login-modal p { margin: 0 0 25px; color: #666; font-size: 16px; }
.fbw-login-modal .button-primary {
    display: inline-block;
    padding: 12px 30px;
    background: #3F4044; color: #fff;
    border: none; border-radius: 4px;
    font-size: 16px; text-decoration: none;
    cursor: pointer; transition: all .2s ease;
}
.fbw-login-modal .button-primary:hover {
    background: #2d2e31;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(63,64,68,.3);
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .fbw-heart-wrapper.fbw-single { top: 10px !important; left: 10px !important; }
    .fbw-heart-btn { padding: 6px 10px !important; font-size: 13px !important; }
    .fbw-text { display: none; }
}
