/* ===== My Library Plugin v2 — Frontend Styles ===== */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
    --mlb-primary:      #1a1a2e;
    --mlb-primary-mid:  #2d2d5e;
    --mlb-accent:       #c9a84c;
    --mlb-accent-light: #e8c97a;
    --mlb-cream:        #faf7f2;
    --mlb-white:        #ffffff;
    --mlb-text:         #1a1a2e;
    --mlb-muted:        #6b6b8a;
    --mlb-border:       #e8e4dc;
    --mlb-radius:       4px;
    --mlb-radius-lg:    10px;
    --mlb-shadow:       0 2px 16px rgba(26,26,46,0.08);
    --mlb-shadow-hover: 0 14px 40px rgba(26,26,46,0.16);
    --mlb-font:         'Tajawal', sans-serif;
}

/* ============================================================
   LIBRARY GRID
   ============================================================ */
.mlb-library {
    display: grid;
    gap: 28px;
    margin: 40px 0;
    direction: rtl;
}
.mlb-cols-1 { grid-template-columns: 1fr; }
.mlb-cols-2 { grid-template-columns: repeat(2, 1fr); }
.mlb-cols-3 { grid-template-columns: repeat(3, 1fr); }
.mlb-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .mlb-library { grid-template-columns: repeat(2, 1fr) !important; gap: 20px; }
}
@media (max-width: 520px) {
    .mlb-library { grid-template-columns: 1fr !important; gap: 16px; }
}

/* ============================================================
   BOOK CARD
   ============================================================ */
.mlb-card {
    background: var(--mlb-white);
    border-radius: var(--mlb-radius-lg);
    box-shadow: var(--mlb-shadow);
    overflow: hidden;
    transition: transform 0.35s cubic-bezier(.16,1,.3,1),
                box-shadow 0.35s ease;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--mlb-border);
    position: relative;
    font-family: var(--mlb-font);
}
.mlb-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 0;
    background: linear-gradient(to bottom, var(--mlb-accent), var(--mlb-primary));
    transition: height 0.4s ease;
    z-index: 2;
    border-radius: 0 var(--mlb-radius-lg) 0 0;
}
.mlb-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--mlb-shadow-hover);
}
.mlb-card:hover::before { height: 100%; }

/* Cover */

/* Cover */
.mlb-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: linear-gradient(145deg, #1a1a2e 0%, #2d2d5e 60%, #1a1a2e 100%);
}

/* زر التحميل بين الصورة والمعلومات */
    width: 100%;
    border-radius: 0;
    margin: 0;
    border-left: none;
    border-right: none;
    border-top: none;
}



.mlb-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(26,26,46,0.65) 0%, transparent 55%);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.35s ease;
}
.mlb-card:hover .mlb-cover::after { opacity: 1; }

.mlb-cover a { display: block; width: 100%; height: 100%; }
.mlb-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(.16,1,.3,1);
    display: block;
}
.mlb-card:hover .mlb-cover img { transform: scale(1.07); }

/* Quick-download overlay button */
.mlb-cover-action {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 3;
    opacity: 0;
    transition: all 0.3s cubic-bezier(.16,1,.3,1);
    white-space: nowrap;
    background: var(--mlb-accent);
    color: var(--mlb-primary);
    border: none;
    padding: 9px 20px;
    border-radius: var(--mlb-radius);
    font-family: var(--mlb-font);
    font-weight: 800;
    font-size: 0.82rem;
    cursor: pointer;
    letter-spacing: 0.3px;
}
.mlb-card:hover .mlb-cover-action {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Card info section */
.mlb-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
    direction: rtl;
    text-align: right;
}
.mlb-title {
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--mlb-text);
    margin: 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--mlb-font);
}
.mlb-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}
.mlb-title a:hover { color: var(--mlb-accent); }

