/*
Theme Name: Madarisy — Final Stable (clean 2.3, modular)
Text Domain: madarisy
*/

/* =========================================================
=                 [GLOBAL] 0) TOKENS & FONTS               =
========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@300;400;700&display=swap');

:root{
  /* Brand palette */
  --blue:#1e5bb8; --blue-700:#154892;
  --green:#10b981; --green-700:#0a8f65;
  --orange:#f59e0b; --orange-700:#c78107;

  /* Surfaces & text */
  --bg:#f6f8fb; --surface:#ffffff;
  --text:#0f223f; --muted:#6d7481;
  --line:#e6eaf1;

  /* Radius & shadows */
  --r-sm:10px; --r:14px; --r-lg:20px;
  --shadow-sm:0 1px 3px rgba(0,0,0,.06);
  --shadow:0 8px 22px rgba(30,91,184,.10);

  /* Layout */
  --container:1240px;
  --gap:16px;

  /* Logo sizing */
  --logo-h-desktop:44px;
  --logo-h-compact:36px;
  --logo-h-mobile:32px;

  /* Buttons sizing */
  --btn-min-w:160px;   /* تقايُس عرض الأزرار */
  --btn-h:46px;        /* ارتفاع موحّد */
}

/* =========================================================
=                 [GLOBAL] 1) BASE & RESET                 =
========================================================= */
*{box-sizing:border-box}
html{scroll-behavior:smooth}
html,body{margin:0;padding:0}
body{
  direction:rtl;
  font-family:'Almarai',system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg); color:var(--text); line-height:1.7;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
}
img{max-width:100%;height:auto;border-radius:8px}
a{color:var(--blue);text-decoration:none}
a:hover{text-decoration:underline}
.container{max-width:var(--container);margin:0 auto;padding:0 16px}

/* =========================================================
=              [GLOBAL] 2) TYPOGRAPHY UTILS                =
========================================================= */
h1,h2,h3{margin:0 0 10px}
.title-xl{font-size:clamp(22px,3vw,36px);font-weight:800;letter-spacing:.1px;margin-bottom:6px}
.title-lg{font-size:clamp(18px,2.2vw,24px);font-weight:800;color:var(--blue);margin:0 0 6px}
.lead{color:var(--muted);font-size:clamp(15px,1.4vw,17px)}
.muted{color:var(--muted)}
.seo-paragraph{color:var(--muted);max-width:80ch}

/* =========================================================
=            [GLOBAL] 3) LAYOUT, CARDS, GRID               =
========================================================= */
.main-wrap{padding:16px 0}
.section{padding:14px 0}
.card{
  background:var(--surface);border:1px solid var(--line);
  border-radius:16px;padding:16px;box-shadow:var(--shadow)
}

/* Grid 12 */
.grid{display:grid;gap:14px;grid-template-columns:repeat(12,minmax(0,1fr))}
.col-12{grid-column:1/-1}
.col-6{grid-column:span 6}
.col-4{grid-column:span 4}
@media (max-width:1024px){.col-4{grid-column:span 6}.col-6{grid-column:span 12}}
@media (max-width:768px){.col-4,.col-6,.col-12{grid-column:1/-1}}

/* =========================================================
=                [COMPONENT] 4) HEADER (RTL)               =
=   Desktop/Tablet: logo right, menu left                   =
=   Mobile/Compact: logo center, hamburger + vertical menu  =
========================================================= */
.mad-header{
  position:sticky; top:0; z-index:100;
  background:#fff; border-bottom:1px solid var(--line); box-shadow:var(--shadow-sm);
}
.mad-header .hdr-wrap{
  direction:rtl;
  display:flex; align-items:center; gap:12px; padding:10px 0;
  justify-content:space-between; position:relative;
}

/* Logo */
.site-brand{display:flex; align-items:center; gap:8px; text-decoration:none; white-space:nowrap; overflow:hidden}
.site-brand .custom-logo{display:block; height:var(--logo-h-desktop); width:auto; max-width:240px; object-fit:contain}
.brand-text{display:none} /* نستخدم صورة شعار */

