/* ============================================
   لوحة الإدارة — هيكل وتخطيط احترافي (ليس ألوان فقط)
   ============================================ */

:root {
    --sidebar-width: 280px;
    --topbar-height: 56px;
    --primary: #0f172a;
    --primary-soft: #1e293b;
    --accent: #0ea5e9;
    --accent-soft: #e0f2fe;
    --bg: #f1f5f9;
    --card-bg: #fff;
    --card-radius: 12px;
    --sidebar-text: rgba(255,255,255,0.9);
    --sidebar-text-muted: rgba(255,255,255,0.6);
    --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

.admin-body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    font-family: var(--font);
    overflow-x: hidden;
}

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ========== القائمة الجانبية — هيكل جديد ========== */
.admin-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--sidebar-text);
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.sidebar-brand-text { letter-spacing: -0.02em; }

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.sidebar-menu::-webkit-scrollbar { width: 5px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    margin: 2px 0.75rem;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.sidebar-item i { font-size: 1.1rem; opacity: 0.9; }
.sidebar-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-item.active { background: var(--accent); color: #fff; }

.sidebar-group { margin: 2px 0.75rem 2px 0; }

.sidebar-group-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: var(--font);
    text-align: right;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.sidebar-group-btn i:first-child { font-size: 1.1rem; opacity: 0.9; }
.sidebar-group-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-group-btn.collapsed .sidebar-chevron { transform: rotate(-90deg); }
.sidebar-chevron { margin-right: auto; font-size: 0.8rem; transition: transform 0.2s; }

.sidebar-group-inner {
    padding: 0.25rem 0 0.5rem 0.5rem;
    border-right: 2px solid rgba(255,255,255,0.1);
    margin-right: 1.5rem;
}

.sidebar-subitem {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--sidebar-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    margin: 2px 0;
    transition: background 0.2s, color 0.2s;
}

.sidebar-subitem:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-text); }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--sidebar-text);
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { display: block; font-weight: 600; font-size: 0.9rem; color: var(--sidebar-text); }
.sidebar-user-link { font-size: 0.8rem; color: var(--sidebar-text-muted); text-decoration: none; }
.sidebar-user-link:hover { color: var(--accent); }
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    color: var(--sidebar-text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
}
.sidebar-logout:hover { color: #f87171; }

/* ========== منطقة المحتوى (يمين السايدبار) ========== */
.admin-content-wrap {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.admin-sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #64748b;
    padding: 0.5rem;
    cursor: pointer;
}

.admin-breadcrumb .breadcrumb {
    background: none;
    padding: 0;
    font-size: 0.875rem;
}

.admin-breadcrumb .breadcrumb-item a { color: #64748b; text-decoration: none; }
.admin-breadcrumb .breadcrumb-item a:hover { color: var(--primary); }
.admin-breadcrumb .breadcrumb-item.active { color: var(--primary); font-weight: 600; }
.admin-breadcrumb .breadcrumb-item + .breadcrumb-item::before { content: "\f285"; font-family: "bootstrap-icons"; color: #94a3b8; }

.admin-topbar-actions { margin-right: auto; }

.admin-main {
    flex: 1;
    padding: 1.5rem;
    overflow-x: hidden;
}

/* ========== عنوان الصفحة ========== */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    letter-spacing: -0.02em;
}

/* ========== بطاقات الإحصائيات — تصميم جديد ========== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

.stat-card .card-body {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card-icon.primary { background: var(--accent-soft); color: var(--accent); }
.stat-card-icon.success { background: #dcfce7; color: #16a34a; }
.stat-card-icon.warning { background: #fef3c7; color: #d97706; }
.stat-card-icon.info { background: #e0e7ff; color: #4f46e5; }

.stat-card-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-card-label { font-size: 0.8rem; color: #64748b; font-weight: 500; margin-top: 2px; }

/* ========== البطاقات ========== */
.admin-main .card {
    border: 1px solid #e2e8f0;
    border-radius: var(--card-radius);
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    overflow: hidden;
}

.admin-main .card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    padding: 1rem 1.25rem;
}

.admin-main .card-body { padding: 1.25rem; }

/* ========== الجداول ========== */
.admin-main .table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.85rem 1rem;
}

.admin-main .table tbody td {
    padding: 0.9rem 1rem;
    vertical-align: middle;
    color: #334155;
    font-size: 0.9rem;
}

.admin-main .table tbody tr { transition: background 0.15s; }
.admin-main .table tbody tr:hover { background: #f8fafc; }
.admin-main .table tbody tr:nth-child(even) { background: #fafafa; }
.admin-main .table tbody tr:nth-child(even):hover { background: #f1f5f9; }

.table-empty {
    text-align: center;
    color: #94a3b8;
    padding: 2.5rem 1rem !important;
    font-size: 0.9rem;
}

/* ========== أزرار ========== */
.admin-main .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.admin-main .btn-primary:hover {
    background: #0284c7;
    border-color: #0284c7;
}

/* ========== overlay للقائمة الجانبية (جوال) ========== */
.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1025;
    opacity: 0;
    transition: opacity 0.3s;
}

.admin-sidebar-overlay.show {
    display: block;
    opacity: 1;
}

@media (min-width: 992px) {
    .admin-sidebar-overlay { display: none !important; }
}

/* ========== متجاوب — جوال وتابلت ========== */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(100%);
        transition: transform 0.3s ease;
        width: min(320px, 85vw);
        min-width: 280px;
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-content-wrap { margin-right: 0; }
    .admin-topbar {
        padding: 0 1rem;
        gap: 0.5rem;
    }
    .admin-breadcrumb .breadcrumb { font-size: 0.8rem; }
    .admin-main {
        padding: 1rem;
    }
}

@media (max-width: 575.98px) {
    .admin-topbar {
        padding: 0 0.75rem;
        flex-wrap: wrap;
    }
    .admin-topbar-actions {
        width: 100%;
        margin-right: 0;
        margin-top: 0.25rem;
        order: 3;
    }
    .admin-main {
        padding: 0.75rem;
    }
    .page-header {
        flex-direction: column;
        align-items: stretch !important;
    }
    .page-title { font-size: 1.25rem; }
}

/* جداول متجاوبة — تمرير أفقي على الجوال */
.admin-main .table-responsive,
.admin-main .card-body:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0;
}

.admin-main .card-body:has(> table) {
    padding-left: 0;
    padding-right: 0;
}

.admin-main .card-body:has(> table) > table {
    margin-bottom: 0;
}

.admin-main .table {
    min-width: 560px;
}

@media (max-width: 767.98px) {
    .admin-main .table thead th,
    .admin-main .table tbody td {
        padding: 0.65rem 0.5rem;
        font-size: 0.85rem;
    }
}
