/* ============ الواجهة العامة — معهد طرابلس للعلوم الطبية ============
   ألوان مأخوذة من الشعار: أخضر طبي عميق + ذهبي الختم + أحمر الهلال (للعاجل فقط) */
:root {
  --green-900: #0C2723;
  --green: #12352F;
  --green-700: #1E4B43;
  --gold: #B8902B;
  --gold-600: #9C7820;
  --gold-100: #F3EAD2;
  --red: #D4421F;
  --paper: #F5F8F6;
  --white: #FFFFFF;
  --ink: #18231F;
  --muted: #56665F;
  --line: #DAE3DE;
  --radius: 10px;
  --wrap: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.8 'Tajawal', Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--green-700); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--gold-600); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; color: var(--green); }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.wrap { width: min(100% - 32px, var(--wrap)); margin-inline: auto; }
.narrow { max-width: 780px; }
.muted { color: var(--muted); }
.skip { position: absolute; right: -999px; top: 8px; background: var(--gold); color: var(--green-900); padding: 8px 14px; z-index: 100; }
.skip:focus { right: 8px; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 2px solid transparent;
  padding: 11px 22px; border-radius: 999px; font: 700 1rem 'Tajawal', sans-serif;
  text-decoration: none; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s;
}
.btn-gold { background: var(--gold); color: var(--green-900); }
.btn-gold:hover { background: #CBA23A; color: var(--green-900); }
.btn-ghost { border-color: rgba(255,255,255,.45); color: #fff; }
.btn-ghost:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,.06); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-700); color: #fff; }
.btn-ghost-dark { border-color: var(--line); color: var(--green); background: #fff; }
.btn-ghost-dark:hover { border-color: var(--green); color: var(--green); }

/* ---------- الشريط العاجل ---------- */
.urgent { background: var(--red); color: #fff; font-size: .95rem; }
.urgent-in { display: flex; gap: 14px; align-items: center; padding: 8px 0; }
.urgent-tag { font-weight: 700; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.urgent-items { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.urgent-items a { color: #fff; text-decoration: none; }
.urgent-items a:hover { text-decoration: underline; }

/* ---------- الترويسة ---------- */
.site-header { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-in { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--green); font-weight: 700; font-size: 1.05rem; line-height: 1.35; max-width: 340px; text-wrap: balance; }
.brand img { width: 52px; height: 52px; flex-shrink: 0; }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a { color: var(--ink); text-decoration: none; padding: 8px 12px; font-weight: 500; font-size: .98rem; border-radius: 6px; white-space: nowrap; }
.site-nav a:hover { color: var(--green); background: var(--paper); }
.site-nav a[aria-current="page"] { color: var(--green); box-shadow: inset 0 -3px 0 var(--gold); border-radius: 0; }
.site-nav .btn-login { background: var(--green); color: #fff; border-radius: 999px; padding: 9px 18px; margin-inline-start: 8px; font-weight: 700; }
.site-nav .btn-login:hover { background: var(--green-700); color: #fff; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 1.6rem; line-height: 1; padding: 6px 10px; color: var(--green); cursor: pointer; }

/* ---------- البطل: الختم ---------- */
.hero {
  background:
    radial-gradient(900px 500px at 15% 40%, rgba(184,144,43,.16), transparent 60%),
    var(--green);
  color: #fff; padding: 72px 0 128px; overflow: hidden;
}
.hero-in { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.hero-place { color: var(--gold); font-weight: 700; margin-bottom: 14px; font-size: 1rem; }
.hero h1 { color: #fff; font-size: clamp(2.1rem, 4.4vw, 3.5rem); font-weight: 700; line-height: 1.25; margin-bottom: 20px; max-width: 16ch; }
.hero-lead { font-size: 1.15rem; color: rgba(255,255,255,.82); max-width: 52ch; margin-bottom: 30px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.seal { position: relative; width: min(100%, 440px); aspect-ratio: 1; margin-inline: auto; }
.seal img { position: absolute; }
.seal-ring { inset: 0; width: 100%; height: 100%; animation: seal-in 1.4s cubic-bezier(.2,.7,.2,1) both; filter: drop-shadow(0 18px 40px rgba(0,0,0,.28)); }
.seal-logo { inset: 15%; width: 70%; height: 70%; object-fit: contain; animation: fade 1s .5s both; }
.seal-photo { inset: 12.5%; width: 75%; height: 75%; object-fit: cover; border-radius: 50%; animation: fade 1s .5s both; }
.seal-badge { width: 24%; height: 24%; bottom: 2%; left: 50%; transform: translateX(-50%); background: #fff; border-radius: 50%; padding: 4px; box-shadow: 0 6px 18px rgba(0,0,0,.25); animation: fade 1s .8s both; }
@keyframes seal-in { from { transform: rotate(-35deg) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- الاستعلام عن النتيجة ---------- */
.results-band { margin-top: -72px; position: relative; z-index: 2; }
.results-card {
  background: var(--white); border-radius: 14px; padding: 26px 30px;
  box-shadow: 0 20px 50px -20px rgba(12,39,35,.35); border-top: 4px solid var(--gold);
  display: grid; grid-template-columns: 1fr 1.6fr; gap: 28px; align-items: center;
}
.results-card.solo { grid-template-columns: 1fr; }
.results-intro h2 { font-size: 1.45rem; margin-bottom: 4px; }
.results-intro p { margin: 0; color: var(--muted); font-size: .98rem; }
.result-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.result-form label span { display: block; font-size: .9rem; font-weight: 700; color: var(--green); margin-bottom: 4px; }
.result-form input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 8px;
  font: 500 1.05rem 'Tajawal', sans-serif; background: var(--paper); color: var(--ink);
}
.result-form input:focus { border-color: var(--gold); background: #fff; outline: none; box-shadow: 0 0 0 3px var(--gold-100); }
.result-form button {
  background: var(--green); color: #fff; border: 0; border-radius: 8px; padding: 13px 22px;
  font: 700 1.02rem 'Tajawal', sans-serif; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap;
}
.result-form button:hover { background: var(--green-700); }

/* ---------- الأقسام العامة ---------- */
.section { padding: 88px 0; }
.h-section { font-size: clamp(1.6rem, 2.6vw, 2.05rem); font-weight: 700; margin-bottom: 26px; position: relative; padding-bottom: 14px; }
.h-section::after { content: ""; position: absolute; right: 0; bottom: 0; width: 44px; height: 3px; background: var(--gold); border-radius: 2px; }
.h-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.h-row > a { font-weight: 700; font-size: .95rem; white-space: nowrap; }
.page-title { font-size: clamp(1.8rem, 3.4vw, 2.6rem); margin-bottom: 18px; }

/* عن المعهد */
.about { padding-top: 96px; }
.about-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 64px; align-items: start; }
.about-text { font-size: 1.13rem; max-width: 62ch; }
.vm { display: grid; gap: 26px; padding-top: 8px; }
.vm-item { border-right: 3px solid var(--gold); padding: 4px 22px 4px 0; }
.vm-item h3 { font-size: 1.15rem; margin-bottom: 6px; }
.vm-item p { margin: 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin: 34px 0 0; border-top: 1px solid var(--line); }
.stats > div { padding: 18px 0 0; }
.stats > div + div { border-right: 1px solid var(--line); padding-right: 20px; }
.stats dt { color: var(--muted); font-size: .92rem; order: 2; }
.stats dd { margin: 0; font-size: 2rem; font-weight: 700; color: var(--green); line-height: 1.2; }
.stats > div { display: flex; flex-direction: column-reverse; }

/* الأقسام العلمية */
.programs { background: var(--white); border-block: 1px solid var(--line); }
.program-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 40px; }
.program-list li { padding: 22px 0; border-top: 1px solid var(--line); }
.program-list h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.program-list h3::before {
  content: ""; width: 14px; height: 14px; flex-shrink: 0;
  background: linear-gradient(var(--gold), var(--gold)) center/14px 4px no-repeat,
              linear-gradient(var(--gold), var(--gold)) center/4px 14px no-repeat;
}
.program-list p { margin: 0; color: var(--muted); font-size: .98rem; padding-right: 24px; }

/* التسجيل */
.admission { background: var(--green-900); color: #fff; padding: 52px 0; }
.admission-in { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.admission h2 { color: var(--gold); font-size: 1.5rem; margin-bottom: 6px; }
.admission p { margin: 0; color: rgba(255,255,255,.85); max-width: 70ch; }

/* الأخبار والإعلانات */
.news-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 56px; }
.lead-post { display: grid; gap: 18px; margin-bottom: 18px; }
.lead-img { display: block; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; background: var(--line); }
.lead-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.lead-img:hover img { transform: scale(1.03); }
.lead-post time, .post-list time, .post time, .pi-meta time { color: var(--gold-600); font-size: .9rem; font-weight: 700; }
.lead-post h3 { font-size: 1.5rem; margin: 4px 0 8px; }
.lead-post h3 a { color: var(--green); text-decoration: none; }
.lead-post h3 a:hover { color: var(--gold-600); }
.lead-post p { color: var(--muted); margin: 0; }
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { padding: 14px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.post-list a { color: var(--ink); text-decoration: none; font-weight: 500; font-size: 1.05rem; }
.post-list a:hover { color: var(--green-700); text-decoration: underline; }

.ad-list { list-style: none; margin: 0; padding: 0; }
.ad-list li { display: grid; grid-template-columns: 62px 1fr; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.ad-list time { text-align: center; background: var(--gold-100); color: var(--gold-600); border-radius: 8px; padding: 6px 4px; font-size: .82rem; line-height: 1.3; font-weight: 700; }
.ad-list time b { display: block; font-size: 1.45rem; color: var(--green); }
.ad-list a { color: var(--ink); text-decoration: none; font-weight: 500; }
.ad-list a:hover { color: var(--green-700); text-decoration: underline; }
.ad-list li.is-urgent time { background: #FBE3DC; }
.ad-list li.is-urgent time b { color: var(--red); }
.tag-urgent { display: inline-block; background: var(--red); color: #fff; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; vertical-align: middle; }

/* المعرض */
.gallery-sec { background: var(--white); border-top: 1px solid var(--line); }
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 190px; grid-auto-flow: dense; gap: 10px; }
.gallery .g-item:first-child { grid-column: span 2; grid-row: span 2; }
.g-item { position: relative; border-radius: 8px; overflow: hidden; background: var(--line); display: block; }
.g-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.g-item:hover img { transform: scale(1.04); }
.gallery-full .g-item:first-child { grid-column: auto; grid-row: auto; }
.gallery-full { grid-auto-rows: 220px; }
.g-cap { position: absolute; inset: auto 0 0 0; padding: 22px 12px 8px; color: #fff; font-size: .9rem; background: linear-gradient(transparent, rgba(12,39,35,.85)); }

/* التواصل */
.contact-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 48px; }
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 22px 32px; }
.contact-list li { display: flex; gap: 14px; align-items: flex-start; }
.contact-list i { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: var(--gold); font-size: 1.1rem; }
.contact-list span { display: block; color: var(--muted); font-size: .88rem; }
.contact-list div { font-weight: 500; }

/* التذييل */
.site-footer { background: var(--green-900); color: rgba(255,255,255,.78); padding: 56px 0 0; font-size: .95rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 40px; padding-bottom: 36px; }
.f-brand { display: flex; gap: 14px; align-items: center; }
.f-brand img { width: 72px; height: 72px; background: #fff; border-radius: 50%; padding: 3px; }
.f-brand strong { display: block; color: #fff; font-size: 1.08rem; }
.f-brand span { font-size: .85rem; opacity: .7; }
.site-footer h3 { color: var(--gold); font-size: 1rem; margin-bottom: 12px; }
.site-footer a, .site-footer span { display: block; color: rgba(255,255,255,.78); text-decoration: none; margin-bottom: 6px; }
.site-footer a:hover { color: #fff; }
.site-footer .f-brand span { display: block; }
.f-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-top: 1px solid rgba(255,255,255,.12); padding: 16px 0; font-size: .85rem; }
.f-bottom span { margin: 0; }

/* صفحة الأخبار */
.tabs { display: flex; gap: 6px; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 700; margin-bottom: -1px; border-bottom: 3px solid transparent; }
.tabs a[aria-current="page"] { color: var(--green); border-bottom-color: var(--gold); }
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; align-items: start; }
.post-item { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.pi-img { display: block; aspect-ratio: 16 / 10; background: var(--line); }
.pi-img img { width: 100%; height: 100%; object-fit: cover; }
.pi-body { padding: 18px 20px 20px; }
.pi-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.pi-type { font-size: .78rem; font-weight: 700; color: var(--green); background: #E3EEEA; padding: 1px 10px; border-radius: 999px; }
.pi-type.is-ad { background: var(--gold-100); color: var(--gold-600); }
.post-item h2 { font-size: 1.18rem; margin: 0 0 6px; }
.post-item h2 a { color: var(--green); text-decoration: none; }
.post-item h2 a:hover { color: var(--gold-600); }
.post-item p { color: var(--muted); font-size: .97rem; margin: 0; }
.post-item.no-img { border-top: 4px solid var(--gold); }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 36px; }
.pager a { min-width: 40px; text-align: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--green); background: #fff; }
.pager a[aria-current="page"] { background: var(--green); color: #fff; border-color: var(--green); }

/* صفحة الخبر */
.back-link { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; font-weight: 700; margin-bottom: 18px; }
.post time { display: block; margin-bottom: 4px; }
.post-summary { font-size: 1.2rem; color: var(--muted); }
.post-img { margin: 26px 0; }
.post-img img { width: 100%; border-radius: var(--radius); }
.post-body { font-size: 1.1rem; }
.post-more { margin-top: 48px; border-top: 3px solid var(--gold); padding-top: 18px; }
.post-more h2 { font-size: 1.2rem; }

/* صفحة النتائج */
.results-page .results-card { margin-top: 10px; }
.notice { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.notice-error { background: #FBE3DC; color: #8A2A12; border-right: 4px solid var(--red); }
.transcript { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; border-top: 4px solid var(--gold); }
.tr-head { display: flex; gap: 14px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 18px; }
.tr-head strong { display: block; color: var(--green); font-size: 1.15rem; }
.tr-head span { color: var(--muted); font-size: .95rem; }
.tr-info { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin: 0 0 20px; }
.tr-info dt { color: var(--muted); font-size: .85rem; }
.tr-info dd { margin: 0; font-weight: 700; }
.table-scroll { overflow-x: auto; }
.tr-table { width: 100%; border-collapse: collapse; text-align: center; font-size: .98rem; }
.tr-table th, .tr-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.tr-table thead th { background: var(--paper); color: var(--green); font-size: .88rem; }
.tr-table tbody th { text-align: right; font-weight: 500; }
.tr-table tfoot th, .tr-table tfoot td { font-weight: 700; background: var(--paper); text-align: center; }
.tr-table tfoot th { text-align: right; }
.tr-table .b { font-weight: 700; }
.ok { color: #1B7A4A; font-weight: 700; }
.no { color: var(--red); font-weight: 700; }
.tr-result { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 20px; font-size: 1.08rem; }
.res-passed { color: #1B7A4A; } .res-failed { color: var(--red); } .res-second_round { color: var(--gold-600); }
.tr-actions { display: flex; gap: 10px; }

/* نافذة الصور */
.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.lightbox::backdrop { background: rgba(8,22,19,.92); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox figure { margin: 0; max-width: min(92vw, 1100px); text-align: center; }
.lightbox img { max-height: 80vh; margin: 0 auto; border-radius: 6px; }
.lightbox figcaption { color: #fff; margin-top: 10px; }
.lightbox button { position: fixed; background: rgba(255,255,255,.12); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 1.3rem; cursor: pointer; }
.lightbox button:hover { background: rgba(255,255,255,.25); }
.lb-close { top: 18px; left: 18px; }
.lb-prev { right: 18px; top: 50%; }
.lb-next { left: 18px; top: 50%; }

/* ---------- الشاشات الصغيرة ---------- */
@media (max-width: 1080px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; top: 100%; inset-inline: 0; background: #fff;
    flex-direction: column; align-items: stretch; padding: 10px 16px 18px; border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 30px -18px rgba(0,0,0,.3);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; }
  .site-nav a[aria-current="page"] { box-shadow: inset -3px 0 0 var(--gold); }
  .site-nav .btn-login { margin: 8px 0 0; display: flex; justify-content: center; gap: 6px; }
}
@media (max-width: 900px) {
  .hero { padding: 48px 0 112px; }
  .hero-in, .about-grid, .news-grid, .contact-grid, .footer-grid { grid-template-columns: 1fr; }
  .hero-in { gap: 36px; }
  .seal { width: min(78%, 340px); order: -1; }
  .results-card { grid-template-columns: 1fr; padding: 22px; }
  .program-list, .post-grid { grid-template-columns: 1fr 1fr; }
  .gallery { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 150px; }
  .admission-in { flex-direction: column; align-items: flex-start; }
  .about-grid, .news-grid { gap: 40px; }
  .section { padding: 64px 0; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .brand span { font-size: .92rem; }
  .brand img { width: 44px; height: 44px; }
  .result-form { grid-template-columns: 1fr; }
  .program-list, .post-grid, .contact-list { grid-template-columns: 1fr; }
  .tr-info { grid-template-columns: 1fr 1fr; }
  .tr-info > div:first-child { grid-column: span 2; }
  .stats > div + div { border-right: 0; padding-right: 0; }
  .transcript { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- الطباعة (كشف الدرجات) ---------- */
@media print {
  .urgent, .site-header, .site-footer, .no-print, .skip { display: none !important; }
  body { background: #fff; font-size: 13pt; }
  .section { padding: 0; }
  .transcript { border: 0; padding: 0; }
}