.mlb-author {
    font-size: 0.82rem;
    color: var(--mlb-muted);
    margin: 0;
    font-weight: 500;
    font-family: var(--mlb-font);
    display: flex;
    align-items: center;
    gap: 5px;
}
.mlb-author-dot {
    width: 5px;
    height: 5px;
    background: var(--mlb-accent);
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.mlb-desc {
    font-size: 0.82rem;
    color: var(--mlb-muted);
    line-height: 1.65;
    margin: 4px 0 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--mlb-font);
}
.mlb-card-divider {
    height: 1px;
    background: var(--mlb-border);
    margin: 10px 0 6px;
}
.mlb-btn-download {
    width: 100%;
    padding: 11px 14px;
    background: var(--mlb-primary);
    color: var(--mlb-accent);
    border: 2px solid var(--mlb-primary);
    border-radius: var(--mlb-radius);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--mlb-font);
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.mlb-btn-download:hover {
    background: var(--mlb-accent);
    border-color: var(--mlb-accent);
    color: var(--mlb-primary);
}
.mlb-unavailable {
    display: block;
    text-align: center;
    color: var(--mlb-muted);
    font-size: 0.8rem;
    margin-top: 6px;
    font-family: var(--mlb-font);
    font-style: italic;
}

/* ============================================================
   SINGLE BOOK — DOWNLOAD SECTION (auto-injected before comments)
   ============================================================ */
.mlb-single-download-wrap {
    margin: 48px 0 32px;
    padding: 38px 44px;
    background: var(--mlb-primary);
    border-radius: var(--mlb-radius-lg);
    position: relative;
    overflow: hidden;
    direction: rtl;
    font-family: var(--mlb-font);
}
.mlb-single-download-wrap::before {
    content: '❝';
    position: absolute;
    left: -10px;
    bottom: -30px;
    font-size: 150px;
    color: rgba(201,168,76,0.07);
    font-family: Georgia, serif;
    line-height: 1;
    pointer-events: none;
    user-select: none;
}
.mlb-sdw-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--mlb-accent);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
    font-family: var(--mlb-font);
}
.mlb-single-download-wrap h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin: 0 0 6px;
    font-family: var(--mlb-font);
    line-height: 1.3;
}
.mlb-single-download-wrap p {
    font-size: 0.92rem;
    color: rgba(255,255,255,0.6);
    margin: 0 0 26px;
    line-height: 1.6;
    font-family: var(--mlb-font);
}
.mlb-btn-single-download {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 34px;
    background: var(--mlb-accent);
    color: var(--mlb-primary);
    border: none;
    border-radius: var(--mlb-radius);
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    font-family: var(--mlb-font);
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
}
.mlb-btn-single-download:hover {
    background: var(--mlb-accent-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(201,168,76,0.35);
}

@media (max-width: 600px) {
    .mlb-single-download-wrap {
        padding: 28px 24px 110px;
    }
    .mlb-single-download-wrap h3 { font-size: 1.2rem; }
}

/* ============================================================
   STICKY MOBILE BAR
   ============================================================ */
.mlb-sticky-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99998;
    padding: 13px 18px;
    background: var(--mlb-primary);
    border-top: 2px solid var(--mlb-accent);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.22);
    direction: rtl;
    font-family: var(--mlb-font);
    align-items: center;
    gap: 12px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
@media (max-width: 768px) {
    .mlb-sticky-bar { display: flex; }
}
.mlb-sticky-bar-title {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255,255,255,0.78);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mlb-sticky-bar-btn {
    flex-shrink: 0;
    padding: 10px 22px;
    background: var(--mlb-accent);
    color: var(--mlb-primary);
    border: none;
    border-radius: var(--mlb-radius);
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    font-family: var(--mlb-font);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 0.2s;
}
.mlb-sticky-bar-btn:hover { background: var(--mlb-accent-light); }

/* ============================================================
   MODAL
   ============================================================ */
.mlb-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.mlb-modal.is-open { display: flex; }

