/* ===== مدرسة السلام الخاصة - نظام إدارة المكتبة ===== */
/* ===== المتغيرات ===== */
:root {
    --primary: #1a237e;
    --primary-light: #283593;
    --primary-dark: #0d1b5e;
    --secondary: #00897b;
    --secondary-light: #26a69a;
    --accent: #ff8f00;
    --accent-light: #ffab00;
    --success: #2e7d32;
    --warning: #f57f17;
    --danger: #c62828;
    --info: #0277bd;
    --bg-gradient: linear-gradient(135deg, #1a237e 0%, #00897b 100%);
    --bg-card: #ffffff;
    --bg-body: #f0f2f5;
    --bg-sidebar: #1a237e;
    --text-primary: #212121;
    --text-secondary: #616161;
    --text-light: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ===== إعادة تعيين ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ===== شاشة تسجيل الدخول ===== */
.login-page {
    min-height: 100vh;
    background: var(--bg-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    animation: rotate 30s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.login-container {
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 420px;
    max-width: 95%;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
}

.login-container .logo-area {
    text-align: center;
    margin-bottom: 25px;
}

.login-container .logo-area img {
    max-height: 100px;
    margin-bottom: 10px;
}

.login-container .logo-placeholder {
    width: 100px;
    height: 100px;
    background: var(--bg-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    color: white;
    font-size: 14px;
    opacity: 0.7;
    border: 3px dashed rgba(255,255,255,0.5);
}

.login-container h1 {
    color: var(--primary);
    font-size: 22px;
    text-align: center;
    margin-bottom: 5px;
}

.login-container p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 25px;
    font-size: 14px;
}

.login-container .form-group {
    margin-bottom: 18px;
}

.login-container label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.login-container input, .login-container select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.3s;
    font-family: var(--font-family);
}

.login-container input:focus, .login-container select:focus {
    border-color: var(--secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,137,123,0.15);
}

.login-container .btn-login {
    width: 100%;
    padding: 14px;
    background: var(--bg-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.login-container .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(26,35,126,0.3);
}

/* ===== تخطيط الصفحة الرئيسية ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ===== الشريط الجانبي ===== */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-light);
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: all 0.3s;
    overflow-y: auto;
}

.sidebar .sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar .sidebar-header .logo-placeholder {
    width: 70px;
    height: 70px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 12px;
    border: 2px dashed rgba(255,255,255,0.3);
}

.sidebar .sidebar-header .logo-placeholder img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 50%;
}

.sidebar .sidebar-header h3 {
    font-size: 16px;
    margin-bottom: 3px;
}

.sidebar .sidebar-header small {
    opacity: 0.7;
    font-size: 12px;
}

.sidebar .user-info {
    padding: 15px 20px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar .user-info .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
}

.sidebar .user-info .user-details h4 {
    font-size: 14px;
}

.sidebar .user-info .user-details span {
    font-size: 11px;
    opacity: 0.7;
}

.sidebar .nav-menu {
    padding: 15px 0;
}

.sidebar .nav-menu .nav-section {
    padding: 8px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 1px;
}

.sidebar .nav-menu .nav-item {
    display: flex;
    align-items: center;
    padding: 13px 20px;
    color: rgba(255,255,255,0.7);
    transition: all 0.3s;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    gap: 12px;
    border-right: 3px solid transparent;
    margin: 2px 8px;
    border-radius: 8px;
}

.sidebar .nav-menu .nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-right-color: var(--secondary);
    padding-right: 22px;
}

.sidebar .nav-menu .nav-item.active {
    background: rgba(255,255,255,0.12);
    color: white;
    border-right-color: var(--accent);
    font-weight: 700;
}

.sidebar .nav-menu .nav-item .icon {
    width: 22px;
    text-align: center;
    font-size: 18px;
}

/* ===== المحتوى الرئيسي ===== */
.main-content {
    flex: 1;
    margin-right: 260px;
    padding: 20px 30px;
    min-height: 100vh;
}

