/* ============================================================
 *  MedScholar Books - Frontend Styles v2.2
 *  Modern, RTL, Mobile-Friendly, Continuous Scroll
 * ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --msbooks-primary: #1a1a2e;
    --msbooks-secondary: #16213e;
    --msbooks-accent: #0f3460;
    --msbooks-highlight: #e94560;
    --msbooks-bg: #f8f9fc;
    --msbooks-card-bg: #ffffff;
    --msbooks-text: #2d3748;
    --msbooks-text-light: #718096;
    --msbooks-border: #e2e8f0;
    --msbooks-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --msbooks-shadow-hover: 0 12px 30px rgba(0, 0, 0, 0.15);
    --msbooks-radius: 12px;
    --msbooks-radius-sm: 8px;
    --msbooks-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --msbooks-toolbar-height: 52px;
}

/* ---- Main Container ---- */
.msbooks-container {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px;
    color: var(--msbooks-text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.8;
}

/* ---- Header ---- */
.msbooks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, var(--msbooks-primary) 0%, var(--msbooks-accent) 100%);
    padding: 20px 24px;
    border-radius: var(--msbooks-radius);
    box-shadow: var(--msbooks-shadow);
}

.msbooks-header-right { flex-shrink: 0; }

.msbooks-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}
.msbooks-logo svg { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
.msbooks-logo-text { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; }

.msbooks-header-center { flex: 1; min-width: 200px; max-width: 500px; }

.msbooks-search-box { position: relative; width: 100%; }
.msbooks-search-box input {
    width: 100%; padding: 12px 42px 12px 36px;
    border: 2px solid rgba(255,255,255,0.2); border-radius: 25px;
    font-size: 14px; font-family: inherit;
    background: rgba(255,255,255,0.12); color: #fff;
    transition: var(--msbooks-transition);
    backdrop-filter: blur(10px);
}
.msbooks-search-box input::placeholder { color: rgba(255,255,255,0.6); }
.msbooks-search-box input:focus {
    outline: none; border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.18);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.1);
}
.msbooks-search-icon {
    position: absolute; right: 14px; top: 50%;
    transform: translateY(-50%); color: rgba(255,255,255,0.6);
    pointer-events: none;
}
.msbooks-search-clear {
    position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%); background: none;
    border: none; color: rgba(255,255,255,0.6);
    cursor: pointer; padding: 4px; display: none;
    transition: var(--msbooks-transition);
}
.msbooks-search-clear:hover { color: #fff; }

.msbooks-header-left { flex-shrink: 0; }
.msbooks-request-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--msbooks-highlight); color: #fff !important;
    padding: 10px 20px; border-radius: 25px; text-decoration: none;
    font-weight: 600; font-size: 14px; transition: var(--msbooks-transition);
    white-space: nowrap; box-shadow: 0 4px 12px rgba(233,69,96,0.3);
}
.msbooks-request-btn:hover {
    background: #d63851; transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233,69,96,0.4); color: #fff !important;
}

/* ---- Stats ---- */
.msbooks-stats { margin-bottom: 20px; padding: 0 4px; color: var(--msbooks-text-light); font-size: 14px; }

/* ---- Loading ---- */
.msbooks-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--msbooks-text-light); }
.msbooks-spinner {
    width: 40px; height: 40px; border: 3px solid var(--msbooks-border);
    border-top-color: var(--msbooks-accent); border-radius: 50%;
    animation: msbooks-spin 0.8s linear infinite; margin-bottom: 12px;
}
@keyframes msbooks-spin { to { transform: rotate(360deg); } }

