/* =================================================================
   دار الإتقان لتعليم القرآن - التنسيق العام (RTL)
   Layout & components. No colour literals here: everything comes
   from theme.css.
   ================================================================= */

/* ---------------- الخط الرسمي (ITF Asal Arabic) ----------------
   الخطوط محلية داخل assets/font ولا تحتاج اتصالًا بالإنترنت.
   Self-hosted, so the site keeps its identity with no CDN call.
   ملاحظة: أسماء الملفات حساسة لحالة الأحرف على خوادم لينكس.
   ---------------------------------------------------------------- */

@font-face {
  font-family: "Asal";
  src: url("font/itfAsalArabic-light.otf") format("opentype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Asal";
  src: url("font/itfAsalArabic-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Asal";
  src: url("font/itfAsalArabic-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Asal";
  src: url("font/itfAsalArabic-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Asal";
  src: url("font/itfAsalArabic-ExtraBold.otf") format("opentype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Asal";
  src: url("font/itfAsalArabic-Black.otf") format("opentype");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--green-light) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-tint) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); text-decoration: underline; }

h1, h2, h3 { line-height: 1.35; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 22px;
}

/* ---------------- الترويسة ---------------- */

.site-header {
  background: var(--grad-header);
  color: var(--text-invert);
  border-bottom: 4px solid var(--yellow);
  box-shadow: var(--shadow-header);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 88px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-invert);
  margin-inline-end: auto;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--text-invert); }

.brand-logo {
  height: 62px;
  width: auto;
  background: var(--surface);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-logo);
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 800; font-size: 20px; }
.brand-tag  { font-size: 13px; opacity: .85; }

.site-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.nav-link {
  color: var(--text-invert);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.nav-link:hover { background: var(--nav-hover); color: var(--text-invert); text-decoration: none; }
.nav-link.is-active { background: var(--nav-hover); border-color: var(--nav-border); }
.nav-link.solid {
  background: var(--grad-gold);
  color: var(--brown-dark);
  box-shadow: var(--shadow-logo);
}
.nav-link.solid:hover { filter: brightness(1.06); color: var(--brown-dark); }

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  opacity: .9;
  padding-inline-start: 8px;
}
.who .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--grad-gold);
  color: var(--brown-dark);
  display: grid; place-items: center;
  font-weight: 800;
  flex: none;
}

/* ---------------- هيكل الصفحة ---------------- */

.page { padding: 34px 0 70px; flex: 1 0 auto; }

.page-head { margin-bottom: 26px; }
.page-title {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 800;
  color: var(--brown-dark);
}
.page-title .accent {
  display: inline-block;
  width: 46px; height: 5px;
  background: var(--grad-gold);
  border-radius: var(--radius-pill);
  vertical-align: middle;
  margin-inline-start: 10px;
}
.page-sub { margin: 0; color: var(--text-soft); font-size: 16px; }