/* ===== شريط العلوي ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.topbar .page-title h2 {
    color: var(--primary);
    font-size: 22px;
}

.topbar .page-title small {
    color: var(--text-secondary);
    font-size: 13px;
}

.topbar .topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar .toggle-sidebar {
    display: none;
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 20px;
}

.topbar .topbar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar .topbar-actions .btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.3s;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.topbar .topbar-actions .btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

/* ===== البطاقات ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid rgba(0,0,0,0.04);
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e8eaf6;
}

.card-header h3 {
    color: var(--primary);
    font-size: 18px;
    font-weight: 700;
}

.card-header .card-actions {
    display: flex;
    gap: 10px;
}

/* ===== الجداول ===== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table thead th {
    background: var(--primary);
    color: white;
    padding: 14px 15px;
    text-align: right;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

table thead th:first-child {
    border-radius: 0;
}

table thead th:last-child {
    border-radius: 0;
}

table tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    transition: background 0.2s;
}

table tbody tr:nth-child(even) {
    background: #f8faff;
}

table tbody tr:hover {
    background: #e8eaf6;
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== الأزرار ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-family);
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-primary { background: linear-gradient(135deg, #1a237e, #283593); color: white; }
.btn-primary:hover { background: linear-gradient(135deg, #283593, #3949ab); }

.btn-secondary { background: linear-gradient(135deg, #00897b, #26a69a); color: white; }
.btn-secondary:hover { background: linear-gradient(135deg, #26a69a, #4db6ac); }

.btn-accent { background: linear-gradient(135deg, #e65100, #ff8f00); color: white; }
.btn-accent:hover { background: linear-gradient(135deg, #ff8f00, #ffb300); }

.btn-success { background: linear-gradient(135deg, #2e7d32, #43a047); color: white; }
.btn-success:hover { background: linear-gradient(135deg, #43a047, #66bb6a); }

.btn-danger { background: linear-gradient(135deg, #c62828, #e53935); color: white; }
.btn-danger:hover { background: linear-gradient(135deg, #e53935, #ef5350); }

.btn-warning { background: linear-gradient(135deg, #e65100, #ff8f00); color: white; }
.btn-warning:hover { background: linear-gradient(135deg, #ff8f00, #ffa726); }

.btn-info { background: linear-gradient(135deg, #0277bd, #039be5); color: white; }
.btn-info:hover { background: linear-gradient(135deg, #039be5, #29b6f6); }

.btn-sm { padding: 8px 16px; font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.btn-sm:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn-lg { padding: 14px 32px; font-size: 16px; }

.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); box-shadow: none; }
.btn-outline:hover { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(26,35,126,0.25); }

.btn-print { background: linear-gradient(135deg, #546e7a, #78909c); color: white; }
.btn-print:hover { background: linear-gradient(135deg, #78909c, #90a4ae); }

/* ===== النماذج ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.3s;
    font-family: var(--font-family);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,137,123,0.15);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

/* ===== الإحصائيات (بطاقات Dashboard) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all 0.3s ease;
    border: 1px solid rgba(0,0,0,0.03);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.12);
}

.stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.stat-card .stat-info h3 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-card .stat-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-weight: 500;
}

.stat-card .stat-icon.blue { background: linear-gradient(135deg, #1a237e, #5c6bc0); }
.stat-card .stat-icon.green { background: linear-gradient(135deg, #00897b, #4db6ac); }
.stat-card .stat-icon.orange { background: linear-gradient(135deg, #e65100, #ffb74d); }
.stat-card .stat-icon.red { background: linear-gradient(135deg, #b71c1c, #ef5350); }
.stat-card .stat-icon.purple { background: linear-gradient(135deg, #4a148c, #ab47bc); }
.stat-card .stat-icon.teal { background: linear-gradient(135deg, #004d40, #26a69a); }

/* ===== البحث ===== */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.3s;
}

.search-box input:focus {
    border-color: var(--secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,137,123,0.15);
}

.search-box select {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    min-width: 150px;
}

