/* =========================================================
   لوحة التحكم — ثيم أسود وذهبي (مطابق لهوية الموقع)
   الملف: assets/css/admin.css
   يُربط في هيدر لوحة التحكم بعد Bootstrap وبعد وسم <style> القديم
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
    --bg-dark: #0b0a08;
    --bg-card: #15130f;
    --bg-hover: #1f1b14;
    --gold: #d4af37;
    --gold-light: #f3d77e;
    --gold-dark: #a8842a;
    --gold-grad: linear-gradient(135deg, #f6e27a 0%, #d4af37 48%, #a8842a 100%);
    --gold-soft: rgba(212, 175, 55, 0.10);
    --line: rgba(212, 175, 55, 0.16);
    --line-strong: rgba(212, 175, 55, 0.45);
    --text-main: #f5efe1;
    --text-muted: #a39a85;
    --sidebar-w: 270px;

    /* ألوان Bootstrap الداكنة */
    --bs-body-bg: #0b0a08;
    --bs-body-color: #f5efe1;
    --bs-emphasis-color: #f5efe1;
    --bs-emphasis-color-rgb: 245, 239, 225;
    --bs-secondary-color: #a39a85;
    --bs-secondary-bg: #1a1712;
    --bs-tertiary-bg: #1a1712;
    --bs-border-color: rgba(212, 175, 55, 0.16);
    --bs-heading-color: #f5efe1;
    --bs-link-color: #d4af37;
    --bs-link-color-rgb: 212, 175, 55;
    --bs-link-hover-color: #f3d77e;
    --bs-link-hover-color-rgb: 243, 215, 126;
    --bs-primary: #d4af37;
    --bs-primary-rgb: 212, 175, 55;
    --bs-focus-ring-color: rgba(212, 175, 55, 0.25);
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(900px 500px at 0% -10%, rgba(212, 175, 55, 0.08), transparent 60%),
        radial-gradient(700px 400px at 100% 110%, rgba(212, 175, 55, 0.05), transparent 60%);
    background-attachment: fixed;
    color: var(--text-main);
    overflow-x: hidden;
}
::selection { background: var(--gold); color: #0b0a08; }
::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-track { background: #0b0a08; }
::-webkit-scrollbar-thumb { background: #2a2418; border-radius: 10px; border: 2px solid #0b0a08; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

h1, h2, h3, h4, h5 { font-family: 'Tajawal', sans-serif; }

/* ================= Sidebar ================= */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #100e0b 0%, #0b0a08 100%);
    color: var(--text-muted);
    min-height: 100vh;
    position: fixed; right: 0; top: 0; z-index: 1000;
    border-left: 1px solid var(--line);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.45);
    transition: right .3s ease;
}
.sidebar-brand {
    display: block;
    padding: 1.8rem 1.5rem;
    font-family: 'Tajawal', sans-serif;
    font-size: 1.5rem; font-weight: 700;
    color: var(--gold-light);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.sidebar-brand::after {
    content: "";
    position: absolute; right: 1.5rem; left: 1.5rem; bottom: -1px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.sidebar-brand:hover { color: var(--gold-light); }
.sidebar-menu { padding: 1.2rem .9rem; list-style: none; margin: 0; }
.sidebar-menu li { margin-bottom: 4px; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 12px;
    padding: .85rem 1.1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    border-radius: 14px;
    border: 1px solid transparent;
    border-right: 1px solid transparent;
    transition: all .2s ease;
}
.sidebar-menu i { font-size: 1.15rem; color: var(--gold-dark); transition: color .2s ease; }
.sidebar-menu a:hover {
    background: var(--gold-soft);
    color: var(--text-main);
    border-color: var(--line);
    border-right: 1px solid var(--line);
}
.sidebar-menu a:hover i { color: var(--gold); }
.sidebar-menu a.active {
    background: var(--gold-grad);
    color: #0b0a08;
    border-color: transparent;
    border-right: 1px solid transparent;
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.25);
}
.sidebar-menu a.active i { color: #0b0a08; }
.sidebar-menu a.text-danger { color: #e97a6f !important; }
.sidebar-menu a.text-danger i { color: #e97a6f; }
.sidebar-menu a.text-danger:hover { background: rgba(233, 122, 111, 0.10); border-color: rgba(233, 122, 111, 0.25); }

/* ================= Main ================= */
.main-content { margin-right: var(--sidebar-w); padding: 2rem; min-height: 100vh; transition: margin .3s ease; }

@media (max-width: 991px) {
    .sidebar { right: calc(-1 * var(--sidebar-w) - 20px); }
    .sidebar.active { right: 0; }
    .main-content { margin-right: 0; padding: 1.25rem; }
}

/* شريط العنوان العلوي (كان bg-white) */
.main-content .bg-white,
.card-header.bg-white,
.card-footer {
    background: rgba(21, 19, 15, 0.85) !important;
    color: var(--text-main);
}
.main-content > .d-flex.bg-white {
    border: 1px solid var(--line);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.main-content > .d-flex.bg-white h5 { color: var(--gold-light); }
.shadow-sm { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-muted b, .text-muted strong { color: var(--gold-light); }
.main-content > h3 { font-weight: 700; color: var(--text-main); }

.btn-light {
    background: var(--gold-soft); color: var(--gold);
    border: 1px solid var(--line-strong);
}
.btn-light:hover, .btn-light:focus { background: var(--gold-grad); color: #0b0a08; border-color: transparent; }

/* ================= Cards ================= */
.card {
    --bs-card-bg: transparent;
    --bs-card-color: var(--text-main);
    --bs-card-border-color: var(--line);
    --bs-card-cap-bg: transparent;
    background: linear-gradient(180deg, #17140f 0%, #120f0b 100%);
    border: 1px solid var(--line) !important;
    border-radius: 18px;
    color: var(--text-main);
    overflow: hidden;
}
.card-header { border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; }
.card-header strong { color: var(--gold-light); font-family: 'Tajawal', sans-serif; font-size: 1.05rem; }
.card-footer { border-top: 1px solid var(--line); }

/* بطاقات الإحصائيات */
.card.bg-primary, .card.bg-success, .card.bg-warning {
    position: relative;
    border: 1px solid var(--line-strong) !important;
    transition: transform .3s ease, box-shadow .3s ease;
}
.card.bg-primary:hover, .card.bg-success:hover, .card.bg-warning:hover { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5) !important; }
.card.bg-primary {
    background: var(--gold-grad) !important;
    color: #0b0a08 !important;
    border-color: transparent !important;
}
.card.bg-success, .card.bg-warning {
    background: linear-gradient(160deg, #1d1912 0%, #120f0b 100%) !important;
    color: var(--text-main) !important;
}
.card.bg-primary .card-body, .card.bg-success .card-body, .card.bg-warning .card-body { padding: 1.4rem 1.5rem; }
.card.bg-primary h2, .card.bg-success h2, .card.bg-warning h2 { font-weight: 800; font-size: 2.2rem; margin-top: .25rem; font-family: 'Tajawal', sans-serif; }
.card.bg-primary .small, .card.bg-success .small, .card.bg-warning .small { font-weight: 700; opacity: .85; }
.card.bg-success h2, .card.bg-warning h2 { color: var(--gold-light); }
.card.bg-success i.fs-1, .card.bg-warning i.fs-1 { color: var(--gold); opacity: .55 !important; }
.card.bg-primary i.fs-1 { opacity: .4 !important; }
.text-dark { color: inherit !important; }

/* ================= Tables ================= */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-main);
    --bs-table-border-color: var(--line);
    --bs-table-hover-bg: rgba(212, 175, 55, 0.06);
    --bs-table-hover-color: var(--text-main);
    --bs-table-striped-bg: rgba(212, 175, 55, 0.03);
    margin-bottom: 0;
}
.table > thead th,
.table-light,
.table-light > tr > th,
.table > thead.table-light th {
    --bs-table-bg: rgba(212, 175, 55, 0.07);
    --bs-table-color: var(--gold-light);
    --bs-table-border-color: var(--line);
    background-color: rgba(212, 175, 55, 0.07) !important;
    color: var(--gold-light) !important;
    font-weight: 700;
    font-size: .88rem;
    white-space: nowrap;
}
.table td, .table th { padding: .85rem .65rem; border-color: var(--line); }
.table td.small { min-width: 120px; line-height: 1.7; }
.table td:has(> .thumb-admin) { width: 110px; }
.table td:has(> .thumb-admin) + td { min-width: 150px; font-weight: 600; line-height: 1.6; }
.table td:has(> .btn) { white-space: nowrap; width: 1%; }
.thumb-admin {
    width: 96px; aspect-ratio: 16/9; height: auto;
    object-fit: cover; border-radius: 10px;
    border: 1px solid var(--line-strong);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* ================= Buttons ================= */
.btn { font-weight: 700; border-radius: 12px; }
.btn-primary {
    --bs-btn-bg: #d4af37; --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: #e2bf4a; --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: #b8932b; --bs-btn-active-border-color: transparent;
    --bs-btn-color: #0b0a08; --bs-btn-hover-color: #0b0a08; --bs-btn-active-color: #0b0a08;
    background: var(--gold-grad);
    color: #0b0a08;
    border: none;
    box-shadow: 0 8px 22px rgba(212, 175, 55, 0.25);
}
.btn-primary:hover, .btn-primary:focus { background: var(--gold-grad); color: #0b0a08; filter: brightness(1.08); }
.btn-outline-primary {
    --bs-btn-color: #d4af37; --bs-btn-border-color: rgba(212, 175, 55, 0.45);
    --bs-btn-hover-bg: #d4af37; --bs-btn-hover-border-color: #d4af37; --bs-btn-hover-color: #0b0a08;
    --bs-btn-active-bg: #b8932b; --bs-btn-active-color: #0b0a08;
}
.btn-outline-secondary {
    --bs-btn-color: #a39a85; --bs-btn-border-color: rgba(212, 175, 55, 0.18);
    --bs-btn-hover-bg: rgba(212, 175, 55, 0.10); --bs-btn-hover-border-color: rgba(212, 175, 55, 0.45); --bs-btn-hover-color: #f3d77e;
    --bs-btn-active-bg: rgba(212, 175, 55, 0.15); --bs-btn-active-color: #f3d77e;
}
.btn-outline-danger {
    --bs-btn-color: #e97a6f; --bs-btn-border-color: rgba(233, 122, 111, 0.4);
    --bs-btn-hover-bg: #c9544a; --bs-btn-hover-border-color: #c9544a; --bs-btn-hover-color: #fff;
}
.badge.bg-danger { background: rgba(233, 122, 111, 0.15) !important; color: #f0a59d; border: 1px solid rgba(233, 122, 111, 0.35); }
.badge.bg-success { background: rgba(212, 175, 55, 0.15) !important; color: var(--gold-light); border: 1px solid var(--line-strong); }

/* ================= Forms ================= */
.form-label { color: var(--gold-light); font-weight: 700; font-size: .92rem; }
.form-control, .form-select {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    color: var(--text-main);
    border-radius: 12px;
    padding: .65rem 1rem;
}
.form-control::placeholder { color: var(--text-muted); opacity: .7; }
.form-control:focus, .form-select:focus {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--gold);
    color: var(--text-main);
    box-shadow: 0 0 0 4px var(--gold-soft);
}
.form-select {
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23d4af37' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.form-select option { background: #15130f; color: var(--text-main); }
.form-control::file-selector-button {
    background: var(--gold-soft);
    color: var(--gold-light);
    border-color: var(--line);
    font-weight: 700;
}
.form-control:hover:not(:disabled):not([readonly])::file-selector-button { background: rgba(212, 175, 55, 0.18); }
.form-check-input { background-color: transparent; border-color: var(--line-strong); }
.form-check-input:checked { background-color: var(--gold); border-color: var(--gold); }

/* تنبيهات */
.alert { border-radius: 14px; border: 1px solid var(--line); }
.alert-success { background: rgba(212, 175, 55, 0.10); color: var(--gold-light); border-color: var(--line-strong); }
.alert-danger { background: rgba(233, 122, 111, 0.10); color: #f0a59d; border-color: rgba(233, 122, 111, 0.35); }

/* ترقيم الصفحات */
.pagination { gap: 6px; }
.pagination .page-link { background: rgba(255,255,255,0.02); border: 1px solid var(--line); color: var(--text-muted); border-radius: 10px !important; }
.pagination .page-link:hover { background: var(--gold-soft); color: var(--gold-light); }
.pagination .active .page-link { background: var(--gold-grad); color: #0b0a08; border-color: transparent; }

/* ================= صفحة الإعدادات ================= */
.form-text { color: var(--text-muted); }
.form-text code, .settings-form code { color: var(--gold-light); background: var(--gold-soft); padding: 1px 6px; border-radius: 6px; }
.form-switch .form-check-input { width: 2.6em; height: 1.35em; cursor: pointer; }
.form-switch .form-check-input:focus { box-shadow: 0 0 0 4px var(--gold-soft); }
.form-check-label { cursor: pointer; }
.links-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.link-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.3fr) 130px auto;
    gap: 8px; align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.015);
    transition: border-color .2s ease;
}
.link-row:hover { border-color: var(--line-strong); }
.link-row .form-control, .link-row .form-select { padding: .5rem .75rem; font-size: .92rem; }
.link-handle { color: var(--gold); font-size: 1.2rem; padding: 0 4px; }
.link-actions { display: flex; gap: 4px; }
.link-actions .btn { padding: .3rem .5rem; }
.settings-savebar {
    position: sticky; bottom: 16px; z-index: 50;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    margin-top: .5rem; padding: .9rem 1.2rem;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: rgba(16, 14, 11, 0.92);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.55);
}
.settings-savebar .btn-primary { margin-inline-start: auto; }
@media (max-width: 767.98px) {
    .link-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .link-handle { display: none; }
    .link-row input[name$="_url[]"] { grid-column: 1 / -1; order: 2; }
    .link-row .form-select { order: 3; }
    .link-row .link-actions { order: 4; justify-content: flex-end; }
}

/* ================= صفحة تسجيل الدخول ================= */
body.login-page { padding: 1rem; }
.login-page .card {
    border: 1px solid var(--line-strong) !important;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 80px rgba(212, 175, 55, 0.08) !important;
}
.login-page .card-body { padding: 2.25rem !important; }
.login-page h4 { color: var(--gold-light); font-weight: 800; }
.login-page a { color: var(--gold); text-decoration: none; }
.login-page a:hover { color: var(--gold-light); }
.login-page .btn-primary { padding: .7rem; font-size: 1.05rem; }

/* مفتاح التبديل في RTL */
.form-switch { padding-right: 3.3em; padding-left: 0; }
.form-switch .form-check-input { margin-right: -3.3em; margin-left: 0; float: right; }

/* إلغاء خلفية الملء التلقائي في المتصفح */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-main);
    -webkit-box-shadow: 0 0 0 1000px #15130f inset;
    caret-color: var(--text-main);
    transition: background-color 9999s ease-out;
}

/* ================= إضافات الإصدار 1.0 ================= */
.sidebar-version { position: absolute; bottom: 18px; right: 0; left: 0; text-align: center; font-size: .75rem; color: var(--text-muted); opacity: .6; }
.stat-icon { width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; border-radius: 14px; font-size: 1.5rem;
    background: var(--gold-soft) !important; color: var(--gold) !important; border: 1px solid var(--line-strong); }
.alert code { background: rgba(0,0,0,.25); padding: 1px 6px; border-radius: 6px; color: inherit; }
.alert-warning { background: rgba(212,175,55,.10); color: var(--gold-light); border-color: var(--line-strong); }
.categories-table form { margin: 0; }
.categories-table .rename-form .form-control { max-width: 320px; }
.badge-count { display: inline-block; padding: 3px 10px; border-radius: 50rem; background: var(--gold-soft); color: var(--gold-light);
    border: 1px solid var(--line-strong); font-size: .78rem; font-weight: 700; text-decoration: none; }
.badge-count:hover { background: var(--gold-grad); color: #0b0a08; }
.form-label a { color: var(--gold); text-decoration: none; }
.form-label a:hover { color: var(--gold-light); }

/* ================= معالج التثبيت ================= */
.install-wrap { max-width: 720px; }
.install-steps { display: flex; gap: 8px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.install-steps span { flex: 1; min-width: 120px; text-align: center; padding: .5rem; border-radius: 12px; border: 1px solid var(--line); color: var(--text-muted); font-size: .85rem; font-weight: 700; }
.install-steps span.on { background: var(--gold-soft); border-color: var(--line-strong); color: var(--gold-light); }
.req-list { list-style: none; padding: 0; margin: 0; }
.req-list li { display: flex; justify-content: space-between; align-items: center; padding: .55rem .2rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
.req-list li:last-child { border-bottom: 0; }
.req-ok { color: #8fd18a; }
.req-bad { color: #f0a59d; }
.install-section-title { color: var(--gold-light); font-weight: 800; font-size: 1rem; margin: 1.25rem 0 .75rem; display: flex; align-items: center; gap: 8px; }
.install-section-title::before { content: ""; width: 4px; height: 1.1em; border-radius: 4px; background: var(--gold-grad); }
.config-box { font-family: monospace; font-size: .8rem; direction: ltr; text-align: left; min-height: 260px; }

/* ================= الفيديو المميّز (1.1) ================= */
.badge-featured { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 6px; padding: 1px 8px; border-radius: 50rem;
    background: var(--gold-grad); color: #0b0a08; font-size: .7rem; font-weight: 800; vertical-align: middle; }
.featured-switch { padding: .8rem 3.6em .8rem 1rem; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--gold-soft); }
.featured-switch .form-check-input { margin-right: -2.6em; }
.featured-switch .form-check-label { color: var(--gold-light); font-weight: 700; }