.section-title {
  font-size: 21px;
  font-weight: 800;
  color: var(--brown-dark);
  margin: 34px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: "";
  width: 6px; height: 22px;
  background: var(--grad-gold);
  border-radius: var(--radius-pill);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------------- الواجهة الترحيبية ---------------- */

.hero {
  background: var(--grad-hero);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  margin-bottom: 26px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset-inline-start: -60px;
  top: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: var(--yellow-light);
  opacity: .55;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { margin: 0 0 8px; font-size: 32px; font-weight: 800; color: var(--brown-dark); }
.hero p  { margin: 0; color: var(--text-soft); max-width: 62ch; }

/* ---------------- شريط الأدوات ---------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}
.field.grow { flex: 1 1 240px; }
.field small { color: var(--text-soft); font-size: 12px; }

input[type=text], input[type=search], input[type=date],
input[type=url], input[type=password], input[type=file],
select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  min-width: 0;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--green); }
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-light);
  outline: none;
}
textarea { resize: vertical; min-height: 110px; }
input::placeholder, textarea::placeholder { color: var(--text-soft); opacity: .8; }

.btn {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  border: 1.5px solid var(--green-dark);
  background: var(--green);
  color: var(--text-invert);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  box-shadow: var(--shadow);
}
.btn:hover {
  background: var(--green-dark);
  color: var(--text-invert);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}
.btn:active { transform: translateY(0); }

.btn.accent {
  background: var(--grad-gold);
  border-color: var(--yellow-dark);
  color: var(--brown-dark);
}
.btn.accent:hover { filter: brightness(1.06); color: var(--brown-dark); }

.btn.ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--brown);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--surface-alt); color: var(--brown-dark); }

.btn.danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: none;
}
.btn.danger:hover { background: var(--danger); color: var(--text-invert); }

.btn.sm { padding: 7px 14px; font-size: 14px; }
.btn.block { width: 100%; justify-content: center; }

/* ---------------- المجموعات ---------------- */

.group { margin-bottom: 34px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  background: var(--green-light);
  border: 1px solid var(--border);
  border-inline-start: 6px solid var(--green);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.group-head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--brown-dark); }
.group-count {
  margin-inline-start: auto;
  background: var(--grad-gold);
  color: var(--brown-dark);
  font-weight: 800;
  font-size: 13px;
  padding: 3px 14px;
  border-radius: var(--radius-pill);
}

/* ---------------- البطاقات ---------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--yellow);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .18s ease, transform .18s ease;
}
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-3px); }

.card.is-done   { border-top-color: var(--green); }
.card.is-high   { border-top-color: var(--pri-high); }
.card.is-hidden { opacity: .75; border-style: dashed; }

.card h3 { margin: 0; font-size: 18px; font-weight: 700; color: var(--brown-dark); }

.card-meta { display: flex; flex-wrap: wrap; gap: 7px; }

.card-details {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  white-space: pre-wrap;
}

.card-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-soft);
}

.card-thumb {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

/* ---------------- الشارات ---------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 13px;
  background: var(--surface-alt);
  color: var(--brown);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.chip.team   { background: var(--green-light);  color: var(--green-dark); }
.chip.person { background: var(--brown-light);  color: var(--brown-dark); }
.chip.type   { background: var(--yellow-light); color: var(--brown-dark); }

.chip.st-todo        { background: var(--st-todo-bg);        color: var(--st-todo); }
.chip.st-in_progress { background: var(--st-in_progress-bg); color: var(--st-in_progress); }
.chip.st-review      { background: var(--st-review-bg);      color: var(--st-review); }
.chip.st-done        { background: var(--st-done-bg);        color: var(--st-done); }

.chip.pri-high   { background: var(--pri-high-bg);   color: var(--pri-high); }
.chip.pri-normal { background: var(--pri-normal-bg); color: var(--pri-normal); }
.chip.pri-low    { background: var(--pri-low-bg);    color: var(--pri-low); }

.chip.due-soon { background: var(--warn-bg);   color: var(--warn); }
.chip.overdue  { background: var(--danger-bg); color: var(--danger); }
.chip.role-admin  { background: var(--green-light); color: var(--green-dark); }
.chip.role-editor { background: var(--yellow-light); color: var(--brown-dark); }
.chip.off { background: var(--surface-alt); color: var(--text-soft); }

/* ---------------- الإحصائيات ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 5px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.stat:hover { transform: translateY(-2px); }
.stat b { display: block; font-size: 28px; font-weight: 800; color: var(--brown-dark); line-height: 1.2; }
.stat span { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.stat.total { border-inline-start-color: var(--green); }

/* ---------------- الرسائل ---------------- */

.msg {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-weight: 700;
  border: 1px solid transparent;
  border-inline-start-width: 5px;
}
.msg.ok     { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok); }
.msg.warn   { background: var(--warn-bg);   color: var(--warn);   border-color: var(--warn); }
.msg.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-soft);
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty strong { display: block; font-size: 19px; color: var(--brown-dark); margin-bottom: 6px; }

.skeleton {
  height: 150px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-alt), var(--surface), var(--surface-alt));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------------- الجداول ---------------- */

