/* ============================================================
   مكتبة الرقية الشرعية الصوتية – Front-end Styles
   Matches screenshot designs – RTL / Arabic first
   ============================================================ */

/* ── Reset & Base ───────────────────────────────────── */
.ruqyah-library-widget,
.ruqyah-cards-grid {
    direction: rtl;
    font-family: 'Segoe UI', Tahoma, 'Noto Naskh Arabic', Arial, sans-serif;
    box-sizing: border-box;
}

.ruqyah-library-widget *,
.ruqyah-cards-grid * {
    box-sizing: inherit;
}

/* ── Cards Grid ─────────────────────────────────────── */
.ruqyah-cards-grid {
    display: grid;
    gap: 16px;
    max-width: 1200px;
    margin: auto;
    width: 100%;
}

.ruqyah-cols-1 { grid-template-columns: 1fr; }
.ruqyah-cols-2 { grid-template-columns: repeat(2, 1fr);}
.ruqyah-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ruqyah-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .ruqyah-cols-3,
    .ruqyah-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .ruqyah-cols-2,
    .ruqyah-cols-3,
    .ruqyah-cols-4 { grid-template-columns: 1fr; }
}

/* ── Single Audio Card ──────────────────────────────── */
.ruqyah-cards-grid .ruqyah-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    background: #ffffff;
    border-radius: 16px;
    padding: 20px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    transition: box-shadow .25s ease, transform .2s ease;
    cursor: default;
    position: relative;
    overflow: hidden;
}

.ruqyah-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,.12);
    transform: translateY(-2px);
}

/* Play Button */
.ruqyah-play-btn {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #4a7c40;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .2s ease, transform .15s ease;
    outline: none;
    order: -1; /* appears first in RTL (right side) */
}

.ruqyah-play-btn:hover {
    background-color: #3a6430;
    transform: scale(1.08);
}

.ruqyah-play-btn:disabled {
    background-color: #c5c5c5;
    cursor: not-allowed;
    transform: none;
}

.ruqyah-play-btn svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
    pointer-events: none;
    /* Offset play icon slightly right for optical centering */
    position: relative;
    left: -1px;
}

.ruqyah-play-btn.is-playing svg.ruqyah-play-icon  { display: none; }
.ruqyah-play-btn.is-playing svg.ruqyah-pause-icon { display: block !important; }

/* Card Info */
.ruqyah-card-info {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.ruqyah-card-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ruqyah-card-sheikh {
    font-size: 13px;
    color: #777777;
    display: block;
}

/* Duration Badge */
.ruqyah-card-duration {
    flex-shrink: 0;
    font-size: 13px;
    color: #888;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    order: 1;
    /* Appears on the left (in RTL that is the visual left) */
    margin-inline-start: auto;
}

/* No results */
.ruqyah-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 15px;
}

/* ── Library Widget – Header ────────────────────────── */
.ruqyah-lib-header {
    position: sticky;
    top: 96px;
    z-index: 1;
    border-bottom: solid 1px #e7e2da;
    background-color: #fbfaf8 !important;
    padding: 48px 24px 32px;
    text-align: center;
}

.ruqyah-lib-title {
    font-size: clamp(26px, 4vw, 42px);
    font-weight: 800;
    color: #1a1a1a;
    margin: 0 0 10px;
    font-family: 'Segoe UI', 'Noto Naskh Arabic', sans-serif;
}

.ruqyah-lib-subtitle {
    font-size: 15px;
    color: #888;
    margin: 0 0 36px;
}

/* ── Tabs ───────────────────────────────────────────── */
.ruqyah-tabs-wrap {
    margin-top: 8px;
}

.ruqyah-tabs-wrap.ruqyah-tabs-sticky {

    padding: 12px 0;
}

.ruqyah-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}

.ruqyah-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1.5px solid #d0c9be;
    border-radius: 50px;
    background: #ffffff;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.ruqyah-tab-btn:hover {
    border-color: #4a7c40;
    color: #4a7c40;
}

.ruqyah-tab-btn.active {
    background-color: #4a7c40;
    border-color: #4a7c40;
    color: #ffffff;
    font-weight: 700;
}

.ruqyah-tab-icon {
    font-size: 16px;
    line-height: 1;
}

.ruqyah-tab-count {
    background: rgba(0,0,0,.1);
    border-radius: 50px;
    padding: 1px 7px;
    font-size: 12px;
    font-weight: 600;
}

.ruqyah-tab-btn.active .ruqyah-tab-count {
    background: rgba(255,255,255,.25);
}