/* ---- Books Grid ---- */
.msbooks-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
@media (max-width: 1100px) { .msbooks-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .msbooks-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; } }
@media (max-width: 480px) { .msbooks-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

/* ---- Book Card ---- */
.msbooks-book-card {
    background: var(--msbooks-card-bg); border-radius: var(--msbooks-radius);
    overflow: hidden; box-shadow: var(--msbooks-shadow);
    transition: var(--msbooks-transition); cursor: pointer; position: relative;
}
.msbooks-book-card:hover { transform: translateY(-6px); box-shadow: var(--msbooks-shadow-hover); }
.msbooks-book-card:active { transform: translateY(-2px); }

/* ---- Book Cover ---- */
.msbooks-book-cover-wrapper {
    position: relative; overflow: hidden; aspect-ratio: 3/4;
    background: linear-gradient(135deg, #f0f4f8, #d9e2ec);
}
.msbooks-book-cover {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.5s ease;
}
.msbooks-book-card:hover .msbooks-book-cover { transform: scale(1.05); }
.msbooks-book-cover-placeholder {
    width: 100%; height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: rgba(255,255,255,0.7); position: relative;
}
.msbooks-cover-loading { position: relative; }
.msbooks-cover-spinner {
    width: 24px; height: 24px; border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%;
    animation: msbooks-spin 0.8s linear infinite;
    position: absolute; top: 8px; left: 8px;
}

/* ---- Book Overlay ---- */
.msbooks-book-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: var(--msbooks-transition); color: #fff;
}
.msbooks-book-card:hover .msbooks-book-overlay { opacity: 1; }
.msbooks-book-overlay svg { filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3)); }

/* ---- Book Info ---- */
.msbooks-book-info { padding: 14px 16px; }
.msbooks-book-title {
    font-size: 14px; font-weight: 700; color: var(--msbooks-text);
    margin: 0; line-height: 1.8; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-align: center;
    direction: rtl; unicode-bidi: plaintext;
}

/* ---- No Results ---- */
.msbooks-no-results { text-align: center; padding: 60px 20px; color: var(--msbooks-text-light); }
.msbooks-no-results svg { color: #cbd5e0; margin-bottom: 16px; }
.msbooks-no-results h3 { font-size: 20px; margin: 0 0 8px; color: var(--msbooks-text); }
.msbooks-no-results p { font-size: 14px; margin: 0; }

/* ---- Pagination ---- */
.msbooks-pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 32px; flex-wrap: wrap; }
.msbooks-pagination button {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 14px; border: 1px solid var(--msbooks-border);
    background: var(--msbooks-card-bg); border-radius: var(--msbooks-radius-sm);
    cursor: pointer; transition: var(--msbooks-transition); font-size: 14px;
    font-family: inherit; color: var(--msbooks-text); min-width: 40px; justify-content: center;
}
.msbooks-pagination button:hover:not(:disabled) { background: var(--msbooks-primary); color: #fff; border-color: var(--msbooks-primary); }
.msbooks-pagination button.active { background: var(--msbooks-accent); color: #fff; border-color: var(--msbooks-accent); font-weight: 700; }
.msbooks-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.msbooks-pagination button.msbooks-page-dots { border: none; background: none; cursor: default; color: var(--msbooks-text-light); }

/* ============================================================
 *  PDF VIEWER OVERLAY
 * ============================================================ */
.msbooks-viewer-overlay {
    display: none; position: fixed; inset: 0; z-index: 99999;
    background: #2c2c2c; flex-direction: column;
}
.msbooks-viewer-overlay.active { display: flex; }

/* ---- Toolbar ---- */
.msbooks-viewer-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; height: var(--msbooks-toolbar-height);
    background: var(--msbooks-secondary); color: #fff;
    flex-shrink: 0; gap: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3); z-index: 10;
}
.msbooks-toolbar-right, .msbooks-toolbar-center, .msbooks-toolbar-left {
    display: flex; align-items: center; gap: 8px;
}
.msbooks-toolbar-right { flex: 0 0 auto; min-width: 0; }
.msbooks-toolbar-center { flex: 0 0 auto; }
.msbooks-toolbar-left { flex: 1; justify-content: flex-end; min-width: 0; flex-wrap: wrap; }

.msbooks-toolbar-btn {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
    color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer;
    transition: var(--msbooks-transition); display: flex; align-items: center;
    justify-content: center; min-width: 36px; height: 36px;
}
.msbooks-toolbar-btn:hover { background: rgba(255,255,255,0.2); }
.msbooks-toolbar-btn:active { background: rgba(255,255,255,0.25); transform: scale(0.95); }
.msbooks-toolbar-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.msbooks-viewer-title {
    font-size: 14px; font-weight: 600; max-width: 200px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: rgba(255,255,255,0.9);
}