.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: middle;
}
.table th {
  background: var(--green-dark);
  color: var(--text-invert);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.table tbody tr:nth-child(even) { background: var(--surface-alt); }
.table tbody tr:hover { background: var(--green-light); }
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- تغيير الحالة من الجدول ---------------- */

.status-form { display: flex; gap: 6px; align-items: center; }

.status-select {
  width: auto;
  min-width: 130px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  border: 1.5px solid currentColor;
  cursor: pointer;
}
.status-select.st-todo        { background: var(--st-todo-bg);        color: var(--st-todo); }
.status-select.st-in_progress { background: var(--st-in_progress-bg); color: var(--st-in_progress); }
.status-select.st-review      { background: var(--st-review-bg);      color: var(--st-review); }
.status-select.st-done        { background: var(--st-done-bg);        color: var(--st-done); }
.status-select option { background: var(--surface); color: var(--text); font-weight: 500; }

.chip.person.me {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

/* ---------------- النماذج ---------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--brown-dark);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--green); flex: none; }

/* ---------------- تسجيل الدخول ---------------- */

.login-page { display: grid; place-items: center; padding: 40px 0; }
.login-box { width: 100%; max-width: 430px; }
.login-logo {
  display: block;
  max-width: 260px;
  height: auto;
  margin: 0 auto 22px;
}
.login-box .panel { border-top: 5px solid var(--yellow); }

/* ---------------- المرفقات على البطاقة ---------------- */

.card-media {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  display: block;
}
.card-media.audio { height: 44px; max-height: none; object-fit: fill; }

.file-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--brown-dark);
  text-decoration: none;
  margin-top: 12px;
}
.file-box:hover { background: var(--yellow-light); text-decoration: none; color: var(--brown-dark); }
.file-box small { color: var(--text-soft); }
.file-icon { font-size: 24px; flex: none; }

.thumb-wrap { position: relative; display: block; }
.thumb-badge {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  background: var(--overlay);
  color: var(--text-invert);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

/* ---------------- النافذة الموسّعة ---------------- */

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(720px, 94vw);
  max-height: 90vh;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lift);
  border-top: 5px solid var(--yellow);
  overflow: auto;
}
.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }

.modal-close-row { position: sticky; top: 0; display: flex; justify-content: flex-start; }
.modal-close {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 30px;
  line-height: 1;
  padding: 10px 16px;
  cursor: pointer;
}
.modal-close:hover { color: var(--danger); }

.modal-body { padding: 4px 26px 26px; display: flex; flex-direction: column; gap: 14px; }
.modal-title { margin: 0; font-size: 24px; font-weight: 800; color: var(--brown-dark); }
.modal-details { margin: 0; white-space: pre-wrap; color: var(--text); }

.modal-media {
  width: 100%;
  max-height: 60vh;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  display: block;
}
.modal-media.audio { height: 48px; max-height: none; }

.modal-facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}
.modal-facts dt { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.modal-facts dd { margin: 2px 0 0; font-weight: 700; color: var(--brown-dark); }

.modal-status { align-items: center; gap: 10px; }
.modal-status label { font-size: 13px; font-weight: 700; color: var(--text-soft); }

.card-expand {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--green);
  cursor: pointer;
  text-align: start;
}
.card-expand:hover { color: var(--green-dark); text-decoration: underline; }

/* ---------------- التذييل ---------------- */

.site-footer {
  background: var(--brown-dark);
  color: var(--brown-light);
  padding: 28px 0;
  font-size: 14px;
  border-top: 4px solid var(--yellow);
  flex-shrink: 0;
}
.footer-inner { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.footer-inner .sep { margin-inline: auto; }
.site-footer a { color: var(--yellow); }

/* ---------------- الاستجابة للشاشات ---------------- */

@media (max-width: 860px) {
  .header-inner { min-height: 0; padding: 14px 0; }
  .brand-logo { height: 48px; }
  .brand-name { font-size: 17px; }
  .hero h1 { font-size: 25px; }
  .page-title { font-size: 24px; }
}

@media (max-width: 560px) {
  .site-nav { width: 100%; }
  .nav-link { flex: 1 1 auto; text-align: center; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .brand-text { display: none; }
}

@media print {
  .site-header, .site-footer, .toolbar, .row-actions { display: none; }
  .card { break-inside: avoid; box-shadow: none; }
}