/* ===== التنبيهات ===== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border-right: 4px solid #2e7d32; }
.alert-danger { background: #ffebee; color: #c62828; border-right: 4px solid #c62828; }
.alert-warning { background: #fff3e0; color: #e65100; border-right: 4px solid #e65100; }
.alert-info { background: #e1f5fe; color: #0277bd; border-right: 4px solid #0277bd; }

/* ===== حالة الكتب ===== */
.status-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.status-available { background: #e8f5e9; color: #2e7d32; }
.status-borrowed { background: #fff3e0; color: #e65100; }
.status-archived { background: #e1f5fe; color: #0277bd; }
.status-weeded { background: #f3e5f5; color: #6a1b9a; }
.status-overdue { background: #ffebee; color: #c62828; }
.status-returned { background: #e8f5e9; color: #2e7d32; }
.status-pending { background: #fff8e1; color: #f57f17; }
.status-approved { background: #e8f5e9; color: #2e7d32; }
.status-cancelled { background: #ffebee; color: #c62828; }
.status-active { background: #e8f5e9; color: #2e7d32; }
.status-inactive { background: #f5f5f5; color: #9e9e9e; }

/* ===== نافذة منبثقة (مودال) ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 600px;
    max-width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.3s;
}

@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    color: var(--primary);
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

/* ===== الطباعة ===== */
.print-title { display: none; font-size: 18px; font-weight: bold; color: #1a237e; text-align: center; margin-bottom: 15px; padding: 10px; border-bottom: 2px solid #1a237e; }

@media print {
    .sidebar, .topbar, .no-print, form { display: none !important; }
    .btn { display: none !important; }
    .main-content { margin-right: 0; padding: 0; }
    .card { box-shadow: none; border: none; padding: 0; margin: 0; }
    .card-header { display: none; }
    .books-table-wrap { overflow: visible; border: none; }
    .books-table-wrap table { min-width: auto; width: 100%; font-size: 8px; }
    .books-table-wrap thead th { padding: 3px; font-size: 8px; }
    .books-table-wrap thead th.sticky-r { position: static; box-shadow: none; }
    .books-table-wrap tbody td { padding: 2px; font-size: 8px; white-space: normal; overflow: visible; max-width: none; }
    .books-table-wrap tbody td.sticky-r { position: static; box-shadow: none; }
    .books-table-wrap .col-long { min-width: auto; white-space: normal; }
    .books-table-wrap .status-badge { font-size: 7px; padding: 2px 5px; }
    table { width: 100%; border-collapse: collapse; font-size: 11px; }
    table thead th {
        background: #1a237e !important; color: white !important;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
        padding: 6px 8px; font-size: 11px;
    }
    table tbody td { padding: 5px 8px; font-size: 11px; }
    table tbody tr:nth-child(even) { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .status-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .print-title { display: block !important; }
    .empty-state, .alert { display: none !important; }
}

/* ===== الصفحة الرئيسية (الهيرو) ===== */
.hero-section {
    background: linear-gradient(135deg, #1a237e 0%, #00897b 50%, #004d40 100%);
    border-radius: var(--radius-lg);
    padding: 40px;
    color: white;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.hero-section::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 100%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.06) 0%, transparent 70%);
}

.hero-section .hero-text h1 {
    font-size: 28px;
    margin-bottom: 10px;
}

.hero-section .hero-text p {
    opacity: 0.9;
    font-size: 15px;
    max-width: 500px;
}

.hero-section .hero-image {
    width: 200px;
    height: 200px;
    opacity: 0.15;
    flex-shrink: 0;
}

.hero-section .hero-image img {
    max-width: 100%;
    max-height: 100%;
}

.hero-section .hero-image-placeholder {
    width: 200px;
    height: 200px;
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0.5;
}

/* ===== شريط التبويبات ===== */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0;
}

.tab-item {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.tab-item:hover {
    color: var(--primary);
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== شاشة حجز الحصص ===== */
.schedule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.schedule-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-right: 4px solid var(--primary);
}

.schedule-card.approved { border-right-color: var(--success); }
.schedule-card.cancelled { border-right-color: var(--danger); }
.schedule-card.pending { border-right-color: var(--warning); }

/* ===== الرد ===== */
.responsive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* ===== شاشة تحميل الملفات ===== */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--secondary);
    background: rgba(0,137,123,0.05);
}

.upload-area .upload-icon {
    font-size: 48px;
    color: var(--secondary);
    margin-bottom: 15px;
}

.upload-area p {
    color: var(--text-secondary);
}

/* ===== ===== */
.pagination {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-top: 20px;
}

.pagination a {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all 0.3s;
}

.pagination a:hover, .pagination a.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== جدول يتسع داخل الصفحة بدون سكرول أفقي ===== */
.table-container.fit-wrap {
    overflow-x: visible;
}

table.fit-table {
    table-layout: fixed;
    width: 100%;
    font-size: 12.5px;
}

table.fit-table thead th {
    padding: 10px 4px;
    font-size: 11.5px;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
}

table.fit-table tbody td {
    padding: 8px 5px;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.5;
    font-size: 12px;
}

table.fit-table tbody td.fx-idx { width: 42px; color: var(--text-secondary); font-weight: 700; }
table.fit-table tbody td.fx-xs   { width: 62px; font-size: 11.5px; }
table.fit-table tbody td.fx-sm   { width: 88px; font-size: 11.5px; }
table.fit-table tbody td.fx-author { width: 22%; text-align: right; font-size: 11.5px; }
table.fit-table tbody td.fx-txt { text-align: right; font-weight: 600; }
table.fit-table tbody td.fx-title  { text-align: right; font-weight: 600; color: var(--primary); }

table.fit-table thead th.fx-idx { width: 42px; }
table.fit-table thead th.fx-xs { width: 62px; }
table.fit-table thead th.fx-sm { width: 88px; }
table.fit-table thead th.fx-author { width: 22%; }

.table-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 12px 0 4px;
}

/* ===== تبويبات التصفية (محسّنة) ===== */
.filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 6px;
    background: #eef1fb;
    border-radius: 12px;
    width: fit-content;
    max-width: 100%;
}

.filter-tabs a,
.filter-tabs button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 9px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 700;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

.filter-tabs a:hover,
.filter-tabs button:hover {
    background: #fff;
    color: var(--primary);
}

.filter-tabs a.on,
.filter-tabs button.on {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

.filter-tabs .tab-count {
    display: inline-block;
    min-width: 24px;
    padding: 1px 7px;
    background: #dfe4f5;
    color: var(--text-primary);
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 800;
    text-align: center;
}

.filter-tabs a.on .tab-count,
.filter-tabs button.on .tab-count {
    background: rgba(255, 255, 255, .28);
    color: #fff;
}

/* ===== شريط الفلاتر (أدوات بحث في مربعات أفقية) ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: #f5f7fe;
    border: 1.5px solid #e4e8f6;
    border-radius: 12px;
}

.filter-bar .fb-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.filter-bar .fb-field > label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-bar .fb-search { flex: 1 1 240px; }
.filter-bar .fb-date   { flex: 0 1 158px; }
.filter-bar .fb-select { flex: 0 1 150px; }

.filter-bar input,
.filter-bar select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 13px;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transition: border-color .2s, box-shadow .2s;
}

.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, .12);
}

.filter-bar input::placeholder { color: #9aa0b5; }

.filter-bar .fb-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: auto;
}

.filter-bar .fb-actions .btn {
    height: 40px;
    min-width: 84px;
    justify-content: center;
}

/* حقل بحث سريع داخل ترويسة البطاقة */
.inline-search {
    width: 240px;
    height: 36px;
    padding: 0 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 9px;
    font-size: 13px;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
}

.inline-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
}

.inline-search::placeholder { color: #9aa0b5; }

/* ===== إحصائيات مصغرة — صف أفقي، كل بطاقة مربع أفقي ===== */
.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.mini-stat {
    --sc: var(--primary);
    --sc-bg: rgba(0, 0, 0, .05);
    display: flex;                 /* أفقي: الأيقونة يمين والنص شمالها */
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border: 1.5px solid #e4e8f6;
    border-inline-start: 4px solid var(--sc);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
    min-width: 0;
}

.mini-stat .ms-ico {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--sc-bg);
    border: 1px solid var(--sc-bg);
    font-size: 19px;
    line-height: 1;
}

/* الرقم والعنوان في سطر واحد أفقي — بدون لفّ لسطر جديد */
.mini-stat .ms-txt {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
    flex-wrap: nowrap;
}

.mini-stat .ms-val {
    flex: 0 0 auto;
    font-size: 21px;
    font-weight: 800;
    color: var(--sc);
    line-height: 1.25;
}

.mini-stat .ms-lbl {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.mini-stat.teal   { --sc: var(--secondary);  --sc-bg: rgba(0, 150, 136, .14); }
.mini-stat.green  { --sc: var(--success);   --sc-bg: rgba(40, 167, 69, .15); }
.mini-stat.orange { --sc: #e07b00;          --sc-bg: rgba(255, 152, 0, .17); }
.mini-stat.red    { --sc: var(--danger);    --sc-bg: rgba(220, 53, 69, .14); }

/* ===== جدول الكتب الواسع (كل الحقول) ===== */
.books-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.books-table-wrap table {
    font-size: 12px;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

.books-table-wrap thead th {
    padding: 10px 5px;
    font-size: 11px;
    white-space: nowrap;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--primary);
    color: white;
}

.books-table-wrap thead th.sticky-r {
    position: sticky;
    right: 0;
    z-index: 3;
    background: var(--primary-dark);
    box-shadow: -2px 0 5px rgba(0,0,0,0.15);
}

/* --- كل الأعمدة بأضيق عرض ممكن --- */
.books-table-wrap .col-id,
.books-table-wrap .col-short,
.books-table-wrap .col-medium,
.books-table-wrap .col-long,
.books-table-wrap .col-text,
.books-table-wrap .col-badge,
.books-table-wrap .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}
.books-table-wrap .col-long { text-align: right; min-width: 80px; }
.books-table-wrap .col-medium,
.books-table-wrap .col-text { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.books-table-wrap .col-long { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* الأعمدة الثابتة على اليمين */
.books-table-wrap tbody td.sticky-r {
    position: sticky;
    right: 0;
    z-index: 1;
    background: inherit;
    box-shadow: -2px 0 5px rgba(0,0,0,0.08);
}

.books-table-wrap tbody tr:nth-child(even) td.sticky-r {
    background: #f8faff;
}

.books-table-wrap tbody tr:hover td.sticky-r {
    background: #e8eaf6;
}

.books-table-wrap tbody td.col-id {
    font-weight: 700;
    color: var(--text-secondary);
}

.books-table-wrap tbody td.col-long {
    font-weight: 600;
    color: var(--primary);
    text-align: right;
}

.books-table-wrap .status-badge {
    font-size: 10px;
    padding: 3px 10px;
    white-space: nowrap;
}

.books-table-wrap .col-actions .btn-sm {
    padding: 4px 8px;
    font-size: 10px;
}

/* ===== شاشة فارغة ===== */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.3;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ===== التذييل ===== */
.footer-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 20px 0 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 30px;
}

/* ===== رفع ملفات متعددة ===== */

/* ===== القوائم المنسدلة ===== */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    min-width: 200px;
    z-index: 100;
    left: 0;
    top: 100%;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
}

.dropdown-menu a:hover {
    background: #f5f5f5;
    color: var(--primary);
}

/* ===== التجاوب ===== */
@media (max-width: 768px) {
    .sidebar {
        right: -260px;
    }
    .sidebar.open {
        right: 0;
    }
    .main-content {
        margin-right: 0;
        padding: 15px;
    }
    .topbar .toggle-sidebar {
        display: block;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    .hero-section {
        flex-direction: column;
        text-align: center;
        padding: 25px;
    }
    .hero-section .hero-image, .hero-section .hero-image-placeholder {
        display: none;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .search-box {
        flex-direction: column;
    }
    .login-container {
        padding: 25px;
    }
    .filter-bar .fb-search,
    .filter-bar .fb-select,
    .filter-bar .fb-date {
        flex: 1 1 100%;
    }
    .filter-bar .fb-actions {
        margin-inline-start: 0;
        width: 100%;
    }
    .filter-bar .fb-actions .btn {
        flex: 1;
    }
    .inline-search {
        width: 100%;
    }
    .mini-stat {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .responsive-grid {
        grid-template-columns: 1fr;
    }
    .mini-stat {
        flex: 1 1 100%;
    }
    .filter-tabs {
        width: 100%;
    }
    .filter-tabs a,
    .filter-tabs button {
        flex: 1 1 auto;
        justify-content: center;
    }
}
