/* =====================================================
   khobr — المكتبة الرقمية المدرسية
   تصميم متجاوب 100%
===================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

/* ---------------------------------------------
   الجسم
--------------------------------------------- */
body {
    font-family: 'Cairo', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #fdfaf5;
    background-image: url('../images/bg.jpg');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: #3b2a1a;
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll;
        background-size: auto 100%;
    }
}

.font-amiri { font-family: 'Amiri', serif; }

img { max-width: 100%; height: auto; display: block; }

/* ---------------------------------------------
   الحاويات
--------------------------------------------- */
.container-khobr {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}
@media (max-width: 480px) {
    .container-khobr { padding: 0 12px; }
}

/* =====================================================
   الرأس الموحّد (Header)
===================================================== */
.khobr-header {
    width: 100%;
    padding: 0;
    background: linear-gradient(
        to left,
        rgba(253, 250, 245, 0) 0%,
        rgba(253, 250, 245, 0.5) 15%,
        rgba(253, 250, 245, 0.9) 35%,
        #fdfaf5 55%,
        #fdfaf5 100%
    );
    position: sticky;
    top: 0;
    z-index: 100;
}

.khobr-header-inner {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 0;
}

.header-school {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.school-name {
    font-family: 'Cairo', sans-serif;
    font-size: clamp(1.1rem, 2.2vw, 1.7rem);
    font-weight: 800;
    color: #1e4620;
    margin: 0 0 6px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.3px;
}

.school-ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 260px;
}

.ornament-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #b89759, transparent);
}

.ornament-diamond {
    width: 8px;
    height: 8px;
    background: #b89759;
    transform: rotate(45deg);
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(184, 151, 89, 0.25);
}

.header-divider {
    width: 1px;
    height: 55px;
    background: linear-gradient(180deg, transparent, #c8b28f, transparent);
    flex-shrink: 0;
}

.header-ministry {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
}

.ministry-logo {
    height: 55px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.ministry-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.ministry-name {
    font-family: 'Cairo', sans-serif;
    font-size: clamp(0.9rem, 1.4vw, 1.15rem);
    font-weight: 800;
    color: #1e4620;
    white-space: nowrap;
}

.ministry-name-en {
    font-family: 'Cairo', sans-serif;
    font-size: clamp(0.62rem, 0.9vw, 0.78rem);
    color: #6b6b6b;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.header-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    border-top: 1px solid rgba(200, 178, 143, 0.4);
}

.nav-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(245, 236, 224, 0.9);
    border: 1px solid #d4c0a5;
    border-radius: 8px;
    color: #4a3018;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
}
.nav-toggle i { font-size: 1.1rem; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    color: #4a3018;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: all 0.25s ease;
    position: relative;
}

.nav-link:hover {
    background: rgba(184, 151, 89, 0.15);
    color: #1e4620;
}

.nav-link.active {
    color: #1e4620;
    background: rgba(184, 151, 89, 0.2);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 14px;
    left: 14px;
    height: 2px;
    background: #8c633c;
    border-radius: 2px;
}

.nav-link i { font-size: 0.82rem; }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(184, 151, 89, 0.15);
    color: #4a3018;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 8px;
    transition: all 0.25s ease;
}
.nav-user:hover { background: rgba(184, 151, 89, 0.25); }
.nav-user i { font-size: 1.1rem; color: #8c633c; }

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.25s ease;
    cursor: pointer;
    white-space: nowrap;
}

.nav-btn-outline {
    background: rgba(253, 250, 245, 0.7);
    color: #4a3018;
    border: 1.5px solid #b89759;
}
.nav-btn-outline:hover {
    background: #b89759;
    color: #ffffff;
}