.mlb-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8,8,24,0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: mlbFadeIn 0.25s ease;
}
.mlb-modal-box {
    position: relative;
    background: var(--mlb-cream);
    border-radius: var(--mlb-radius-lg);
    width: 100%;
    max-width: 460px;
    padding: 0;
    box-shadow: 0 30px 80px rgba(0,0,0,0.28);
    animation: mlbSlideUp 0.38s cubic-bezier(.16,1,.3,1);
    direction: rtl;
    text-align: right;
    overflow: hidden;
}
.mlb-modal-header {
    background: var(--mlb-primary);
    padding: 28px 32px 26px;
    position: relative;
    overflow: hidden;
}
.mlb-modal-header::before {
    content: '📚';
    position: absolute;
    left: -8px;
    bottom: -28px;
    font-size: 110px;
    opacity: 0.06;
    transform: rotate(-15deg);
    pointer-events: none;
    user-select: none;
}
.mlb-modal-header-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--mlb-accent);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    font-family: var(--mlb-font);
    margin-bottom: 6px;
}
.mlb-modal-header h3 {
    font-size: 1.22rem;
    font-weight: 800;
    color: #fff;
    margin: 0 0 4px;
    font-family: var(--mlb-font);
    line-height: 1.3;
}
.mlb-modal-header p {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.55);
    margin: 0;
    font-family: var(--mlb-font);
}
.mlb-modal-close {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255,255,255,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-family: var(--mlb-font);
}
.mlb-modal-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.mlb-modal-body { padding: 26px 32px 32px; }
.mlb-modal-note {
    font-size: 0.82rem;
    color: var(--mlb-muted);
    text-align: center;
    margin: 0 0 18px;
    font-family: var(--mlb-font);
    line-height: 1.55;
    background: rgba(201,168,76,0.1);
    border: 1px solid rgba(201,168,76,0.25);
    border-radius: var(--mlb-radius);
    padding: 9px 14px;
}
.mlb-modal-note strong { color: var(--mlb-text); }

.mlb-field { margin-bottom: 16px; }
.mlb-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--mlb-text);
    margin-bottom: 7px;
    font-family: var(--mlb-font);
}
.mlb-field label .opt {
    font-size: 0.76rem;
    font-weight: 400;
    color: var(--mlb-muted);
    margin-right: 4px;
}
.mlb-field input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--mlb-border);
    border-radius: var(--mlb-radius);
    font-size: 0.92rem;
    color: var(--mlb-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: var(--mlb-font);
    direction: rtl;
    background: #fff;
}
.mlb-field input:focus {
    outline: none;
    border-color: var(--mlb-accent);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.16);
}
.mlb-field input::placeholder { color: #bbb; }

.mlb-btn-submit {
    width: 100%;
    padding: 14px;
    background: var(--mlb-primary);
    color: var(--mlb-accent);
    border: none;
    border-radius: var(--mlb-radius);
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--mlb-font);
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}
.mlb-btn-submit:hover { background: var(--mlb-primary-mid); transform: translateY(-1px); }
.mlb-btn-submit:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.mlb-btn-text, .mlb-btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mlb-form-msg {
    margin-top: 14px;
    padding: 11px 16px;
    border-radius: var(--mlb-radius);
    font-size: 0.88rem;
    display: none;
    text-align: center;
    font-family: var(--mlb-font);
    font-weight: 600;
    line-height: 1.5;
}
.mlb-form-msg.success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1.5px solid #bbf7d0;
    display: block;
}
.mlb-form-msg.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1.5px solid #fecaca;
    display: block;
}
.mlb-no-books {
    text-align: center;
    color: var(--mlb-muted);
    padding: 60px 20px;
    font-family: var(--mlb-font);
    font-size: 1.05rem;
}

/* ============================================================
   SPINNER
   ============================================================ */
.mlb-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(201,168,76,0.3);
    border-top-color: var(--mlb-accent);
    border-radius: 50%;
    animation: mlbSpin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
@keyframes mlbSpin { to { transform: rotate(360deg); } }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes mlbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes mlbSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