/* Primary nav (left in RTL) */
.primary-nav{display:block; margin-left:auto}
.primary-nav .menu{
  display:flex; gap:22px; list-style:none; margin:0; padding:0; justify-content:flex-end
}
.primary-nav .menu>li>a{
  display:inline-block; padding:8px 6px; font-weight:700; color:var(--text); border-radius:8px
}
.primary-nav .menu>li>a:hover{background:#eef3ff; color:var(--blue); text-decoration:none}

/* Mobile toggler */
.nav-toggle{display:none; border:0; background:transparent; padding:6px; cursor:pointer}
.nav-toggle .bar{display:block; width:26px; height:3px; background:#7a7a7a; border-radius:3px; margin:4px 0}

/* Compact mode (overlap) */
.mad-header .hdr-wrap.is-compact{justify-content:center}
.mad-header .hdr-wrap.is-compact .site-brand{order:2}
.mad-header .hdr-wrap.is-compact .site-brand .custom-logo{height:var(--logo-h-compact)}
.mad-header .hdr-wrap.is-compact .nav-toggle{
  display:block; order:3; position:absolute; right:12px; top:50%; transform:translateY(-50%);
}
.mad-header .hdr-wrap.is-compact .primary-nav{
  order:1; display:none; position:absolute; top:100%; right:0; left:0;
  background:#fff; border-bottom:1px solid var(--line); box-shadow:var(--shadow);
}
.mad-header .hdr-wrap.is-compact .primary-nav.open{display:block}
.mad-header .hdr-wrap.is-compact .primary-nav .menu{flex-direction:column; gap:0; padding:8px 0}
.mad-header .hdr-wrap.is-compact .primary-nav .menu li a{display:block; padding:12px 16px; border-radius:0}

/* Mobile breakpoint (forces compact) */
@media (max-width:768px){
  .mad-header .hdr-wrap{justify-content:center}
  .site-brand .custom-logo{height:var(--logo-h-mobile)}
  .nav-toggle{display:block; position:absolute; right:12px; top:50%; transform:translateY(-50%)}
  .primary-nav{display:none; position:absolute; top:100%; right:0; left:0; background:#fff; border-bottom:1px solid var(--line); box-shadow:var(--shadow)}
  .primary-nav.open{display:block}
  .primary-nav .menu{flex-direction:column; gap:0; padding:8px 0}
  .primary-nav .menu li a{display:block; padding:12px 16px}
  .site-brand{order:2}
}

/* ضمان: لوغو يمين/قائمة يسار على الديسكتوب مهما كانت إضافات أخرى */
@media (min-width:769px){
  .mad-header .hdr-wrap{direction:rtl !important; display:flex !important; align-items:center !important; justify-content:flex-start !important; gap:12px !important}
  .mad-header .site-brand{order:1 !important; margin:0 !important; float:none !important}
  .mad-header .primary-nav{order:2 !important; flex:0 1 auto !important; margin-left:auto !important; margin-right:0 !important; float:none !important; text-align:left !important}
  .mad-header .primary-nav .menu{display:flex !important; gap:22px !important; list-style:none !important; margin:0 !important; padding:0 !important; justify-content:flex-end !important}
  .mad-header .nav-toggle{display:none !important}
}

/* =========================================================
=              [COMPONENT] 5) HERO (Home Top)              =
========================================================= */
.hero-pro{
  background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  border: 1px solid #e8eef9;
  border-radius: 20px;
  box-shadow: 0 10px 26px rgba(30,91,184,.08);
  padding: 22px 18px !important;
  text-align:center;
}
.hero-pro .title-xl{color:#162033; letter-spacing:.2px; margin-bottom:10px}
.hero-pro .lead{color:#5c6473; font-size:clamp(15px,1.5vw,17px); max-width:80ch; margin-inline:auto}

/* Search */
.hero-search{display:flex; gap:8px; flex-wrap:wrap; justify-content:center; margin:16px auto 12px !important}
.hero-search input{
  flex:1; max-width:780px; min-width:240px; min-height:50px;
  border:2px solid #dbe7ff; background:#fff; border-radius:14px; padding:12px 14px; font-size:16px;
  transition:border-color .18s ease, box-shadow .18s ease;
}
.hero-search input::placeholder{color:#9aa6b2}
.hero-search input:focus{border-color:#7aa6ff; box-shadow:0 0 0 4px rgba(122,166,255,.15)}
.hero-search .btn{
  min-height:50px; padding-inline:18px; border-radius:12px; font-weight:800;
  border:2px solid #144ea0; box-shadow:0 4px 0 #0d3688;
}
.hero-search .btn:active{transform:translateY(1px); box-shadow:0 3px 0 #0d3688}

/* =========================================================
=         [COMPONENT] 6) CYCLE CARDS (Primary/College/Lycee)
========================================================= */
.cycle-cards{display:grid; gap:14px; margin-top:14px; grid-template-columns: repeat(12,minmax(0,1fr))}
.cycle-card{
  grid-column: span 4;
  display:flex; flex-direction:column; gap:8px;
  background:#fff; border:1px solid var(--line); border-radius:16px;
  padding:16px; text-decoration:none; color:inherit;
  box-shadow:0 6px 18px rgba(0,0,0,.05);
  transition:transform .18s ease, box-shadow .18s ease, background .18s ease;
  position:relative; overflow:hidden;
}
.cycle-card:hover{transform:translateY(-3px); box-shadow:0 10px 26px rgba(30,91,184,.12); text-decoration:none}
.cycle-icon{display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; border-radius:12px; background:#f1f5ff}
.cycle-title{font-size:18px; font-weight:800; line-height:1}
.cycle-sub{font-size:13px; color:#6d7481}
.cycle--primary .cycle-icon{background:#eaf2ff}
.cycle--primary:hover{background:linear-gradient(180deg,#ffffff 0%,#f4f8ff 100%)}
.cycle--college .cycle-icon{background:#e8fbf3}
.cycle--college:hover{background:linear-gradient(180deg,#ffffff 0%,#ecfff7 100%)}
.cycle--lycee .cycle-icon{background:#fff3e8}
.cycle--lycee:hover{background:linear-gradient(180deg,#ffffff 0%,#fff7ee 100%)}
@media (max-width:1024px){ .cycle-card{grid-column: span 6} }
@media (max-width:768px){
  .hero-pro{padding:18px 14px !important}
  .cycle-cards{grid-template-columns:1fr; gap:12px}
  .cycle-card{grid-column:1/-1}
}

/* =========================================================
=              [COMPONENT] 7) NEWS LIST                    =
========================================================= */
.news-list{display:grid;gap:12px}
.news-item{background:#fff;border:1px solid var(--line);border-radius:12px;padding:12px 14px;box-shadow:var(--shadow-sm)}
.news-title{margin:0 0 6px;font-size:18px;font-weight:800}
.news-excerpt{margin:0;color:var(--muted);font-size:14px}

/* =========================================================
=            [COMPONENT] 8) CONTENT / TABLES               =
========================================================= */
.entry-content{font-size:1.05rem}
.entry-content h2{font-size:1.28rem;margin-top:16px}
.entry-content h3{font-size:1.12rem;margin-top:12px}
.entry-content ul{padding-inline-start:22px}
.entry-content table{width:100%;border-collapse:separate;border-spacing:0;margin:12px 0;border:1px solid var(--line);border-radius:12px;overflow:hidden}
.entry-content th,.entry-content td{padding:10px 12px;border-bottom:1px solid var(--line)}
.entry-content thead th{background:#f0f4fb}

/* =========================================================
=         [COMPONENT] 9) BREADCRUMBS & PAGINATION          =
========================================================= */
.breadcrumbs{font-size:14px;color:var(--muted);margin:8px 0 12px}
.breadcrumbs a{color:var(--blue)}
.pagination .nav-links{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}
.pagination a,.pagination span{padding:8px 10px;border:1px solid var(--line);border-radius:10px;background:#fff;min-width:34px;text-align:center}
.pagination .current{background:var(--blue);color:#fff;border-color:var(--blue)}

/* =========================================================
=                 [COMPONENT] 10) FOOTER                   =
========================================================= */
.mad-footer{margin-top:22px;background:#0b1630;color:#cfd8e6;padding:22px 0 10px;border-top:1px solid rgba(255,255,255,.06)}
.ftr-grid{display:grid;gap:14px;grid-template-columns:repeat(12,minmax(0,1fr))}
.ftr-grid>div:nth-child(1){grid-column:span 5}
.ftr-grid>div:nth-child(2){grid-column:span 4}
.ftr-grid>div:nth-child(3){grid-column:span 3}
.ftr-menu{list-style:none;margin:0;padding:0}
.ftr-menu li a{color:#e3ecfa}
.ftr-menu li a:hover{color:#fff;text-decoration:none}
.ftr-copy{border-top:1px solid rgba(255,255,255,.08);margin-top:10px;padding-top:8px;font-size:13px}

/* =========================================================
=        [COMPONENT] 11) HOME SECTIONS (Cards + Buttons)   =
========================================================= */
/* كارت أنيق لكل قسم */
.home-sec{
  background:#fff;
  border:1px solid #e9eef6;
  border-radius:18px;
  padding:16px 14px;
  margin:14px 0;
  box-shadow:0 8px 22px rgba(0,0,0,.045);
}

/* رأس القسم */
.section-head{margin-bottom:10px}
.section-head .title-lg{margin-bottom:4px}
.section-desc{
  color:#606a78; font-size:15px; line-height:1.9;
  max-width:90ch;
}

/* صف الأزرار */
.btn-row{
  display:flex; flex-wrap:wrap;
  gap:10px 10px;
  justify-content:flex-start;
  margin-top:10px;
}

/* زر كبسولي متقايِس (ارتفاع وعرض أدنى موحّد) */
.btn-pill{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  min-width:var(--btn-min-w);
  height:var(--btn-h);
  padding:0 16px;                 /* نفس الارتفاع دائماً */
  border-radius:999px;
  font-weight:800;
  border:2px solid transparent;
  text-decoration:none;
  transition:transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
  box-shadow:0 3px 0 rgba(0,0,0,.08);
  white-space:nowrap;
}
.btn-pill:hover{transform:translateY(-1px); text-decoration:none}
.btn-pill:active{transform:translateY(0)}

/* لون افتراضي احتياطي */
.btn-pill{background:#f6f9ff; color:#154892; border-color:#d7e5ff}

/* ألوان حسب القسم */
.home-sec--levels .btn-pill{background:#eef5ff; color:#154892; border-color:#cfe0ff; box-shadow:0 3px 0 rgba(21,72,146,.14)}
.home-sec--levels .btn-pill:hover{background:#e7f0ff; border-color:#bcd2ff}

.home-sec--student .btn-pill{background:#eef3ff; color:#1e5bb8; border-color:#cfe0ff; box-shadow:0 3px 0 rgba(30,91,184,.14)}
.home-sec--student .btn-pill:hover{background:#e8f1ff; border-color:#bcd2ff}

.home-sec--teacher .btn-pill{background:#eafcf4; color:#0a8f65; border-color:#cdeee2; box-shadow:0 3px 0 rgba(10,143,101,.14)}
.home-sec--teacher .btn-pill:hover{background:#e3f9f0; border-color:#bfe8d7}

.home-sec--uni .btn-pill{background:#fff7e8; color:#b15d09; border-color:#ffe0b8; box-shadow:0 3px 0 rgba(177,93,9,.14)}
.home-sec--uni .btn-pill:hover{background:#fff2db; border-color:#ffd49b}

.home-sec--news .btn-pill{background:#f1f5ff; color:#1f3b80; border-color:#d6e3ff; box-shadow:0 3px 0 rgba(31,59,128,.12)}
.home-sec--news .btn-pill:hover{background:#e9efff; border-color:#c7d8ff}

.home-sec--seo .btn-pill{background:#f6faf3; color:#2a6b2f; border-color:#d7efd9; box-shadow:0 3px 0 rgba(42,107,47,.12)}
.home-sec--seo .btn-pill:hover{background:#eef9ea; border-color:#c9ecca}

/* Accent صغير أعلى كل كارت */
.home-sec--levels  {border-top:4px solid #cfe0ff}
.home-sec--student {border-top:4px solid #cfe0ff}
.home-sec--teacher {border-top:4px solid #cdeee2}
.home-sec--uni     {border-top:4px solid #ffe0b8}
.home-sec--news    {border-top:4px solid #d6e3ff}
.home-sec--seo     {border-top:4px solid #d7efd9}

/* استجابة ممتازة */
@media (max-width:992px){
  .home-sec{padding:14px 12px}
  .section-desc{font-size:14px}
  :root{--btn-min-w:140px; --btn-h:44px}
}
@media (max-width:600px){
  .btn-row{gap:8px}
  :root{--btn-min-w:120px; --btn-h:42px}
}

/* =========================================================
=        [LEGACY CLEANUP] 12) REMOVE OLD STATS BLOCK        =
========================================================= */
#home-hero .stat-list, #home-hero .stat-num, #home-hero .stat-label{display:none !important}

/* === Center primary nav on desktop/tablet (RTL) === */
@media (min-width: 769px){
  .mad-header .hdr-wrap{
    position: relative; /* مهمّ لتوسيط الـnav */
  }

  /* خلي اللوغو ثابت يمين بلا تغيير */
  .mad-header .site-brand{
    order: 1 !important;
    margin: 0 !important;
  }

  /* المنيو في الوسط تماماً داخل الكونتينر */
  .mad-header .primary-nav{
    order: 2 !important;
    position: absolute !important;
    left: 50% !important;          /* نحدد المركز */
    transform: translateX(-50%) !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
    width: auto;                    /* ما تشدش العرض كامل */
    text-align: center !important;
  }
  .mad-header .primary-nav .menu{
    justify-content: center !important; /* العناصر وسط */
    gap: 22px !important;
  }

  /* زر الموبايل موحود غير فالصغير، نخبيه هنا */
  .mad-header .nav-toggle{ display: none !important; }
}

/* ⚡ استايل البحث */
.site-search {
  width: 100%;
  max-width: 700px;
  margin: 20px auto;
}

.site-search .search-group {
  display: flex;
  align-items: center;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.site-search input[type="search"] {
  flex: 1;
  padding: 12px 16px;
  border: none;
  font-size: 16px;
  outline: none;
  background: #fff;
}

.site-search input[type="search"]::placeholder {
  color: #999;
}

.site-search .search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #2d89ef; /* لون أزرق تعليمي */
  color: #fff;
  border: none;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  white-space: nowrap;
  transition: background 0.3s;
}

.site-search .search-btn:hover {
  background: #1e5cb3;
}

.site-search .search-btn .icon {
  width: 18px;
  height: 18px;
  stroke: #fff;
}

/* البطاقات */
.cycle-cards {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 40px 0;
}

.cycle-card {
  flex: 1 1 260px;          /* الحجم الأساسي */
  max-width: 300px;         /* الحد الأقصى في الشاشات الكبيرة */
  min-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 16px;       /* تصغير المساحة الداخلية */
  border-radius: 12px;
  background: #fff;
  color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  text-decoration: none;
}

.cycle-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 5px 14px rgba(0,0,0,0.12);
}

.cycle-card .cycle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.05);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  margin-bottom: 12px;
  transition: background 0.3s, transform 0.3s;
}

.cycle-card:hover .cycle-icon {
  transform: scale(1.08);
}

.cycle-card .cycle-icon svg {
  width: 26px;
  height: 26px;
}

/* العناوين */
.cycle-title {
  font-size: 18px;
  font-weight: bold;
  margin: 4px 0;
}

.cycle-sub {
  font-size: 13px;
  color: #666;
  margin: 0;
}

/* ألوان الأسلاك */
.cycle--primary { border-top: 3px solid #1e5bb8; }
.cycle--primary .cycle-icon { color: #1e5bb8; background: rgba(30,91,184,0.1); }

.cycle--college { border-top: 3px solid #0a8f65; }
.cycle--college .cycle-icon { color: #0a8f65; background: rgba(10,143,101,0.1); }

.cycle--lycee { border-top: 3px solid #c78107; }
.cycle--lycee .cycle-icon { color: #c78107; background: rgba(199,129,7,0.1); }


/* =====================[ HOME SECTIONS — CENTERED ]===================== */
/* وسّط العنوان والوصف، وخلي عرض الوصف مضبوط */
.home-sec .section-head,
.home-sec .section-desc {
  text-align: center;
}

.home-sec .section-desc {
  margin-inline: auto;
  max-width: 84ch; /* أو 80ch حسب ذوقك */
}

/* صف الأزرار: وسط ومرن */
.home-sec .btn-row{
  justify-content: center;        /* كان flex-start -> مركزنا */
  gap: 10px 12px;                 /* فراغ أفقي أكبر شوية */
}

/* زر كبسولي: أطول ومتجاوب */
:root{
  /* نرفع الحد الأدنى شوية */
  --btn-min-w: 170px;
  --btn-h: 48px;
}

/* طول/عرض متجاوب باستعمال clamp */
.home-sec .btn-pill{
  min-width: clamp(150px, 22vw, 230px);
  height: var(--btn-h);
  padding: 0 18px;                /* يعطي نفس الارتفاع */
  font-weight: 800;
  line-height: 1;                 /* تجنّب تمدد عمودي */
  justify-content: center;
}

/* أيقونة داخل الزرّ (إن وجدت) */
.home-sec .btn-pill .emoji,
.home-sec .btn-pill .icon{
  width: 18px; height: 18px;
  margin-left: 6px;               /* RTL: الأيقونة يسار النص */
}

/* ===== تكييف أحجام الأزرار حسب حجم الشاشة ===== */
@media (max-width: 992px){
  :root{ --btn-min-w: 150px; --btn-h: 46px; }
  .home-sec .btn-pill{ min-width: clamp(140px, 32vw, 200px); }
}

@media (max-width: 600px){
  :root{ --btn-min-w: 130px; --btn-h: 44px; }
  .home-sec .btn-row{ gap: 8px; }
  .home-sec .btn-pill{ min-width: clamp(128px, 42vw, 190px); padding: 0 14px; }
}

/* =====================[ CYCLE CARDS — TWEAKS ]===================== */
/* توسيط الشبكة (أنت أصلاً مركزها، هاد لمسات خفيفة) */
.cycle-cards{
  justify-content: center;
  margin-top: 16px;
}

/* خفّض المبالغة في الارتفاع باش ما تبانش “أزرار ضخمة” */
.cycle-card{
  padding: 16px 14px;
  max-width: 300px;
}
.cycle-title{ font-size: 17px; margin: 4px 0; }
.cycle-sub{ font-size: 12.5px; }

/* =====================[ HERO SEARCH — CONSISTENT CENTER ]===================== */
/* إذا كنت كتستعمل .site-search داخل الهيرو، خلّيه دائماً وسط */
.hero-pro .site-search,
.hero-pro .hero-search{
  margin-inline: auto;
  justify-content: center;
}

/* =====================[ OPTIONAL: CENTERED UTIL ]===================== */
/* تقدر تستعمل .text-center لأي عناصر إضافية بغيت توسّطها */
.text-center{ text-align:center }