/* ---- Page Navigation ---- */
.msbooks-page-nav { display: flex; align-items: center; gap: 6px; font-size: 14px; color: rgba(255,255,255,0.8); }
.msbooks-page-nav input {
    width: 50px; text-align: center; background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
    color: #fff; font-size: 14px; font-family: inherit; padding: 4px 6px;
}
.msbooks-page-nav input:focus { outline: none; border-color: rgba(255,255,255,0.5); }

.msbooks-zoom-level { font-size: 13px; color: rgba(255,255,255,0.7); min-width: 45px; text-align: center; }

/* ---- Search in PDF ---- */
.msbooks-search-in-pdf { position: relative; display: flex; align-items: center; }
.msbooks-pdf-search-bar {
    position: absolute; top: 46px; left: 0;
    background: var(--msbooks-secondary); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px; padding: 8px; display: flex; align-items: center;
    gap: 6px; box-shadow: 0 8px 25px rgba(0,0,0,0.4); z-index: 20; min-width: 280px;
}
.msbooks-pdf-search-bar input {
    flex: 1; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px; color: #fff; font-size: 14px; font-family: inherit;
    padding: 6px 10px; min-width: 0;
}
.msbooks-pdf-search-bar input::placeholder { color: rgba(255,255,255,0.5); }
.msbooks-pdf-search-bar input:focus { outline: none; border-color: rgba(255,255,255,0.5); }
.msbooks-pdf-search-bar button {
    background: rgba(255,255,255,0.1); border: none; color: #fff;
    border-radius: 6px; padding: 4px 8px; cursor: pointer;
    display: flex; align-items: center; transition: var(--msbooks-transition);
}
.msbooks-pdf-search-bar button:hover { background: rgba(255,255,255,0.2); }
.msbooks-search-count { font-size: 12px; color: rgba(255,255,255,0.6); min-width: 40px; text-align: center; white-space: nowrap; }

/* ============================================================
 *  VIEWER BODY - Continuous Scroll
 *  KEY FIXES: touch-action, min-height, proper scroll container
 * ============================================================ */
.msbooks-viewer-body {
    flex: 1;
    min-height: 0;  /* Critical for flexbox scroll to work */
    overflow-y: auto;
    overflow-x: hidden;  /* Prevent horizontal scroll on mobile */
    background: #2c2c2c;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;  /* Allow vertical touch scrolling */
    padding: 20px;
    /* Prevent browser auto-zoom on mobile */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.msbooks-pages-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-bottom: 40px;
    min-height: min-content;  /* Ensure wrapper takes height of children */
}

/* ---- Individual Page Item ---- */
.msbooks-page-item {
    position: relative;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    border-radius: 4px;
    overflow: hidden;
    line-height: 0;
    flex-shrink: 0;  /* Don't shrink pages in flex layout */
}

.msbooks-page-canvas {
    display: block;
    /* Sharp text rendering on all devices */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* GPU acceleration for smooth scrolling */
    will-change: transform;
}

/* ---- Canvas Overlay (prevent right-click save) ---- */
.msbooks-canvas-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
    cursor: default;
    pointer-events: none;  /* KEY FIX: Allow touch scroll to pass through */
}

/* ---- Page Number Badge ---- */
.msbooks-page-number {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    font-family: Tahoma, sans-serif;
    direction: ltr;
    z-index: 3;
    pointer-events: none;
    line-height: 1.6;
}

/* ---- PDF Loading Overlay ---- */
.msbooks-pdf-loading {
    position: absolute; inset: 0;
    background: rgba(44, 44, 44, 0.95);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 5; color: rgba(255,255,255,0.8);
}
.msbooks-pdf-loading .msbooks-spinner {
    width: 48px; height: 48px; border-width: 4px;
    border-color: rgba(255,255,255,0.2); border-top-color: var(--msbooks-highlight);
}
.msbooks-pdf-loading p { font-size: 16px; margin-top: 16px; }