/* ── Library Content Area ───────────────────────────── */
.ruqyah-lib-content {
    padding: 32px 24px 48px;
    background: #f8f6f1;
    min-height: 200px;
}

/* Section Meta (icon + title) */
.ruqyah-lib-section-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: center;
    flex-direction: column;
    margin-bottom: 28px;
    text-align: center;
}

.ruqyah-lib-section-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background-color: #4a7c40;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    box-shadow: 0 4px 16px rgba(74,124,64,.3);
}

.ruqyah-lib-section-title {
    font-size: clamp(24px, 3.5vw, 38px);
    font-weight: 800;
    color: #4a7c40;
    margin: 12px 0 4px;
}

.ruqyah-lib-section-desc {
    font-size: 14px;
    color: #777;
    margin: 0;
}

/* ── Search ─────────────────────────────────────────── */
.ruqyah-search-wrap {
    max-width: 600px;
    margin: 0 auto 32px;
    position: relative;
    display: flex;
    align-items: center;
}

.ruqyah-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #4a7c40;
    display: flex;
    pointer-events: none;
}

.ruqyah-search-icon svg {
    width: 18px;
    height: 18px;
}

.ruqyah-search-input {
    width: 100%;
    padding: 14px 48px 14px 20px;
    border: 1.5px solid #e0d9ce;
    /* border-radius: 50px; */
    font-size: 15px;
    outline: none;
    background: #ffffff;
    color: #333;
    font-family: inherit;
    direction: rtl;
    transition: border-color .2s;
}

.ruqyah-search-input:focus {
    border: none;
    outline: none;
    /* box-shadow: 0 0 0 3px rgba(74,124,64,.12); */
}

.ruqyah-search-input::placeholder {
    color: #aaa;
}

/* ── Loading Spinner ────────────────────────────────── */
.ruqyah-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.ruqyah-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(74,124,64,.2);
    border-top-color: #4a7c40;
    border-radius: 50%;
    animation: ruqyah-spin .7s linear infinite;
}

@keyframes ruqyah-spin {
    to { transform: rotate(360deg); }
}

/* ── Global Audio Player ────────────────────────────── */
.ruqyah-global-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #2d4a28;
    color: #fff;
    box-shadow: 0 -4px 24px rgba(0,0,0,.3);
    direction: rtl;
}

.ruqyah-global-audio { display: none; }

.ruqyah-player-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Player Controls */
.ruqyah-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ruqyah-player-controls button,
.ruqyah-player-play-pause {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    transition: background .2s;
}

.ruqyah-player-controls button:hover { background: rgba(255,255,255,.1); }

.ruqyah-player-play-pause {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,.15) !important;
    justify-content: center;
}

.ruqyah-player-play-pause:hover { background: rgba(255,255,255,.25) !important; }

.ruqyah-player-controls svg { width: 20px; height: 20px; fill: currentColor; }
.ruqyah-player-play-pause svg { width: 24px; height: 24px; }

/* Player Info */
.ruqyah-player-info {
    flex: 1;
    min-width: 120px;
}

.ruqyah-player-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ruqyah-player-sheikh {
    display: block;
    font-size: 12px;
    opacity: .7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress */
.ruqyah-player-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 2;
    min-width: 200px;
}

.ruqyah-player-current,
.ruqyah-player-total {
    font-size: 12px;
    opacity: .8;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    min-width: 36px;
}

.ruqyah-player-progress {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,.2);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.ruqyah-player-progress-bar {
    height: 100%;
    background: #a8d5a0;
    border-radius: 4px;
    width: 0%;
    transition: width .1s linear;
}

/* Close Button */
.ruqyah-player-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.6);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    transition: color .2s;
}

.ruqyah-player-close:hover { color: #fff; }

/* ── Card playing state ─────────────────────────────── */
.ruqyah-card.is-playing {
    background: linear-gradient(135deg, #f0f8ee 0%, #fff 100%);
    border: 1.5px solid rgba(74,124,64,.3);
}

/* ── Fade animation for grid refresh ────────────────── */
@keyframes ruqyah-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ruqyah-card {
    animation: ruqyah-fade-in .3s ease both;
}

/* Stagger cards */
.ruqyah-card:nth-child(2)  { animation-delay: .04s; }
.ruqyah-card:nth-child(3)  { animation-delay: .08s; }
.ruqyah-card:nth-child(4)  { animation-delay: .12s; }
.ruqyah-card:nth-child(5)  { animation-delay: .16s; }
.ruqyah-card:nth-child(6)  { animation-delay: .20s; }
.ruqyah-card:nth-child(7)  { animation-delay: .24s; }
.ruqyah-card:nth-child(8)  { animation-delay: .28s; }