.nav-btn-solid {
    background: linear-gradient(180deg, #704b2b 0%, #4a3018 100%);
    color: #fceecb;
    border: 1.5px solid #8c633c;
}
.nav-btn-solid:hover {
    background: linear-gradient(180deg, #855b35 0%, #5c3c1e 100%);
    box-shadow: 0 4px 12px rgba(74, 48, 24, 0.3);
}

@media (max-width: 900px) {
    .header-top {
        flex-direction: column;
        gap: 10px;
        padding: 12px 0;
    }

    .header-divider {
        width: 80%;
        height: 1px;
        background: linear-gradient(90deg, transparent, #c8b28f, transparent);
    }

    .header-school,
    .header-ministry {
        width: 100%;
        justify-content: center;
    }

    .header-ministry {
        flex-direction: row;
        justify-content: center;
    }

    .school-name {
        font-size: 1.15rem;
        white-space: normal;
    }

    .ministry-logo { height: 42px; }
    .ministry-name { font-size: 0.95rem; }
    .ministry-name-en { font-size: 0.65rem; }
    .school-ornament { max-width: 180px; }

    .header-nav-bar {
        flex-wrap: wrap;
        padding: 10px 0;
    }

    .nav-toggle { display: inline-flex; }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding-top: 10px;
        border-top: 1px solid rgba(200, 178, 143, 0.4);
        margin-top: 8px;
    }

    .nav-links.open { display: flex; }

    .nav-link {
        justify-content: flex-start;
        padding: 10px 14px;
        width: 100%;
    }

    .nav-link.active::after {
        right: 0;
        left: auto;
        width: 3px;
        top: 8px;
        bottom: 8px;
        height: auto;
    }

    .nav-actions { margin-right: auto; }

    .nav-btn {
        padding: 7px 12px;
        font-size: 0.8rem;
    }

    .nav-btn span { display: none; }
    .nav-btn i { font-size: 1rem; }
    .nav-user span { display: none; }
}

@media (max-width: 380px) {
    .ministry-name { font-size: 0.85rem; }
    .ministry-logo { height: 36px; }
}

/* ---------------------------------------------
   الإطار الكلاسيكي
--------------------------------------------- */
.classic-frame {
    border: 1px solid #c8b28f;
    position: relative;
    background-color: rgba(253, 250, 245, 0.92);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 8px;
}
.classic-frame::before {
    content: '';
    position: absolute;
    top: 3px; left: 3px; right: 3px; bottom: 3px;
    border: 1px solid #e2d2b8;
    pointer-events: none;
    border-radius: 6px;
}

/* ---------------------------------------------
   الأزرار الذهبية
--------------------------------------------- */
.btn-gold {
    background: linear-gradient(180deg, #704b2b 0%, #4a3018 100%);
    color: #fceecb;
    border: 1px solid #8c633c;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-gold:hover {
    background: linear-gradient(180deg, #855b35 0%, #5c3c1e 100%);
    box-shadow: 0 4px 12px rgba(74, 48, 24, 0.3);
}
.btn-gold:active { transform: translateY(1px); }

.btn-gold-light {
    background-color: rgba(245, 236, 224, 0.9);
    color: #4a3018;
    border: 1px solid #d4c0a5;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-gold-light:hover {
    background: linear-gradient(180deg, #6e4929 0%, #4a3018 100%);
    color: #ffffff;
    border-color: #4a3018;
}

/* ---------------------------------------------
   فاصل الماسة
--------------------------------------------- */
.diamond-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
}
.diamond-divider::before,
.diamond-divider::after {
    content: "";
    height: 1px;
    width: 80px;
    background: linear-gradient(90deg, transparent, #8c6f4a, transparent);
}
.diamond {
    width: 8px; height: 8px;
    background-color: #8c6f4a;
    transform: rotate(45deg);
    margin: 0 10px;
}
@media (max-width: 480px) {
    .diamond-divider::before,
    .diamond-divider::after { width: 50px; }
}

/* ---------------------------------------------
   التذييل
--------------------------------------------- */
.khobr-footer {
    width: 100%;
    text-align: center;
    padding: 16px 12px;
    margin-top: auto;
    background: linear-gradient(
        to left,
        rgba(253, 250, 245, 0) 0%,
        rgba(253, 250, 245, 0.5) 15%,
        rgba(253, 250, 245, 0.9) 35%,
        #fdfaf5 55%,
        #fdfaf5 100%
    );
    color: #5a422b;
    font-size: 0.85rem;
    line-height: 1.8;
}
.footer-inner { max-width: 700px; margin: 0 auto; padding: 0 8px; }
.footer-line-1 { margin: 0; font-weight: 700; color: #3b2a1a; font-size: 0.9rem; }
.footer-line-2 { margin: 4px 0; color: #664b30; font-size: 0.82rem; }
.footer-line-3 {
    margin: 6px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #4a3018;
    font-weight: 600;
    font-size: 0.78rem;
    flex-wrap: wrap;
}
.footer-phone {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    direction: ltr;
}
.footer-sep { color: #b89759; font-weight: 300; }
.footer-name { letter-spacing: 0.5px; }

@media (max-width: 480px) {
    .khobr-footer { padding: 12px 10px; font-size: 0.78rem; }
    .footer-line-1 { font-size: 0.82rem; }
    .footer-line-2 { font-size: 0.75rem; }
    .footer-line-3 { font-size: 0.72rem; gap: 6px; }
}

/* ---------------------------------------------
   القلب النابض
--------------------------------------------- */
.beating-heart {
    display: inline-block;
    color: #d43a3a;
    animation: heartbeat 1.2s ease-in-out infinite;
    font-size: 1.1em;
    vertical-align: middle;
    will-change: transform;
}
@keyframes heartbeat {
    0%, 100%  { transform: scale(1); }
    15%       { transform: scale(1.25); }
    30%       { transform: scale(1); }
    45%       { transform: scale(1.18); }
    60%       { transform: scale(1); }
}

/* ---------------------------------------------
   صفحة المصادقة
--------------------------------------------- */
.auth-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    width: 100%;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 32px 28px;
}
.auth-title {
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    color: #2c1d11;
    margin: 0 0 4px;
}
.auth-subtitle {
    text-align: center;
    color: #664b30;
    font-size: 0.95rem;
    margin: 0 0 20px;
}
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
    color: #3b2a1a;
    font-size: 0.88rem;
}
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #d4c0a5;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    color: #3b2a1a;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #8c633c;
    box-shadow: 0 0 0 3px rgba(140, 99, 60, 0.15);
    background: #fff;
}
.auth-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    margin-top: 8px;
}
.auth-links {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: #664b30;
}
.auth-links a {
    color: #704b2b;
    font-weight: 700;
    text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .auth-card { padding: 24px 18px; }
    .auth-title { font-size: 1.5rem; }
    .auth-subtitle { font-size: 0.85rem; }
}

/* ---------------------------------------------
   التنبيهات
--------------------------------------------- */
.alert {
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.5;
}
.alert i { flex-shrink: 0; margin-top: 2px; }
.alert-error   { background: #fde8e8; color: #a02020; border: 1px solid #f5c0c0; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.alert-warning { background: #fff8e1; color: #8a6d00; border: 1px solid #ffe082; }
.alert-info    { background: #e3f2fd; color: #0d47a1; border: 1px solid #90caf9; }

/* ---------------------------------------------
   لوحة التحكم
--------------------------------------------- */
.dashboard-wrap {
    width: 100%;
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    padding: 20px;
    text-align: center;
    transition: transform 0.2s ease;
}
.stat-card i {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}
.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: #2c1d11;
    line-height: 1.2;
}
.stat-label {
    color: #664b30;
    font-size: 0.88rem;
    margin-top: 4px;
}
.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.quick-link {
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
}

@media (max-width: 640px) {
    .dashboard-wrap { margin: 16px auto; padding: 0 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px 10px; }
    .stat-card i { font-size: 1.5rem; margin-bottom: 4px; }
    .stat-number { font-size: 1.5rem; }
    .stat-label { font-size: 0.75rem; }
    .quick-links-grid { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------
   النماذج الكبيرة
--------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; gap: 12px; }
}
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.form-actions > * {
    flex: 1;
    min-width: 140px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 700;
    text-align: center;
}

/* ---------------------------------------------
   الجداول
--------------------------------------------- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}
.table-khobr {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    background: rgba(255, 253, 249, 0.9);
    font-size: 0.9rem;
}
.table-khobr th,
.table-khobr td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid #e6d7c3;
}
.table-khobr th {
    background: rgba(112, 75, 43, 0.08);
    font-weight: 700;
    color: #3b2a1a;
    white-space: nowrap;
}
.table-khobr tr:hover td {
    background: rgba(140, 99, 60, 0.05);
}
@media (max-width: 640px) {
    .table-khobr { font-size: 0.82rem; min-width: 500px; }
    .table-khobr th,
    .table-khobr td { padding: 8px 8px; }
}

/* =====================================================
   الصفحة الرئيسية — المكتبة
===================================================== */
.library-main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.library-hero {
    text-align: center;
    margin: 16px 0 24px;
}
.library-hero-title {
    font-family: 'Amiri', serif;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 800;
    color: #2c1d11;
    margin: 0 0 6px;
    line-height: 1.2;
    letter-spacing: -0.5px;
}
.library-hero-subtitle {
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    color: #664b30;
    font-weight: 600;
    margin: 0;
}

.search-section {
    max-width: 720px;
    margin: 0 auto 28px;
}
.search-frame {
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(74, 48, 24, 0.08);
}
.search-btn {
    padding: 10px 22px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.search-input {
    width: 100%;
    background: transparent;
    padding: 8px 12px;
    border: none;
    outline: none;
    text-align: right;
    color: #3b2a1a;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    font-weight: 500;
}
.search-input::placeholder { color: #8c7456; }
.search-icon {
    color: #8c7456;
    font-size: 1.1rem;
    margin-left: 8px;
    flex-shrink: 0;
}
@media (max-width: 480px) {
    .search-btn { padding: 9px 14px; font-size: 0.85rem; }
    .search-btn span { display: none; }
    .search-input { font-size: 0.9rem; padding: 6px 8px; }
}

/* التصنيفات الموضوعية */
.categories-section {
    margin: 24px 0 32px;
    text-align: center;
}
.categories-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #3b2a1a;
    margin-bottom: 16px;
}
.categories-title i {
    color: #8c6f4a;
    font-size: 0.7rem;
}
.categories-title h2 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}
.categories-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
}
.category-btn {
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.25s ease;
}
.category-btn.active {
    background: linear-gradient(180deg, #6e4929 0%, #4a3018 100%);
    color: #ffffff;
    border-color: #4a3018;
    box-shadow: 0 4px 12px rgba(74, 48, 24, 0.25);
}
@media (max-width: 640px) {
    .category-btn { padding: 8px 14px; font-size: 0.82rem; }
    .categories-grid { gap: 8px; }
}

/* شبكة الكتب */
.books-section { margin-top: 20px; }
.books-header {
    text-align: center;
    margin-bottom: 24px;
}
.books-title {
    font-family: 'Amiri', serif;
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 800;
    color: #2c1d11;
    margin: 6px 0;
}
.books-count {
    font-size: 0.9rem;
    color: #664b30;
    font-weight: 600;
    margin: 4px 0 0;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}
@media (max-width: 640px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }
}

.book-card {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-radius: 12px;
    background-color: rgba(255, 253, 249, 0.95);
    border: 1px solid #d9c7af;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(59, 42, 26, 0.15);
}
@media (max-width: 768px) {
    .book-card:hover { transform: none; }
}

.book-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(184, 151, 89, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.book-cover-placeholder {
    text-align: center;
    color: #d4af37;
    padding: 14px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
}
.book-cover-placeholder i { font-size: 2.4rem; opacity: 0.85; }
.book-cover-placeholder span {
    font-family: 'Amiri', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #fceecb;
    line-height: 1.3;
    padding: 0 6px;
}
.book-cover-placeholder small {
    font-size: 0.7rem;
    color: #d4af37;
    opacity: 0.85;
    font-family: 'Cairo', sans-serif;
}

.book-info { flex: 1; margin-bottom: 10px; }
.book-title {
    font-size: 1rem;
    font-weight: 800;
    color: #2c1d11;
    margin: 0 0 4px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
}
.book-author {
    font-size: 0.82rem;
    color: #664b30;
    text-align: center;
    margin: 0 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.book-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}
.book-tag {
    font-size: 0.7rem;
    padding: 3px 9px;
    border-radius: 20px;
    background: rgba(184, 151, 89, 0.15);
    color: #5a422b;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.book-tag i { font-size: 0.65rem; }

.book-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
}
.book-btn {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    transition: all 0.25s ease;
}
.book-btn-locked { opacity: 0.9; }

@media (max-width: 640px) {
    .book-title { font-size: 0.9rem; }
    .book-author { font-size: 0.75rem; }
    .book-tag { font-size: 0.65rem; padding: 2px 7px; }
    .book-btn { font-size: 0.75rem; padding: 7px 6px; }
}

/* =====================================================
   بطاقات الصفوف (المناهج) والتصنيفات (القراءة الحرة)
===================================================== */
.cards-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.card-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: linear-gradient(180deg, #fff 0%, #fdfaf5 100%);
    border: 2px solid #d4c0a5;
    border-radius: 12px;
    text-decoration: none;
    color: #3b2a1a;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    text-align: center;
}

.card-large:hover {
    transform: translateY(-5px);
    border-color: #8c633c;
    box-shadow: 0 8px 20px rgba(74, 48, 24, 0.15);
}

.card-large i {
    font-size: 3rem;
    color: #8c633c;
    margin-bottom: 15px;
}

.card-large h3 {
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    margin: 0 0 8px;
    color: #2c1d11;
}

.card-large p {
    font-size: 0.9rem;
    color: #664b30;
    margin: 0;
}

/* ---------------------------------------------
   أدوات مساعدة
--------------------------------------------- */
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.hidden { display: none !important; }

@media (max-width: 768px) {
    input, select, textarea { font-size: 16px !important; }
}

/* =====================================================
   لوحة التحكم — Sidebar
===================================================== */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 60px);
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    gap: 20px;
    width: 100%;
}
.admin-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: rgba(253, 250, 245, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #c8b28f;
    border-radius: 12px;
    padding: 18px 0;
    align-self: flex-start;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    margin: 16px 0;
}
.sidebar-close {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(245, 236, 224, 0.9);
    border: 1px solid #d4c0a5;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: #4a3018;
    cursor: pointer;
    font-size: 1rem;
    align-items: center;
    justify-content: center;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px 16px;
    border-bottom: 1px solid rgba(200, 178, 143, 0.3);
    margin-bottom: 12px;
}
.sidebar-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #b89759, #8c633c);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-weight: 700;
    color: #2c1d11;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.75rem;
    color: #8a6d00;
    margin-top: 2px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section {
    padding: 12px 18px 6px;
    font-size: 0.72rem;
    font-weight: 800;
    color: #8c6f4a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: #3b2a1a;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    border-right: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}
.sidebar-link:hover { background: rgba(184, 151, 89, 0.1); color: #1e4620; }
.sidebar-link.active {
    background: rgba(184, 151, 89, 0.15);
    color: #1e4620;
    border-right-color: #8c633c;
    font-weight: 800;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 0.95rem; color: #8c633c; }
.sidebar-link.active i { color: #4a3018; }
.sidebar-logout {
    margin-top: 8px;
    border-top: 1px solid rgba(200, 178, 143, 0.3);
    color: #a02020 !important;
    padding-top: 14px;
}
.sidebar-logout i { color: #a02020 !important; }
.sidebar-logout:hover { background: rgba(160, 32, 32, 0.08) !important; }
.admin-content { flex: 1; min-width: 0; padding: 16px 0; }
.admin-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 998;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(180deg, #704b2b 0%, #4a3018 100%);
    color: #fceecb;
    border: 2px solid #8c633c;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(74, 48, 24, 0.35);
    align-items: center;
    justify-content: center;
}

/* ---------------------------------------------
   بطاقات OTP
--------------------------------------------- */
.otp-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}
.otp-card {
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    border-width: 2px;
}
.otp-active   { border-color: #4a7c4a; }
.otp-paused   { border-color: #8a6d00; opacity: 0.9; }
.otp-pending  { border-color: #1e3a5f; opacity: 0.9; }
.otp-expired  { border-color: #999; opacity: 0.75; }
.otp-full     { border-color: #a02020; }

.otp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.otp-card-header h3 {
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    margin: 0;
    color: #2c1d11;
}
.otp-status {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(184, 151, 89, 0.15);
}
.otp-type {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    margin-right: 5px;
}
.type-student { background: #e3f2fd; color: #0d47a1; }
.type-teacher { background: #f3e5f5; color: #6a1b9a; }

.otp-code-box {
    text-align: center;
    padding: 12px;
    background: rgba(44, 29, 17, 0.06);
    border-radius: 8px;
    border: 1px dashed #c8b28f;
}
.otp-code {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 800;
    color: #4a3018;
    letter-spacing: 1.5px;
    word-break: break-all;
}
.otp-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    color: #664b30;
}
.otp-progress-wrap { margin-top: 4px; }
.otp-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: #664b30;
    margin-bottom: 4px;
    font-weight: 700;
}
.otp-progress-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    overflow: hidden;
}
.otp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #b89759, #704b2b);
    border-radius: 10px;
    transition: width 0.3s ease;
}
.otp-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(200, 178, 143, 0.3);
}

/* ---------------------------------------------
   استجابة الجوال
--------------------------------------------- */
@media (max-width: 900px) {
    .admin-layout { padding: 0; gap: 0; }
    .admin-sidebar {
        position: fixed;
        top: 0;
        right: -300px;
        bottom: 0;
        width: 280px;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        z-index: 999;
        transition: right 0.3s ease;
        padding-top: 60px;
    }
    .admin-sidebar.open {
        right: 0;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    }
    .sidebar-close { display: flex; }
    .admin-menu-toggle { display: flex; }
    .admin-content { padding: 16px 12px; width: 100%; }
}

@media (max-width: 640px) {
    .otp-cards-grid { grid-template-columns: 1fr; gap: 14px; }
    .otp-card { padding: 16px; }
    .otp-code { font-size: 0.95rem; }
    .cards-grid-large { grid-template-columns: 1fr; }
}

@media print {
    .admin-sidebar,
    .admin-menu-toggle { display: none !important; }
}