/* =========================================================
   لوحة تحكم موقع مدارس الضياء - التنسيقات
   ========================================================= */

@font-face { font-family: RB-bold;  src: url('../../fonts/RB-bold.ttf'); }
@font-face { font-family: RB-light; src: url('../../fonts/RB-light.ttf'); }
@font-face { font-family: Kufi;     src: url('../../fonts/DroidKufi-Bold.ttf'); }

:root {
    --ad-primary: #0093c8;
    --ad-primary-d: #007aa3;
    --ad-accent: #d39b2a;
    --ad-sidenav: #16203c;
    --ad-sidenav-2: #1f2d52;
    --ad-bg: #f1f5f9;
    --ad-card: #ffffff;
    --ad-text: #0f172a;
    --ad-muted: #64748b;
    --ad-line: #e2e8f0;
    --ad-ok: #16a34a;
    --ad-warn: #d97706;
    --ad-err: #dc2626;
    --ad-info: #2563eb;
    --ad-radius: 14px;
    --ad-shadow: 0 1px 3px rgba(15,23,42,.08), 0 8px 24px rgba(15,23,42,.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: RB-light, "Segoe UI", Tahoma, sans-serif;
    background: var(--ad-bg);
    color: var(--ad-text);
    font-size: 15px;
    line-height: 1.7;
}

a { color: var(--ad-primary-d); text-decoration: none; }
a:hover { text-decoration: underline; }

.rb-bold { font-family: RB-bold, sans-serif; }
.kufi { font-family: Kufi, sans-serif; }

/* ---------- الهيكل ---------- */
.ad-wrap { display: flex; min-height: 100vh; }

.ad-side {
    width: 264px; flex: 0 0 264px;
    background: linear-gradient(180deg, var(--ad-sidenav) 0%, var(--ad-sidenav-2) 100%);
    color: #fff; position: fixed; inset-block: 0; inset-inline-end: 0;
    display: flex; flex-direction: column; z-index: 40;
}
.ad-side-head { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; gap: 12px; }
.ad-side-head img { height: 42px; }
.ad-side-head .t { font-family: RB-bold, sans-serif; font-size: 16px; line-height: 1.3; }
.ad-side-head .s { font-size: 11px; opacity: .65; }

.ad-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.ad-nav .grp { font-size: 11px; opacity: .5; padding: 14px 12px 6px; letter-spacing: .5px; }
.ad-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px; color: #dbe4f0;
    font-size: 14.5px; margin-bottom: 2px; transition: background .18s, color .18s;
}
.ad-nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.ad-nav a.on { background: var(--ad-primary); color: #fff; font-family: RB-bold, sans-serif; }
.ad-nav a .ic { width: 20px; text-align: center; font-size: 16px; flex: 0 0 20px; }
.ad-nav a .badge {
    margin-inline-start: auto; background: var(--ad-err); color: #fff;
    font-size: 11px; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
}

.ad-main { flex: 1; margin-inline-end: 264px; min-width: 0; display: flex; flex-direction: column; }

.ad-top {
    background: #fff; border-bottom: 1px solid var(--ad-line);
    padding: 14px 26px; display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 30;
}
.ad-top h1 { font-size: 19px; margin: 0; font-family: RB-bold, sans-serif; }
.ad-top .sp { flex: 1; }
.ad-top .who { font-size: 13px; color: var(--ad-muted); }
.ad-top .who b { color: var(--ad-text); }

.ad-body { padding: 24px 26px 60px; flex: 1; }

.ad-burger { display: none; background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--ad-text); }