/* ============================================================
 *  RESPONSIVE
 * ============================================================ */
@media (max-width: 992px) {
    .msbooks-header { padding: 16px; }
    .msbooks-logo-text { font-size: 15px; }
    .msbooks-viewer-title { max-width: 120px; font-size: 13px; }
    .msbooks-toolbar-center { gap: 4px; }
    .msbooks-toolbar-btn { padding: 4px 8px; min-width: 32px; height: 32px; }
    .msbooks-zoom-level { font-size: 12px; }
    .msbooks-page-nav input { width: 40px; }
}

@media (max-width: 768px) {
    .msbooks-container { padding: 12px; }
    .msbooks-header { padding: 14px; gap: 12px; }
    .msbooks-header-right { width: 100%; }
    .msbooks-logo { justify-content: center; }
    .msbooks-header-center { max-width: 100%; order: 3; }
    .msbooks-header-left { width: 100%; text-align: center; order: 2; }
    .msbooks-request-btn { width: 100%; justify-content: center; font-size: 13px; padding: 8px 16px; }
    .msbooks-book-info { padding: 10px 12px; }
    .msbooks-book-title { font-size: 13px; }

    /* Mobile Viewer */
    .msbooks-viewer-toolbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
    .msbooks-toolbar-right { flex: 0 0 auto; order: 1; }
    .msbooks-toolbar-center { order: 3; width: 100%; justify-content: center; }
    .msbooks-toolbar-left { order: 2; flex: 1; justify-content: flex-end; }
    .msbooks-viewer-title { max-width: 80px; font-size: 12px; }
    .msbooks-toolbar-btn { padding: 4px 6px; min-width: 30px; height: 30px; }
    .msbooks-toolbar-btn svg { width: 16px; height: 16px; }
    .msbooks-zoom-level { display: none; }
    .msbooks-viewer-body { padding: 8px; }
    .msbooks-pages-wrapper { gap: 10px; }
    .msbooks-pdf-search-bar { min-width: 240px; left: -100px; }
}

@media (max-width: 480px) {
    .msbooks-book-title { font-size: 12px; -webkit-line-clamp: 2; text-align: center; }
    .msbooks-pagination button { padding: 6px 10px; font-size: 13px; }
    .msbooks-pdf-search-bar { min-width: 200px; left: -140px; }
    .msbooks-toolbar-left { gap: 4px; }
    .msbooks-toolbar-btn { padding: 3px 5px; min-width: 28px; height: 28px; }
}

/* ---- Print Protection ---- */
@media print {
    .msbooks-container, .msbooks-viewer-overlay, .msbooks-viewer-toolbar, .msbooks-viewer-body {
        display: none !important;
    }
}

/* ---- Selection Protection ---- */
.msbooks-viewer-overlay {
    -webkit-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
}
.msbooks-viewer-overlay canvas {
    -webkit-touch-callout: none; -webkit-user-select: none; pointer-events: none;
}

/* ---- Scrollbar Styling ---- */
.msbooks-viewer-body::-webkit-scrollbar { width: 8px; }
.msbooks-viewer-body::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
.msbooks-viewer-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
.msbooks-viewer-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ---- Animations ---- */
@keyframes msbooks-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.msbooks-book-card { animation: msbooks-fadeIn 0.4s ease forwards; }
.msbooks-viewer-overlay.active { animation: msbooks-fadeIn 0.2s ease; }

/* ============================================================
 *  LOGIN WALL - Guest Access Control
 * ============================================================ */

/* Blurred grid for guests (preview behind the wall) */
.msbooks-grid-blurred {
    filter: blur(6px);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Login wall overlay */
.msbooks-login-wall {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99998;
    align-items: center;
    justify-content: center;
    direction: rtl;
}

.msbooks-login-wall-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.msbooks-login-wall-modal {
    position: relative;
    background: #ffffff;
    border-radius: 20px;
    padding: 40px 36px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    animation: msbooks-login-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
    z-index: 1;
}

@keyframes msbooks-login-pop {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.msbooks-login-wall-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--msbooks-primary) 0%, var(--msbooks-accent) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 24px rgba(15, 52, 96, 0.3);
}