/* ---------- البطاقات ---------- */
.card {
    background: var(--ad-card); border: 1px solid var(--ad-line);
    border-radius: var(--ad-radius); box-shadow: var(--ad-shadow); margin-bottom: 18px;
}
.card > .hd {
    padding: 15px 20px; border-bottom: 1px solid var(--ad-line);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card > .hd h2 { margin: 0; font-size: 16px; font-family: RB-bold, sans-serif; }
.card > .hd .sp { flex: 1; }
.card > .bd { padding: 20px; }
.card > .bd.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-side { grid-template-columns: 300px minmax(0,1fr); align-items: start; }

/* ---------- إحصاءات ---------- */
.stat {
    background: #fff; border: 1px solid var(--ad-line); border-radius: var(--ad-radius);
    padding: 18px 20px; box-shadow: var(--ad-shadow); position: relative; overflow: hidden;
}
.stat::after { content:""; position:absolute; inset-block:0; inset-inline-start:0; width:5px; background: var(--ad-primary); }
.stat.s2::after { background: var(--ad-accent); }
.stat.s3::after { background: var(--ad-ok); }
.stat.s4::after { background: var(--ad-err); }
.stat .n { font-size: 30px; font-family: RB-bold, sans-serif; line-height: 1.2; }
.stat .t { font-size: 13.5px; color: var(--ad-muted); }

/* ---------- الحقول ---------- */
.fld { margin-bottom: 16px; }
.fld > label { display: block; font-size: 13.5px; margin-bottom: 6px; }
.fld > label .hint { color: var(--ad-muted); font-weight: normal; font-size: 12px; }

.inp, textarea.inp, select.inp {
    width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 9px;
    font-family: inherit; font-size: 14.5px; background: #fff; color: var(--ad-text);
    transition: border-color .15s, box-shadow .15s;
}
.inp:focus, textarea.inp:focus, select.inp:focus {
    outline: 0; border-color: var(--ad-primary); box-shadow: 0 0 0 3px rgba(0,147,200,.16);
}
textarea.inp { min-height: 110px; resize: vertical; line-height: 1.85; }
textarea.inp.tall { min-height: 220px; }
.inp[readonly] { background: #f8fafc; color: var(--ad-muted); }

/* حقل اللون */
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=color] {
    width: 46px; height: 38px; padding: 2px; border: 1px solid #cbd5e1;
    border-radius: 9px; background: #fff; cursor: pointer; flex: 0 0 46px;
}
.color-row .inp { direction: ltr; text-align: left; font-family: Consolas, monospace; }
.color-row .reset { border: 0; background: none; cursor: pointer; color: var(--ad-muted); font-size: 17px; padding: 4px; }
.color-row .reset:hover { color: var(--ad-primary); }

/* مفتاح تشغيل */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .sw {
    width: 42px; height: 23px; border-radius: 999px; background: #cbd5e1;
    position: relative; transition: background .2s; flex: 0 0 42px;
}
.toggle .sw::after {
    content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
    width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.toggle input:checked + .sw { background: var(--ad-ok); }
.toggle input:checked + .sw::after { transform: translateX(-19px); }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px;
    border: 1px solid transparent; border-radius: 9px; cursor: pointer;
    font-family: RB-bold, sans-serif; font-size: 14.5px; background: var(--ad-primary);
    color: #fff; transition: background .18s, transform .1s;
}
.btn:hover { background: var(--ad-primary-d); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.sec { background: #fff; color: var(--ad-text); border-color: #cbd5e1; }
.btn.sec:hover { background: #f8fafc; color: var(--ad-text); }
.btn.ok { background: var(--ad-ok); }
.btn.ok:hover { background: #15803d; }
.btn.danger { background: var(--ad-err); }
.btn.danger:hover { background: #b91c1c; }
.btn.warn { background: var(--ad-warn); }
.btn.warn:hover { background: #b45309; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.xs { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-bar {
    position: sticky; bottom: 0; background: #fff; border: 1px solid var(--ad-line);
    border-radius: 12px; padding: 12px 18px; display: flex; gap: 10px;
    align-items: center; box-shadow: 0 -4px 20px rgba(15,23,42,.08); margin-top: 20px; z-index: 20;
}
.btn-bar .sp { flex: 1; }

/* ---------- التنبيهات ---------- */
.alert {
    padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
    border: 1px solid; display: flex; gap: 10px; align-items: flex-start; font-size: 14px;
}
.alert.ok   { background: #e9f9ef; border-color: #a7e3bd; color: #14532d; }
.alert.err  { background: #fdecec; border-color: #f3c0c0; color: #7f1d1d; }
.alert.warn { background: #fff7e6; border-color: #f5d99a; color: #78350f; }
.alert.info { background: #eaf2fe; border-color: #bcd4fb; color: #1e3a8a; }
.alert .x { margin-inline-start: auto; cursor: pointer; opacity: .5; }

/* ---------- الجداول ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
    text-align: right; padding: 11px 14px; background: #f8fafc; color: var(--ad-muted);
    font-weight: normal; font-size: 12.5px; border-bottom: 1px solid var(--ad-line); white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.tbl tr:hover td { background: #fafcfe; }
table.tbl td.num { width: 46px; color: var(--ad-muted); text-align: center; }

/* ---------- التبويبات ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ad-line); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
    padding: 10px 16px; border: 0; background: none; cursor: pointer; font-size: 14.5px;
    color: var(--ad-muted); border-bottom: 2px solid transparent; white-space: nowrap;
    font-family: inherit; transition: color .15s;
}
.tabs button:hover { color: var(--ad-text); }
.tabs button.on { color: var(--ad-primary); border-bottom-color: var(--ad-primary); font-family: RB-bold, sans-serif; }

/* ---------- اختيار الصفحة ( breadcrumbs ) ---------- */
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ad-muted); flex-wrap: wrap; }
.crumbs .sep { opacity: .45; }
.crumbs .code { font-family: Consolas, monospace; background: #f1f5f9; padding: 2px 7px; border-radius: 5px; color: #475569; direction: ltr; display: inline-block; }

.sec-list { display: flex; flex-direction: column; gap: 6px; }
.sec-list a {
    display: flex; align-items: center; gap: 9px; padding: 11px 14px;
    border: 1px solid var(--ad-line); border-radius: 10px; background: #fff; color: var(--ad-text); font-size: 14px;
}
.sec-list a:hover { border-color: var(--ad-primary); text-decoration: none; }
.sec-list a.on { background: var(--ad-primary); color: #fff; border-color: var(--ad-primary); }
.sec-list a.on .d { color: rgba(255,255,255,.8); }
.sec-list a .d { font-size: 11.5px; color: var(--ad-muted); }
.sec-list a .ic { font-size: 17px; }

/* ---------- الصور ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.img-cell {
    border: 1px solid var(--ad-line); border-radius: 11px; overflow: hidden; background: #fff; position: relative;
}
.img-cell .thumb {
    height: 110px; background: #f1f5f9 center/cover no-repeat; display: flex;
    align-items: center; justify-content: center; cursor: pointer;
}
.img-cell .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-cell .meta { padding: 7px 9px; font-size: 11px; color: var(--ad-muted); border-top: 1px solid var(--ad-line); }
.img-cell .ops {
    position: absolute; top: 6px; inset-inline-end: 6px; display: flex; gap: 4px;
    opacity: 0; transition: opacity .18s;
}
.img-cell:hover .ops { opacity: 1; }
.img-cell .ops button {
    width: 27px; height: 27px; border-radius: 7px; border: 0; cursor: pointer;
    background: rgba(255,255,255,.94); color: #475569; font-size: 14px; line-height: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.img-cell .ops button:hover { background: var(--ad-primary); color: #fff; }
.img-cell .ops button.del:hover { background: var(--ad-err); }
.img-cell.off { opacity: .45; }
.img-cell.off::after {
    content: "مخفي"; position: absolute; top: 8px; inset-inline-start: 8px;
    background: var(--ad-err); color: #fff; font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
}

.drop-zone {
    border: 2px dashed #cbd5e1; border-radius: 12px; padding: 28px; text-align: center;
    cursor: pointer; transition: border-color .2s, background .2s; background: #fafcfe;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--ad-primary); background: #f0f9fd; }
.drop-zone .big { font-size: 34px; }

/* ---------- معاينة الموقع داخل اللوحة ---------- */
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--ad-line); border-radius: 12px; overflow: hidden; background: #fff; }
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- صفحة الدخول ---------- */
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: linear-gradient(135deg, #16203c 0%, #1f3a63 55%, #0093c8 100%);
}
.login-box {
    width: 100%; max-width: 420px; background: #fff; border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0,0,0,.35); overflow: hidden;
}
.login-box .top { padding: 30px 30px 22px; text-align: center; background: #fff; }
.login-box .top img { height: 62px; margin-bottom: 12px; }
.login-box .top h1 { font-size: 20px; margin: 0 0 5px; font-family: RB-bold, sans-serif; }
.login-box .top p { margin: 0; font-size: 13px; color: var(--ad-muted); }
.login-box .bd { padding: 0 30px 30px; }
.pw-meter { height: 5px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-top: 7px; }
.pw-meter i { display: block; height: 100%; width: 0; transition: width .25s, background .25s; }

/* ---------- متفرقات ---------- */
.muted { color: var(--ad-muted); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, monospace; direction: ltr; }
.nowrap { white-space: nowrap; }
.mb0 { margin-bottom: 0 !important; }
.mt0 { margin-top: 0 !important; }
.hr { height: 1px; background: var(--ad-line); margin: 18px 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; }
.pill.new  { background: #fde8e8; color: #a11; }
.pill.err  { background: #fde8e8; color: #a11; }
.edit-row td { background: #fafbfc; border-top: 0; }
.edit-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.tbl-scroll { overflow-x: auto; }
.create-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; align-items: end; }
.create-form .btn { grid-column: 1 / -1; }
.pill.read { background: #e0f2fe; color: #075985; }
.pill.done { background: #e7f7ec; color: #14532d; }

.empty { text-align: center; padding: 40px 20px; color: var(--ad-muted); }
.empty .big { font-size: 44px; margin-bottom: 10px; }

/* ---------- شريط الحفظ العائم للمحتوى ---------- */
.changed-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ad-warn); }

/* ---------- فوتر اللوحة ---------- */
.ad-foot {
    margin-top: auto; padding: 16px 26px 20px;
    border-top: 1px solid var(--ad-line);
    text-align: center;
}
.ad-foot p { margin: 0; font-size: 13px; color: var(--ad-muted); }
.ad-foot .l2 { margin-top: 2px; }
.ad-foot .sig {
    font-family: RB-bold, sans-serif; color: var(--ad-text);
    direction: ltr; unicode-bidi: isolate; display: inline-block;
}

/* ---------- استجابة الشاشات ---------- */
@media (max-width: 1100px) {
    .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .g3, .g-side { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .ad-side {
        transform: translateX(100%); transition: transform .25s; box-shadow: -6px 0 30px rgba(0,0,0,.3);
    }
    body.nav-open .ad-side { transform: translateX(0); }
    .ad-main { margin-inline-end: 0; }
    .ad-burger { display: block; }
    .ad-body { padding: 16px; }
    .ad-foot { padding: 14px 16px 18px; }
    .g2, .g3, .g4 { grid-template-columns: 1fr; }
    .ad-side-head { padding: 16px; }
}