.msbooks-login-wall-icon svg {
    width: 36px;
    height: 36px;
}

.msbooks-login-wall-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--msbooks-primary);
    margin: 0 0 14px;
    line-height: 1.6;
}

.msbooks-login-wall-desc {
    font-size: 15px;
    color: var(--msbooks-text);
    margin: 0 0 24px;
    line-height: 2;
}

/* ---- Free Badge ---- */
.msbooks-login-wall-free-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 24px;
    line-height: 1.8;
    border: 1px solid #a5d6a7;
}

.msbooks-login-wall-free-badge svg {
    flex-shrink: 0;
    color: #43a047;
}

/* ---- Login Button (removed - no redirect) ---- */
.msbooks-login-wall-btn {
    display: none;
}

.msbooks-login-wall-register {
    display: none;
}

.msbooks-login-wall-preview {
    display: block;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--msbooks-primary) 0%, var(--msbooks-accent) 100%);
    border: none;
    color: #fff;
    padding: 14px 32px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--msbooks-transition);
    box-shadow: 0 6px 20px rgba(15, 52, 96, 0.35);
    width: 100%;
}

.msbooks-login-wall-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(15, 52, 96, 0.45);
}

/* ---- Preview Mode Banner ---- */
.msbooks-preview-banner {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--msbooks-radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.8;
    text-align: center;
    flex-wrap: wrap;
}

.msbooks-preview-banner svg {
    flex-shrink: 0;
}

.msbooks-preview-banner a {
    color: #fff;
    text-decoration: underline;
    font-weight: 700;
}

.msbooks-preview-banner a:hover {
    text-decoration: none;
}

/* ---- Lock Overlay on Book Cards (Preview Mode) ---- */
.msbooks-lock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    z-index: 5;
    transition: var(--msbooks-transition);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.msbooks-lock-overlay svg {
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
    animation: msbooks-lock-pulse 2s ease-in-out infinite;
}

@keyframes msbooks-lock-pulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.msbooks-book-card:hover .msbooks-lock-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.msbooks-book-card:hover .msbooks-lock-overlay svg {
    opacity: 1;
    transform: scale(1.15);
}

/* ---- Floating Login Button (Preview Mode) ---- */
.msbooks-floating-login {
    position: fixed;
    bottom: 28px;
    left: 28px;
    z-index: 99990;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--msbooks-primary) 0%, var(--msbooks-accent) 100%);
    color: #fff !important;
    padding: 14px 26px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
    box-shadow: 0 8px 30px rgba(15, 52, 96, 0.45);
    transition: var(--msbooks-transition);
    animation: msbooks-float-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    direction: rtl;
    cursor: pointer;
    /* Scope to msbooks pages only */
    isolation: isolate;
}

.msbooks-floating-login:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(15, 52, 96, 0.55);
    color: #fff !important;
}

.msbooks-floating-login:active {
    transform: translateY(-1px);
}

@keyframes msbooks-float-in {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Login Wall Responsive ---- */
@media (max-width: 480px) {
    .msbooks-login-wall-modal {
        padding: 30px 24px;
        border-radius: 16px;
    }
    .msbooks-login-wall-icon {
        width: 64px;
        height: 64px;
    }
    .msbooks-login-wall-icon svg {
        width: 28px;
        height: 28px;
    }
    .msbooks-login-wall-title {
        font-size: 18px;
    }
    .msbooks-login-wall-btn {
        padding: 12px 24px;
        font-size: 15px;
    }
    .msbooks-preview-banner {
        font-size: 13px;
        padding: 8px 14px;
    }
    .msbooks-floating-login {
        bottom: 18px;
        left: 18px;
        padding: 12px 20px;
        font-size: 14px;
    }
    .msbooks-lock-overlay svg {
        width: 20px;
        height: 20px;
    }
}
