.arttree-rt{--rt-bg:#0b0b0f;--rt-card:#15151d;--rt-card-soft:rgba(255,255,255,.055);--rt-text:#f7f4ee;--rt-muted:#b9b2a8;--rt-gold:#c8a96a;--rt-gold-soft:rgba(200,169,106,.16);--rt-line:rgba(255,255,255,.12);--rt-ok:#68d391;--rt-danger:#f87171;font-family:inherit;color:var(--rt-text);background:radial-gradient(circle at 70% 0,rgba(200,169,106,.16),transparent 34%),linear-gradient(180deg,#101018,#09090d);padding:0;border-radius:34px;margin:32px auto;max-width:1200px;overflow:hidden;border:1px solid var(--rt-line)}
.arttree-rt *{box-sizing:border-box}
.arttree-rt-hero{position:relative;text-align:center;padding:78px 24px 52px;max-width:900px;margin:0 auto}
.arttree-rt-hero:before{content:"";position:absolute;inset:24px auto auto 50%;width:180px;height:180px;transform:translateX(-50%);background:rgba(200,169,106,.12);filter:blur(60px);pointer-events:none}
.arttree-eyebrow{display:inline-flex;align-items:center;justify-content:center;border:1px solid rgba(200,169,106,.35);background:var(--rt-gold-soft);color:var(--rt-gold);border-radius:999px;padding:7px 14px;font-size:13px;font-weight:800;margin-bottom:18px}
.arttree-rt-hero h2,.arttree-rt-head h2{font-size:40px;line-height:1.22;margin:0 0 14px;font-weight:900;font-feature-settings:"kern" 1,"liga" 1,"calt" 1}
.arttree-rt-hero p,.arttree-rt-head p{font-size:30px;line-height:1.65;color:var(--rt-muted);margin:0 auto;max-width:780px}
.arttree-rt-actions{display:flex;justify-content:center;align-items:center;gap:12px;margin-top:28px;flex-wrap:wrap}
.arttree-rt-primary,.arttree-rt-secondary,.arttree-rt-toggle,.arttree-rt-form button,.arttree-rt-disabled{appearance:none;text-decoration:none;border-radius:999px;padding:13px 20px;font-size:15px;font-weight:900;line-height:1;transition:transform .22s ease,opacity .22s ease,border-color .22s ease,background .22s ease;display:inline-flex;align-items:center;justify-content:center;min-height:46px}
.arttree-rt-primary,.arttree-rt-toggle,.arttree-rt-form button{border:1px solid var(--rt-gold);background:var(--rt-gold);color:#111;cursor:pointer}
.arttree-rt-secondary{border:1px solid var(--rt-line);background:rgba(255,255,255,.04);color:var(--rt-text)}
.arttree-rt-primary:hover,.arttree-rt-secondary:hover,.arttree-rt-toggle:hover,.arttree-rt-form button:hover{transform:translateY(-2px);opacity:.92}
.arttree-rt-disabled{border:1px solid rgba(248,113,113,.25);background:rgba(248,113,113,.08);color:#fca5a5;cursor:not-allowed}
.arttree-rt-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;padding:0 24px 56px}
.arttree-rt-card{background:linear-gradient(180deg,rgba(255,255,255,.065),rgba(255,255,255,.025));border:1px solid var(--rt-line);border-radius:26px;padding:24px;transition:transform .25s ease,border-color .25s ease,background .25s ease,box-shadow .25s ease;min-height:100%}
.arttree-rt-card:hover{transform:translateY(-7px);border-color:rgba(200,169,106,.48);background:rgba(255,255,255,.07);box-shadow:0 18px 48px rgba(0,0,0,.22)}
.arttree-rt-card.is-closed{opacity:.82;filter:saturate(.82)}
.arttree-card-top{display:flex;justify-content:flex-start;margin-bottom:14px}
.arttree-status{display:inline-flex;border-radius:999px;padding:7px 12px;font-size:13px;font-weight:900;border:1px solid var(--rt-line)}
.arttree-status.open{color:var(--rt-ok);background:rgba(104,211,145,.09);border-color:rgba(104,211,145,.24)}
.arttree-status.closed{color:#fca5a5;background:rgba(248,113,113,.09);border-color:rgba(248,113,113,.24)}
.arttree-rt-card h3,.arttree-portal-card h3,.arttree-rt-faq h3{font-size:28px;line-height:1.35;margin:0 0 12px;font-weight:900;color:var(--rt-text)}
.arttree-rt-meta{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px;color:var(--rt-gold);font-size:14px}
.arttree-rt-meta span{border:1px solid rgba(200,169,106,.26);background:rgba(200,169,106,.08);padding:6px 10px;border-radius:999px}
.arttree-rt-card p,.arttree-portal-card p,.arttree-rt-faq p{font-size:16px;line-height:1.85;color:var(--rt-muted);margin:0 0 18px}
.arttree-deadline{font-size:14px;color:var(--rt-muted);margin:0 0 16px}
.arttree-rt-form{margin-top:18px;display:grid;gap:12px;background:rgba(0,0,0,.18);border:1px solid var(--rt-line);border-radius:20px;padding:16px}
.arttree-rt-form[hidden]{display:none}
.arttree-rt-form.visible{display:grid;max-width:540px;margin:0 auto 52px}
.arttree-rt-form label{display:grid;gap:7px;font-size:14px;color:var(--rt-muted)}
.arttree-rt-form input,.arttree-rt-form textarea{width:100%;border:1px solid var(--rt-line);background:rgba(255,255,255,.06);color:var(--rt-text);border-radius:14px;padding:12px 14px;font:inherit;outline:none;transition:border-color .2s ease,box-shadow .2s ease}
.arttree-rt-form input:focus,.arttree-rt-form textarea:focus{border-color:rgba(200,169,106,.65);box-shadow:0 0 0 4px rgba(200,169,106,.12)}
.arttree-portal-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;padding:0 24px 52px}
.arttree-portal-card{display:block;text-decoration:none;color:var(--rt-text);background:linear-gradient(180deg,rgba(255,255,255,.07),rgba(255,255,255,.025));border:1px solid var(--rt-line);border-radius:28px;padding:26px;transition:transform .25s ease,border-color .25s ease,background .25s ease}
.arttree-portal-card:hover{transform:translateY(-7px);border-color:rgba(200,169,106,.48);background:rgba(255,255,255,.075)}
.arttree-portal-card span{width:42px;height:42px;border-radius:14px;display:block;margin-bottom:18px;background:linear-gradient(135deg,var(--rt-gold),#ead6a7);position:relative}
.arttree-portal-card span:after{content:"";position:absolute;inset:12px;border:2px solid #111;border-radius:8px}
.arttree-rt-faq{margin:0 24px 56px;padding:26px;border-radius:28px;background:rgba(255,255,255,.04);border:1px solid var(--rt-line)}
.arttree-rt-faq details{border-top:1px solid var(--rt-line);padding:16px 0}
.arttree-rt-faq details:first-of-type{border-top:0}
.arttree-rt-faq summary{cursor:pointer;font-size:18px;font-weight:900;color:var(--rt-text);list-style:none}
.arttree-rt-faq summary::-webkit-details-marker{display:none}
.arttree-rt-faq summary:after{content:"+";float:left;color:var(--rt-gold);font-weight:900}
.arttree-rt-faq details[open] summary:after{content:"-"}
.arttree-rt-success,.arttree-rt-error{max-width:540px;margin:18px auto 52px;padding:16px;border-radius:18px}.arttree-rt-success{background:rgba(40,167,69,.14);border:1px solid rgba(40,167,69,.35)}.arttree-rt-error{background:rgba(220,53,69,.14);border:1px solid rgba(220,53,69,.35)}.arttree-rt-empty{grid-column:1/-1;text-align:center;color:var(--rt-muted);font-size:16px}
@media(max-width:900px){.arttree-rt{border-radius:24px;margin:24px 0}.arttree-rt-hero{padding:54px 16px 38px}.arttree-rt-hero h2,.arttree-rt-head h2{font-size:36px}.arttree-rt-hero p,.arttree-rt-head p{font-size:20px}.arttree-rt-grid,.arttree-portal-grid{grid-template-columns:1fr;padding:0 16px 40px}.arttree-rt-card h3,.arttree-portal-card h3,.arttree-rt-faq h3{font-size:22px}.arttree-rt-faq{margin:0 16px 40px;padding:20px}.arttree-rt-faq summary{font-size:16px}}
@media(prefers-reduced-motion:reduce){.arttree-rt *{transition:none!important;animation:none!important}}

/* v1.0.22 - Combined recruitment/training pages and applicant portal */
.arttree-rt-section-head{padding:12px 24px 24px;max-width:980px;margin:0 auto;text-align:right}
.arttree-rt-section-head span{display:inline-flex;border:1px solid rgba(200,169,106,.32);background:rgba(200,169,106,.12);color:var(--rt-gold);border-radius:999px;padding:7px 12px;font-size:13px;font-weight:900;margin-bottom:12px}
.arttree-rt-section-head h3{font-size:40px;line-height:1.25;margin:0 0 10px;font-weight:900;color:var(--rt-text)}
.arttree-rt-section-head p{font-size:20px;line-height:1.8;color:var(--rt-muted);margin:0;max-width:760px}
.arttree-portal-shell{display:grid;grid-template-columns:260px 1fr;gap:18px;margin:0 24px 28px;padding:18px;border:1px solid var(--rt-line);border-radius:30px;background:rgba(255,255,255,.035)}
.arttree-portal-sidebar{display:grid;align-content:start;gap:8px;border:1px solid var(--rt-line);background:rgba(0,0,0,.18);border-radius:24px;padding:18px;position:relative}
.arttree-portal-sidebar strong{font-size:20px;color:var(--rt-text);margin-bottom:10px}
.arttree-portal-sidebar a{display:flex;align-items:center;min-height:42px;text-decoration:none;color:var(--rt-muted);border:1px solid transparent;border-radius:14px;padding:9px 12px;font-size:15px;font-weight:800;transition:background .22s ease,color .22s ease,border-color .22s ease,transform .22s ease}
.arttree-portal-sidebar a:hover{background:rgba(200,169,106,.1);border-color:rgba(200,169,106,.25);color:var(--rt-text);transform:translateX(-2px)}
.arttree-portal-content{display:grid;gap:16px}
.arttree-portal-panel{border:1px solid rgba(200,169,106,.25);border-radius:24px;padding:22px;background:linear-gradient(180deg,rgba(200,169,106,.12),rgba(255,255,255,.025))}
.arttree-portal-panel span{color:var(--rt-gold);font-size:13px;font-weight:900}
.arttree-portal-panel h3{font-size:32px;line-height:1.35;margin:8px 0 8px;color:var(--rt-text)}
.arttree-portal-panel p{font-size:16px;line-height:1.9;color:var(--rt-muted);margin:0}
.arttree-portal-mini-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.arttree-portal-mini-grid div{border:1px solid var(--rt-line);background:rgba(255,255,255,.04);border-radius:22px;padding:18px}
.arttree-portal-mini-grid b{display:block;font-size:18px;color:var(--rt-text);margin-bottom:8px}
.arttree-portal-mini-grid p{font-size:15px;line-height:1.75;color:var(--rt-muted);margin:0}
.arttree-combined-page .arttree-rt-grid{padding-bottom:34px}
.arttree-combined-page .arttree-rt-faq{margin-top:10px}
@media(max-width:900px){.arttree-rt-section-head{padding:8px 16px 20px}.arttree-rt-section-head h3{font-size:32px}.arttree-rt-section-head p{font-size:18px}.arttree-portal-shell{grid-template-columns:1fr;margin:0 16px 24px;padding:14px;border-radius:24px}.arttree-portal-sidebar{display:flex;overflow-x:auto;gap:8px;border-radius:20px}.arttree-portal-sidebar strong{min-width:max-content;margin:0 0 0 8px;align-self:center}.arttree-portal-sidebar a{min-width:max-content}.arttree-portal-mini-grid{grid-template-columns:1fr}.arttree-portal-panel h3{font-size:26px}}

/* v1.0.23 - make careers training workshops pages follow homepage visual system */
.arttree-jobs-page,
.arttree-training-page{
  --rt-bg:#fbfaf6;
  --rt-card:#ffffff;
  --rt-text:#251c32;
  --rt-muted:#6f6579;
  --rt-gold:#503d7a;
  --rt-gold-soft:rgba(80,61,122,.09);
  --rt-line:#e7dfd4;
  --rt-ok:#207a4a;
  --rt-danger:#a93d3d;
  width:100vw;
  max-width:none;
  margin:0 calc(50% - 50vw);
  padding:0;
  border:0;
  border-radius:0;
  overflow:visible;
  color:var(--rt-text);
  background:var(--rt-bg);
}
.arttree-jobs-page .arttree-rt-hero,
.arttree-training-page .arttree-rt-hero{
  max-width:none;
  min-height:520px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:flex-start;
  text-align:right;
  padding:132px max(24px,calc((100vw - 1180px)/2)) 92px;
  background:
    radial-gradient(circle at 16% 20%,rgba(80,61,122,.13),transparent 34%),
    radial-gradient(circle at 88% 12%,rgba(184,148,77,.16),transparent 28%),
    linear-gradient(180deg,#fbfaf6 0%,#f7f2ea 100%);
  border-bottom:1px solid var(--rt-line);
}
.arttree-jobs-page .arttree-rt-hero:before,
.arttree-training-page .arttree-rt-hero:before{display:none}
.arttree-jobs-page .arttree-eyebrow,
.arttree-training-page .arttree-eyebrow{
  background:rgba(80,61,122,.08);
  border-color:rgba(80,61,122,.16);
  color:#503d7a;
  margin-bottom:22px;
  font-size:14px;
  font-weight:900;
}
.arttree-jobs-page .arttree-rt-hero h2,
.arttree-training-page .arttree-rt-hero h2{
  max-width:900px;
  font-size:88px;
  line-height:.95;
  letter-spacing:0;
  color:var(--rt-text);
  margin:0 0 24px;
  text-wrap:balance;
}
.arttree-jobs-page .arttree-rt-hero p,
.arttree-training-page .arttree-rt-hero p{
  max-width:760px;
  margin:0;
  color:var(--rt-muted);
  font-size:20px;
  line-height:1.8;
  font-weight:400;
}
.arttree-jobs-page .arttree-rt-actions,
.arttree-training-page .arttree-rt-actions{justify-content:flex-start;margin-top:30px}
.arttree-jobs-page .arttree-rt-primary,
.arttree-training-page .arttree-rt-primary,
.arttree-jobs-page .arttree-rt-toggle,
.arttree-training-page .arttree-rt-toggle,
.arttree-jobs-page .arttree-rt-form button,
.arttree-training-page .arttree-rt-form button{
  background:#503d7a;
  border-color:#503d7a;
  color:#fff;
  box-shadow:0 14px 34px rgba(80,61,122,.18);
}
.arttree-jobs-page .arttree-rt-secondary,
.arttree-training-page .arttree-rt-secondary{
  background:#fff;
  border-color:var(--rt-line);
  color:var(--rt-text);
}
.arttree-jobs-page .arttree-rt-section-head,
.arttree-training-page .arttree-rt-section-head{
  max-width:1180px;
  padding:84px 24px 34px;
  margin:0 auto;
  text-align:right;
}
.arttree-jobs-page .arttree-rt-section-head span,
.arttree-training-page .arttree-rt-section-head span{
  color:#503d7a;
  background:rgba(80,61,122,.08);
  border-color:rgba(80,61,122,.16);
}
.arttree-jobs-page .arttree-rt-section-head h3,
.arttree-training-page .arttree-rt-section-head h3{
  color:var(--rt-text);
  font-size:40px;
  line-height:1.12;
  margin:0 0 14px;
}
.arttree-jobs-page .arttree-rt-section-head p,
.arttree-training-page .arttree-rt-section-head p{
  max-width:860px;
  color:var(--rt-muted);
  font-size:30px;
  line-height:1.45;
}
.arttree-jobs-page .arttree-rt-grid,
.arttree-training-page .arttree-rt-grid{
  max-width:1180px;
  margin:0 auto;
  padding:0 24px 72px;
  gap:22px;
}
.arttree-jobs-page .arttree-rt-card,
.arttree-training-page .arttree-rt-card{
  background:#fff;
  border:1px solid var(--rt-line);
  border-radius:30px;
  padding:30px;
  box-shadow:0 14px 42px rgba(34,24,52,.06);
}
.arttree-jobs-page .arttree-rt-card:hover,
.arttree-training-page .arttree-rt-card:hover{
  transform:translateY(-8px);
  border-color:rgba(80,61,122,.22);
  background:#fff;
  box-shadow:0 26px 70px rgba(34,24,52,.13);
}
.arttree-jobs-page .arttree-rt-card h3,
.arttree-training-page .arttree-rt-card h3{
  color:var(--rt-text);
  font-size:28px;
  line-height:1.12;
  margin-bottom:14px;
}
.arttree-jobs-page .arttree-rt-card p,
.arttree-training-page .arttree-rt-card p{
  color:var(--rt-muted);
  font-size:16px;
  line-height:1.75;
}
.arttree-jobs-page .arttree-rt-meta span,
.arttree-training-page .arttree-rt-meta span{
  color:#503d7a;
  background:rgba(80,61,122,.07);
  border-color:rgba(80,61,122,.16);
}
.arttree-jobs-page .arttree-status,
.arttree-training-page .arttree-status{background:#fbfaf6;border-color:var(--rt-line)}
.arttree-jobs-page .arttree-status.open,
.arttree-training-page .arttree-status.open{color:#207a4a;background:rgba(32,122,74,.08);border-color:rgba(32,122,74,.18)}
.arttree-jobs-page .arttree-status.closed,
.arttree-training-page .arttree-status.closed{color:#a93d3d;background:rgba(169,61,61,.08);border-color:rgba(169,61,61,.18)}
.arttree-jobs-page .arttree-rt-form,
.arttree-training-page .arttree-rt-form{
  background:#fbfaf6;
  border-color:var(--rt-line);
}
.arttree-jobs-page .arttree-rt-form input,
.arttree-training-page .arttree-rt-form input,
.arttree-jobs-page .arttree-rt-form textarea,
.arttree-training-page .arttree-rt-form textarea{
  background:#fff;
  border-color:var(--rt-line);
  color:var(--rt-text);
}
.arttree-jobs-page .arttree-rt-faq,
.arttree-training-page .arttree-rt-faq{
  max-width:1180px;
  margin:0 auto 84px;
  background:#fff;
  border-color:var(--rt-line);
  border-radius:30px;
  box-shadow:0 14px 42px rgba(34,24,52,.06);
}
.arttree-jobs-page .arttree-rt-faq h3,
.arttree-training-page .arttree-rt-faq h3,
.arttree-jobs-page .arttree-rt-faq summary,
.arttree-training-page .arttree-rt-faq summary{color:var(--rt-text)}
.arttree-jobs-page .arttree-rt-faq p,
.arttree-training-page .arttree-rt-faq p{color:var(--rt-muted)}
.arttree-training-page .arttree-rt-hero{background:
  radial-gradient(circle at 12% 28%,rgba(184,148,77,.16),transparent 30%),
  radial-gradient(circle at 88% 18%,rgba(80,61,122,.12),transparent 32%),
  linear-gradient(180deg,#fbfaf6 0%,#f7f2ea 100%)}
@media(max-width:900px){
  .arttree-jobs-page .arttree-rt-hero,
  .arttree-training-page .arttree-rt-hero{min-height:auto;padding:104px 16px 58px}
  .arttree-jobs-page .arttree-rt-hero h2,
  .arttree-training-page .arttree-rt-hero h2{font-size:44px;line-height:1}
  .arttree-jobs-page .arttree-rt-hero p,
  .arttree-training-page .arttree-rt-hero p{font-size:20px;line-height:1.75}
  .arttree-jobs-page .arttree-rt-section-head,
  .arttree-training-page .arttree-rt-section-head{padding:58px 16px 26px}
  .arttree-jobs-page .arttree-rt-section-head h3,
  .arttree-training-page .arttree-rt-section-head h3{font-size:36px}
  .arttree-jobs-page .arttree-rt-section-head p,
  .arttree-training-page .arttree-rt-section-head p{font-size:22px}
  .arttree-jobs-page .arttree-rt-grid,
  .arttree-training-page .arttree-rt-grid{padding:0 16px 52px}
  .arttree-jobs-page .arttree-rt-card:hover,
  .arttree-training-page .arttree-rt-card:hover{transform:none}
  .arttree-jobs-page .arttree-rt-faq,
  .arttree-training-page .arttree-rt-faq{margin:0 16px 60px}
}


/* v1.0.26 - force training and workshops pages to match homepage light sections */
.arttree-rt.arttree-jobs-page,
.arttree-rt.arttree-training-page,
.arttree-rt.arttree-combined-page{
  --rt-bg:#fbfaf6 !important;
  --rt-card:#ffffff !important;
  --rt-card-soft:#ffffff !important;
  --rt-text:#251c32 !important;
  --rt-muted:#6f6579 !important;
  --rt-gold:#503d7a !important;
  --rt-gold-soft:rgba(80,61,122,.09) !important;
  --rt-line:#e7dfd4 !important;
  color:#251c32 !important;
  background:#fbfaf6 !important;
}
.arttree-rt.arttree-jobs-page *,
.arttree-rt.arttree-training-page *,
.arttree-rt.arttree-combined-page *{
  color-scheme:light;
}
.arttree-rt.arttree-jobs-page .arttree-rt-hero,
.arttree-rt.arttree-training-page .arttree-rt-hero,
.arttree-rt.arttree-combined-page .arttree-rt-hero{
  background:
    radial-gradient(circle at 16% 20%,rgba(80,61,122,.13),transparent 34%),
    radial-gradient(circle at 88% 12%,rgba(184,148,77,.16),transparent 28%),
    linear-gradient(180deg,#fbfaf6 0%,#f7f2ea 100%) !important;
  color:#251c32 !important;
  border-bottom:1px solid #e7dfd4 !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-hero h2,
.arttree-rt.arttree-training-page .arttree-rt-hero h2,
.arttree-rt.arttree-combined-page .arttree-rt-hero h2,
.arttree-rt.arttree-jobs-page .arttree-rt-section-head h3,
.arttree-rt.arttree-training-page .arttree-rt-section-head h3,
.arttree-rt.arttree-combined-page .arttree-rt-section-head h3,
.arttree-rt.arttree-jobs-page .arttree-rt-card h3,
.arttree-rt.arttree-training-page .arttree-rt-card h3,
.arttree-rt.arttree-combined-page .arttree-rt-card h3,
.arttree-rt.arttree-jobs-page .arttree-rt-faq h3,
.arttree-rt.arttree-training-page .arttree-rt-faq h3,
.arttree-rt.arttree-combined-page .arttree-rt-faq h3,
.arttree-rt.arttree-jobs-page .arttree-rt-faq summary,
.arttree-rt.arttree-training-page .arttree-rt-faq summary,
.arttree-rt.arttree-combined-page .arttree-rt-faq summary{
  color:#251c32 !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-hero p,
.arttree-rt.arttree-training-page .arttree-rt-hero p,
.arttree-rt.arttree-combined-page .arttree-rt-hero p,
.arttree-rt.arttree-jobs-page .arttree-rt-section-head p,
.arttree-rt.arttree-training-page .arttree-rt-section-head p,
.arttree-rt.arttree-combined-page .arttree-rt-section-head p,
.arttree-rt.arttree-jobs-page .arttree-rt-card p,
.arttree-rt.arttree-training-page .arttree-rt-card p,
.arttree-rt.arttree-combined-page .arttree-rt-card p,
.arttree-rt.arttree-jobs-page .arttree-rt-faq p,
.arttree-rt.arttree-training-page .arttree-rt-faq p,
.arttree-rt.arttree-combined-page .arttree-rt-faq p{
  color:#6f6579 !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-card,
.arttree-rt.arttree-training-page .arttree-rt-card,
.arttree-rt.arttree-combined-page .arttree-rt-card,
.arttree-rt.arttree-jobs-page .arttree-rt-faq,
.arttree-rt.arttree-training-page .arttree-rt-faq,
.arttree-rt.arttree-combined-page .arttree-rt-faq{
  background:#ffffff !important;
  border-color:#e7dfd4 !important;
  box-shadow:0 14px 42px rgba(34,24,52,.06) !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-form,
.arttree-rt.arttree-training-page .arttree-rt-form,
.arttree-rt.arttree-combined-page .arttree-rt-form{
  background:#fbfaf6 !important;
  border-color:#e7dfd4 !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-form input,
.arttree-rt.arttree-training-page .arttree-rt-form input,
.arttree-rt.arttree-combined-page .arttree-rt-form input,
.arttree-rt.arttree-jobs-page .arttree-rt-form textarea,
.arttree-rt.arttree-training-page .arttree-rt-form textarea,
.arttree-rt.arttree-combined-page .arttree-rt-form textarea{
  background:#ffffff !important;
  color:#251c32 !important;
  border-color:#e7dfd4 !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-primary,
.arttree-rt.arttree-training-page .arttree-rt-primary,
.arttree-rt.arttree-combined-page .arttree-rt-primary,
.arttree-rt.arttree-jobs-page .arttree-rt-toggle,
.arttree-rt.arttree-training-page .arttree-rt-toggle,
.arttree-rt.arttree-combined-page .arttree-rt-toggle,
.arttree-rt.arttree-jobs-page .arttree-rt-form button,
.arttree-rt.arttree-training-page .arttree-rt-form button,
.arttree-rt.arttree-combined-page .arttree-rt-form button{
  background:#503d7a !important;
  border-color:#503d7a !important;
  color:#ffffff !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-secondary,
.arttree-rt.arttree-training-page .arttree-rt-secondary,
.arttree-rt.arttree-combined-page .arttree-rt-secondary{
  background:#ffffff !important;
  color:#251c32 !important;
  border-color:#e7dfd4 !important;
}


/* v1.0.27 - remove outer frame from training and workshops pages so content is not compressed */
.arttree-rt.arttree-training-page,
.arttree-rt.arttree-combined-page,
.arttree-rt.arttree-jobs-page{
  border:0 !important;
  outline:0 !important;
  box-shadow:none !important;
  border-radius:0 !important;
  padding:0 !important;
  overflow:visible !important;
  max-width:none !important;
}
.arttree-rt.arttree-training-page .arttree-rt-hero,
.arttree-rt.arttree-combined-page .arttree-rt-hero,
.arttree-rt.arttree-jobs-page .arttree-rt-hero{
  border-radius:0 !important;
}
.arttree-rt.arttree-training-page .arttree-rt-grid,
.arttree-rt.arttree-combined-page .arttree-rt-grid,
.arttree-rt.arttree-jobs-page .arttree-rt-grid{
  width:min(1180px,100%);
  box-sizing:border-box;
}
.arttree-rt.arttree-training-page .arttree-rt-faq,
.arttree-rt.arttree-combined-page .arttree-rt-faq,
.arttree-rt.arttree-jobs-page .arttree-rt-faq{
  width:min(1180px,calc(100% - 48px));
  box-sizing:border-box;
}
@media(max-width:900px){
  .arttree-rt.arttree-training-page .arttree-rt-faq,
  .arttree-rt.arttree-combined-page .arttree-rt-faq,
  .arttree-rt.arttree-jobs-page .arttree-rt-faq{
    width:calc(100% - 32px);
  }
}


/* v1.0.30 - registration gate for jobs, training, and workshops */
.arttree-gate-panel{
  max-width:860px;
  margin:0 auto 36px;
  padding:28px;
  border-radius:30px;
  border:1px solid rgba(86,64,128,.14);
  background:rgba(255,255,255,.78);
  box-shadow:0 22px 70px rgba(35,24,53,.08);
  text-align:center;
}
.arttree-gate-panel span{
  display:inline-flex;
  padding:7px 12px;
  border-radius:999px;
  background:rgba(86,64,128,.08);
  color:#564080;
  font-size:13px;
  font-weight:900;
  margin-bottom:12px;
}
.arttree-gate-panel h3{
  margin:0 0 10px;
  font-size:36px;
  line-height:1.25;
  color:#281f3d;
  font-weight:900;
}
.arttree-gate-panel p{
  margin:0 auto;
  max-width:680px;
  color:#6f687b;
  font-size:18px;
  line-height:1.85;
}
.arttree-gate-panel small{
  display:block;
  margin-top:16px;
  color:#8a8494;
  font-size:13px;
}
.arttree-rt-card .arttree-rt-primary{
  margin-top:6px;
}
@media(max-width:900px){
  .arttree-gate-panel{margin:0 16px 28px;padding:22px;border-radius:24px}
  .arttree-gate-panel h3{font-size:28px}
  .arttree-gate-panel p{font-size:16px}
}


/* v1.0.31 - light applicant registration portal and hidden prototype dashboard */
.arttree-portal-page{
  --rt-bg:#fbfaf6;
  --rt-card:#ffffff;
  --rt-text:#251c32;
  --rt-muted:#6f6579;
  --rt-gold:#503d7a;
  --rt-gold-soft:rgba(80,61,122,.09);
  --rt-line:#e7dfd4;
  --rt-ok:#207a4a;
  --rt-danger:#a93d3d;
  width:100vw;
  max-width:none;
  margin:0 calc(50% - 50vw);
  padding:0;
  border:0;
  border-radius:0;
  overflow:visible;
  color:var(--rt-text);
  background:var(--rt-bg);
}
.arttree-portal-page .arttree-portal-hero{
  max-width:none;
  min-height:520px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:flex-start;
  text-align:right;
  padding:132px max(24px,calc((100vw - 1180px)/2)) 92px;
  background:
    radial-gradient(circle at 16% 20%,rgba(80,61,122,.13),transparent 34%),
    radial-gradient(circle at 88% 12%,rgba(184,148,77,.16),transparent 28%),
    linear-gradient(180deg,#fbfaf6 0%,#f7f2ea 100%);
  border-bottom:1px solid var(--rt-line);
}
.arttree-portal-page .arttree-portal-hero:before{display:none}
.arttree-portal-page .arttree-eyebrow{
  background:rgba(80,61,122,.08);
  border-color:rgba(80,61,122,.16);
  color:#503d7a;
}
.arttree-portal-page .arttree-rt-hero h2{
  max-width:860px;
  font-size:64px;
  line-height:1.04;
  letter-spacing:-.01em;
  color:var(--rt-text);
}
.arttree-portal-page .arttree-rt-hero p{
  max-width:760px;
  margin:0;
  font-size:24px;
  color:var(--rt-muted);
}
.arttree-portal-page .arttree-rt-primary{background:#503d7a;border-color:#503d7a;color:#fff}
.arttree-portal-page .arttree-rt-secondary{background:#fff;border-color:#e7dfd4;color:#251c32}
.arttree-portal-public-grid{
  max-width:1180px;
  margin:0 auto;
  padding:72px 24px 34px;
}
.arttree-portal-page .arttree-portal-card{
  background:#fff;
  border-color:#e7dfd4;
  color:#251c32;
  box-shadow:0 18px 58px rgba(37,28,50,.06);
}
.arttree-portal-page .arttree-portal-card:hover{
  background:#fff;
  border-color:rgba(80,61,122,.25);
  box-shadow:0 24px 70px rgba(37,28,50,.1);
}
.arttree-portal-page .arttree-portal-card h3{color:#251c32}
.arttree-portal-page .arttree-portal-card p{color:#6f6579}
.arttree-portal-page .arttree-portal-card span{background:linear-gradient(135deg,#503d7a,#7d65af)}
.arttree-portal-page .arttree-portal-card span:after{border-color:#fff}
.arttree-portal-page .arttree-rt-faq{
  max-width:1180px;
  margin:0 auto 82px;
  background:#fff;
  border-color:#e7dfd4;
  box-shadow:0 18px 58px rgba(37,28,50,.06);
}
.arttree-portal-page .arttree-rt-faq h3,
.arttree-portal-page .arttree-rt-faq summary{color:#251c32}
.arttree-portal-page .arttree-rt-faq p{color:#6f6579}
.arttree-portal-page .arttree-portal-shell,
.arttree-portal-page .arttree-portal-sidebar,
.arttree-portal-page .arttree-portal-content,
.arttree-portal-page .arttree-portal-panel,
.arttree-portal-page .arttree-portal-mini-grid{display:none!important}
@media(max-width:900px){
  .arttree-portal-page .arttree-portal-hero{min-height:auto;padding:112px 18px 58px}
  .arttree-portal-page .arttree-rt-hero h2{font-size:40px}
  .arttree-portal-page .arttree-rt-hero p{font-size:18px}
  .arttree-portal-public-grid{padding:44px 16px 24px}
  .arttree-portal-page .arttree-rt-faq{margin:0 16px 54px}
}

/* v1.0.33 - force registration portal and workshop/training gates to the same light homepage style */
.arttree-fullwidth-page{
  background:#fbfaf6;
  overflow-x:hidden;
}
.arttree-fullwidth-page > .arttree-rt,
.arttree-rt.arttree-portal-page,
.arttree-rt.arttree-applicant-portal,
.arttree-rt.arttree-training-page,
.arttree-rt.arttree-jobs-page,
.arttree-rt.arttree-combined-page{
  --rt-bg:#fbfaf6 !important;
  --rt-card:#ffffff !important;
  --rt-card-soft:#ffffff !important;
  --rt-text:#251c32 !important;
  --rt-muted:#6f6579 !important;
  --rt-gold:#503d7a !important;
  --rt-gold-soft:rgba(80,61,122,.09) !important;
  --rt-line:#e7dfd4 !important;
  color:#251c32 !important;
  background:#fbfaf6 !important;
  width:100vw !important;
  max-width:none !important;
  margin:0 calc(50% - 50vw) !important;
  padding:0 !important;
  border:0 !important;
  border-radius:0 !important;
  box-shadow:none !important;
  outline:0 !important;
  overflow:visible !important;
}
.arttree-rt.arttree-portal-page .arttree-portal-hero,
.arttree-rt.arttree-applicant-portal .arttree-portal-hero,
.arttree-rt.arttree-training-page .arttree-rt-hero,
.arttree-rt.arttree-jobs-page .arttree-rt-hero,
.arttree-rt.arttree-combined-page .arttree-rt-hero{
  width:100% !important;
  max-width:none !important;
  min-height:520px;
  margin:0 !important;
  padding:132px max(24px,calc((100vw - 1180px)/2)) 92px !important;
  display:flex !important;
  flex-direction:column !important;
  justify-content:center !important;
  align-items:flex-start !important;
  text-align:right !important;
  color:#251c32 !important;
  background:
    radial-gradient(circle at 16% 20%,rgba(80,61,122,.13),transparent 34%),
    radial-gradient(circle at 88% 12%,rgba(184,148,77,.16),transparent 28%),
    linear-gradient(180deg,#fbfaf6 0%,#f7f2ea 100%) !important;
  border:0 !important;
  border-bottom:1px solid #e7dfd4 !important;
  border-radius:0 !important;
  box-shadow:none !important;
}
.arttree-rt.arttree-portal-page .arttree-rt-hero:before,
.arttree-rt.arttree-applicant-portal .arttree-rt-hero:before,
.arttree-rt.arttree-training-page .arttree-rt-hero:before,
.arttree-rt.arttree-jobs-page .arttree-rt-hero:before,
.arttree-rt.arttree-combined-page .arttree-rt-hero:before{
  display:none !important;
}
.arttree-rt.arttree-portal-page .arttree-eyebrow,
.arttree-rt.arttree-applicant-portal .arttree-eyebrow,
.arttree-rt.arttree-training-page .arttree-eyebrow,
.arttree-rt.arttree-jobs-page .arttree-eyebrow,
.arttree-rt.arttree-combined-page .arttree-eyebrow{
  background:rgba(80,61,122,.08) !important;
  border-color:rgba(80,61,122,.16) !important;
  color:#503d7a !important;
}
.arttree-rt.arttree-portal-page .arttree-rt-hero h2,
.arttree-rt.arttree-applicant-portal .arttree-rt-hero h2,
.arttree-rt.arttree-training-page .arttree-rt-hero h2,
.arttree-rt.arttree-jobs-page .arttree-rt-hero h2,
.arttree-rt.arttree-combined-page .arttree-rt-hero h2{
  color:#251c32 !important;
  max-width:900px !important;
  font-size:64px !important;
  line-height:1.04 !important;
  margin:0 0 22px !important;
  text-align:right !important;
}
.arttree-rt.arttree-training-page .arttree-rt-hero h2,
.arttree-rt.arttree-jobs-page .arttree-rt-hero h2,
.arttree-rt.arttree-combined-page .arttree-rt-hero h2{
  font-size:88px !important;
  line-height:.95 !important;
}
.arttree-rt.arttree-portal-page .arttree-rt-hero p,
.arttree-rt.arttree-applicant-portal .arttree-rt-hero p,
.arttree-rt.arttree-training-page .arttree-rt-hero p,
.arttree-rt.arttree-jobs-page .arttree-rt-hero p,
.arttree-rt.arttree-combined-page .arttree-rt-hero p{
  color:#6f6579 !important;
  max-width:760px !important;
  margin:0 !important;
  text-align:right !important;
}
.arttree-rt.arttree-portal-page .arttree-rt-actions,
.arttree-rt.arttree-applicant-portal .arttree-rt-actions,
.arttree-rt.arttree-training-page .arttree-rt-actions,
.arttree-rt.arttree-jobs-page .arttree-rt-actions,
.arttree-rt.arttree-combined-page .arttree-rt-actions{
  justify-content:flex-start !important;
}
.arttree-rt.arttree-portal-page .arttree-portal-public-grid,
.arttree-rt.arttree-applicant-portal .arttree-portal-public-grid,
.arttree-rt.arttree-training-page .arttree-rt-grid,
.arttree-rt.arttree-jobs-page .arttree-rt-grid,
.arttree-rt.arttree-combined-page .arttree-rt-grid{
  width:min(1180px,100%) !important;
  max-width:1180px !important;
  margin:0 auto !important;
  padding-left:24px !important;
  padding-right:24px !important;
  box-sizing:border-box !important;
}
.arttree-rt.arttree-portal-page .arttree-portal-card,
.arttree-rt.arttree-applicant-portal .arttree-portal-card,
.arttree-rt.arttree-training-page .arttree-rt-card,
.arttree-rt.arttree-jobs-page .arttree-rt-card,
.arttree-rt.arttree-combined-page .arttree-rt-card,
.arttree-rt.arttree-portal-page .arttree-rt-faq,
.arttree-rt.arttree-applicant-portal .arttree-rt-faq,
.arttree-rt.arttree-training-page .arttree-rt-faq,
.arttree-rt.arttree-jobs-page .arttree-rt-faq,
.arttree-rt.arttree-combined-page .arttree-rt-faq,
.arttree-gate-panel{
  background:#ffffff !important;
  border:1px solid #e7dfd4 !important;
  color:#251c32 !important;
  box-shadow:0 18px 58px rgba(37,28,50,.06) !important;
}
.arttree-rt.arttree-portal-page .arttree-portal-card h3,
.arttree-rt.arttree-applicant-portal .arttree-portal-card h3,
.arttree-rt.arttree-training-page .arttree-rt-card h3,
.arttree-rt.arttree-jobs-page .arttree-rt-card h3,
.arttree-rt.arttree-combined-page .arttree-rt-card h3,
.arttree-rt.arttree-portal-page .arttree-rt-faq h3,
.arttree-rt.arttree-applicant-portal .arttree-rt-faq h3,
.arttree-rt.arttree-training-page .arttree-rt-faq h3,
.arttree-rt.arttree-jobs-page .arttree-rt-faq h3,
.arttree-rt.arttree-combined-page .arttree-rt-faq h3,
.arttree-rt.arttree-portal-page .arttree-rt-faq summary,
.arttree-rt.arttree-applicant-portal .arttree-rt-faq summary,
.arttree-rt.arttree-training-page .arttree-rt-faq summary,
.arttree-rt.arttree-jobs-page .arttree-rt-faq summary,
.arttree-rt.arttree-combined-page .arttree-rt-faq summary,
.arttree-gate-panel h3{
  color:#251c32 !important;
}
.arttree-rt.arttree-portal-page .arttree-portal-card p,
.arttree-rt.arttree-applicant-portal .arttree-portal-card p,
.arttree-rt.arttree-training-page .arttree-rt-card p,
.arttree-rt.arttree-jobs-page .arttree-rt-card p,
.arttree-rt.arttree-combined-page .arttree-rt-card p,
.arttree-rt.arttree-portal-page .arttree-rt-faq p,
.arttree-rt.arttree-applicant-portal .arttree-rt-faq p,
.arttree-rt.arttree-training-page .arttree-rt-faq p,
.arttree-rt.arttree-jobs-page .arttree-rt-faq p,
.arttree-rt.arttree-combined-page .arttree-rt-faq p,
.arttree-gate-panel p,
.arttree-gate-panel small{
  color:#6f6579 !important;
}
.arttree-rt.arttree-portal-page .arttree-rt-faq,
.arttree-rt.arttree-applicant-portal .arttree-rt-faq,
.arttree-rt.arttree-training-page .arttree-rt-faq,
.arttree-rt.arttree-jobs-page .arttree-rt-faq,
.arttree-rt.arttree-combined-page .arttree-rt-faq{
  width:min(1180px,calc(100% - 48px)) !important;
  max-width:1180px !important;
  margin:0 auto 82px !important;
}
.arttree-rt.arttree-portal-page .arttree-portal-shell,
.arttree-rt.arttree-applicant-portal .arttree-portal-shell,
.arttree-rt.arttree-portal-page .arttree-portal-sidebar,
.arttree-rt.arttree-applicant-portal .arttree-portal-sidebar,
.arttree-rt.arttree-portal-page .arttree-portal-content,
.arttree-rt.arttree-applicant-portal .arttree-portal-content,
.arttree-rt.arttree-portal-page .arttree-portal-panel,
.arttree-rt.arttree-applicant-portal .arttree-portal-panel,
.arttree-rt.arttree-portal-page .arttree-portal-mini-grid,
.arttree-rt.arttree-applicant-portal .arttree-portal-mini-grid{
  display:none !important;
}
@media(max-width:900px){
  .arttree-rt.arttree-portal-page .arttree-portal-hero,
  .arttree-rt.arttree-applicant-portal .arttree-portal-hero,
  .arttree-rt.arttree-training-page .arttree-rt-hero,
  .arttree-rt.arttree-jobs-page .arttree-rt-hero,
  .arttree-rt.arttree-combined-page .arttree-rt-hero{
    min-height:auto !important;
    padding:112px 18px 58px !important;
  }
  .arttree-rt.arttree-portal-page .arttree-rt-hero h2,
  .arttree-rt.arttree-applicant-portal .arttree-rt-hero h2,
  .arttree-rt.arttree-training-page .arttree-rt-hero h2,
  .arttree-rt.arttree-jobs-page .arttree-rt-hero h2,
  .arttree-rt.arttree-combined-page .arttree-rt-hero h2{
    font-size:40px !important;
    line-height:1.05 !important;
  }
  .arttree-rt.arttree-training-page .arttree-rt-hero h2,
  .arttree-rt.arttree-jobs-page .arttree-rt-hero h2,
  .arttree-rt.arttree-combined-page .arttree-rt-hero h2{
    font-size:44px !important;
  }
  .arttree-rt.arttree-portal-page .arttree-rt-hero p,
  .arttree-rt.arttree-applicant-portal .arttree-rt-hero p,
  .arttree-rt.arttree-training-page .arttree-rt-hero p,
  .arttree-rt.arttree-jobs-page .arttree-rt-hero p,
  .arttree-rt.arttree-combined-page .arttree-rt-hero p{
    font-size:18px !important;
  }
  .arttree-rt.arttree-portal-page .arttree-portal-public-grid,
  .arttree-rt.arttree-applicant-portal .arttree-portal-public-grid,
  .arttree-rt.arttree-training-page .arttree-rt-grid,
  .arttree-rt.arttree-jobs-page .arttree-rt-grid,
  .arttree-rt.arttree-combined-page .arttree-rt-grid{
    padding-left:16px !important;
    padding-right:16px !important;
  }
  .arttree-rt.arttree-portal-page .arttree-rt-faq,
  .arttree-rt.arttree-applicant-portal .arttree-rt-faq,
  .arttree-rt.arttree-training-page .arttree-rt-faq,
  .arttree-rt.arttree-jobs-page .arttree-rt-faq,
  .arttree-rt.arttree-combined-page .arttree-rt-faq{
    width:calc(100% - 32px) !important;
  }
}

/* v1.0.35 - complete applicant login/register portal */
.arttree-auth-grid{
  width:min(1180px,100%);
  margin:0 auto;
  padding:74px 24px 38px;
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:22px;
  box-sizing:border-box;
}
.arttree-auth-card{
  background:#fff;
  border:1px solid #e7dfd4;
  border-radius:32px;
  padding:28px;
  box-shadow:0 18px 58px rgba(37,28,50,.06);
  display:grid;
  gap:14px;
}
.arttree-auth-card > span{
  width:max-content;
  display:inline-flex;
  padding:7px 12px;
  border-radius:999px;
  background:rgba(80,61,122,.08);
  border:1px solid rgba(80,61,122,.14);
  color:#503d7a;
  font-size:13px;
  font-weight:900;
}
.arttree-auth-card h3{
  margin:0;
  color:#251c32;
  font-size:34px;
  line-height:1.2;
  font-weight:900;
}
.arttree-auth-card p{
  margin:0;
  color:#6f6579;
  font-size:16px;
  line-height:1.8;
}
.arttree-auth-card label{
  display:grid;
  gap:8px;
  color:#3b314c;
  font-size:14px;
  font-weight:800;
}
.arttree-auth-card input{
  width:100%;
  border:1px solid #e7dfd4;
  border-radius:16px;
  padding:13px 14px;
  background:#fbfaf6;
  color:#251c32;
  font:inherit;
  outline:none;
}
.arttree-auth-card input:focus{
  border-color:rgba(80,61,122,.45);
  box-shadow:0 0 0 4px rgba(80,61,122,.08);
}
.arttree-auth-card button{
  border:1px solid #503d7a;
  background:#503d7a;
  color:#fff;
  min-height:48px;
  border-radius:999px;
  padding:12px 20px;
  font:inherit;
  font-weight:900;
  cursor:pointer;
  transition:transform .2s ease,opacity .2s ease;
}
.arttree-auth-card button:hover{transform:translateY(-2px);opacity:.94}
.arttree-demo-users{
  border:1px dashed rgba(80,61,122,.25);
  background:rgba(80,61,122,.05);
  border-radius:20px;
  padding:14px;
  color:#6f6579;
  font-size:14px;
  line-height:1.7;
}
.arttree-demo-users strong{display:block;color:#251c32;margin-bottom:4px}
.arttree-demo-users p{font-size:14px;line-height:1.75;margin:0 0 6px;color:#6f6579}
.arttree-demo-users small{color:#503d7a;font-weight:900}
.arttree-portal-notice,.arttree-portal-error{
  width:min(1180px,calc(100% - 48px));
  margin:96px auto 0;
  border-radius:18px;
  padding:14px 18px;
  font-size:15px;
  font-weight:800;
}
.arttree-portal-notice{background:rgba(32,122,74,.09);border:1px solid rgba(32,122,74,.18);color:#207a4a}
.arttree-portal-error{background:rgba(169,61,61,.09);border:1px solid rgba(169,61,61,.18);color:#a93d3d}
.arttree-dashboard-shell{
  width:min(1180px,100%);
  margin:0 auto;
  padding:74px 24px 88px;
  display:grid;
  grid-template-columns:280px 1fr;
  gap:22px;
  box-sizing:border-box;
}
.arttree-dashboard-sidebar{
  position:sticky;
  top:96px;
  align-self:start;
  display:grid;
  gap:8px;
  background:#fff;
  border:1px solid #e7dfd4;
  border-radius:28px;
  padding:20px;
  box-shadow:0 18px 58px rgba(37,28,50,.06);
}
.arttree-dashboard-sidebar strong{
  font-size:22px;
  color:#251c32;
  margin-bottom:8px;
}
.arttree-dashboard-sidebar a{
  text-decoration:none;
  color:#6f6579;
  border:1px solid transparent;
  border-radius:16px;
  padding:11px 13px;
  font-size:15px;
  font-weight:900;
  transition:background .2s ease,color .2s ease,border-color .2s ease,transform .2s ease;
}
.arttree-dashboard-sidebar a:hover{
  color:#251c32;
  background:rgba(80,61,122,.07);
  border-color:rgba(80,61,122,.12);
  transform:translateX(-2px);
}
.arttree-dashboard-content{display:grid;gap:18px}
.arttree-dashboard-panel{
  background:#fff;
  border:1px solid #e7dfd4;
  border-radius:30px;
  padding:28px;
  box-shadow:0 18px 58px rgba(37,28,50,.06);
}
.arttree-dashboard-panel.hero-panel{
  background:linear-gradient(135deg,rgba(80,61,122,.10),rgba(200,169,106,.10)),#fff;
}
.arttree-dashboard-panel > span{
  display:inline-flex;
  padding:7px 12px;
  border-radius:999px;
  background:rgba(80,61,122,.08);
  color:#503d7a;
  font-size:13px;
  font-weight:900;
  margin-bottom:10px;
}
.arttree-dashboard-panel h3{
  margin:0 0 10px;
  color:#251c32;
  font-size:34px;
  line-height:1.25;
  font-weight:900;
}
.arttree-dashboard-panel p{
  margin:0;
  color:#6f6579;
  font-size:16px;
  line-height:1.8;
}
.arttree-dashboard-stats{
  margin-top:20px;
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
}
.arttree-dashboard-stats b{
  display:grid;
  gap:6px;
  background:#fff;
  border:1px solid #e7dfd4;
  border-radius:20px;
  padding:18px;
  color:#503d7a;
  font-size:28px;
}
.arttree-dashboard-stats small{font-size:13px;color:#6f6579;font-weight:800}
.arttree-profile-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  margin-top:12px;
}
.arttree-profile-grid p{
  background:#fbfaf6;
  border:1px solid #e7dfd4;
  border-radius:18px;
  padding:14px;
}
.arttree-profile-grid strong{display:block;color:#251c32;margin-bottom:6px}
.arttree-request-list{display:grid;gap:10px;margin-top:12px}
.arttree-request-list article{
  display:grid;
  grid-template-columns:1fr auto auto;
  align-items:center;
  gap:12px;
  border:1px solid #e7dfd4;
  background:#fbfaf6;
  border-radius:18px;
  padding:14px;
}
.arttree-request-list strong{color:#251c32;font-size:16px}
.arttree-request-list span{
  color:#207a4a;
  background:rgba(32,122,74,.08);
  border:1px solid rgba(32,122,74,.18);
  border-radius:999px;
  padding:6px 10px;
  font-size:13px;
  font-weight:900;
}
.arttree-request-list small{color:#6f6579;font-size:13px}
.arttree-empty-state{
  background:#fbfaf6;
  border:1px dashed #e7dfd4;
  border-radius:18px;
  padding:16px;
  color:#6f6579;
}
@media(max-width:900px){
  .arttree-auth-grid{grid-template-columns:1fr;padding:44px 16px 28px}
  .arttree-auth-card{padding:22px;border-radius:24px}
  .arttree-auth-card h3{font-size:28px}
  .arttree-dashboard-shell{grid-template-columns:1fr;padding:44px 16px 64px}
  .arttree-dashboard-sidebar{position:relative;top:auto;display:flex;overflow-x:auto;border-radius:22px}
  .arttree-dashboard-sidebar strong,.arttree-dashboard-sidebar a{min-width:max-content}
  .arttree-dashboard-panel{padding:22px;border-radius:24px}
  .arttree-dashboard-panel h3{font-size:28px}
  .arttree-dashboard-stats,.arttree-profile-grid{grid-template-columns:1fr}
  .arttree-request-list article{grid-template-columns:1fr}
}


/* v1.0.36 - applicant dashboard collapsible sidebar with clean SVG icons */
.arttree-dashboard-shell{
  position:relative;
  transition:grid-template-columns .28s ease,gap .28s ease;
}
.arttree-dashboard-toggle{
  position:absolute;
  top:24px;
  inset-inline-start:24px;
  z-index:3;
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid #e7dfd4;
  background:#fff;
  color:#251c32;
  border-radius:999px;
  padding:9px 13px;
  font-family:inherit;
  font-size:14px;
  font-weight:900;
  cursor:pointer;
  box-shadow:0 14px 38px rgba(37,28,50,.08);
  transition:background .2s ease,border-color .2s ease,transform .2s ease;
}
.arttree-dashboard-toggle:hover{background:#fbfaf6;border-color:rgba(80,61,122,.22);transform:translateY(-1px)}
.arttree-dashboard-toggle-icon{width:18px;height:18px;display:inline-block;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h16'/%3E%3Cpath d='M4 12h16'/%3E%3Cpath d='M4 18h16'/%3E%3C/svg%3E") center/contain no-repeat;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h16'/%3E%3Cpath d='M4 12h16'/%3E%3Cpath d='M4 18h16'/%3E%3C/svg%3E") center/contain no-repeat}
.arttree-dashboard-sidebar{
  overflow:hidden;
  transition:opacity .24s ease,transform .24s ease,max-width .28s ease,padding .28s ease,border-width .28s ease;
}
.arttree-dashboard-sidebar a{
  display:flex;
  align-items:center;
  gap:10px;
}
.arttree-dashboard-sidebar a span:last-child{min-width:0}
.arttree-dash-icon{
  flex:0 0 auto;
  width:22px;
  height:22px;
  color:#503d7a;
  background:currentColor;
  opacity:.95;
  mask-position:center;
  mask-repeat:no-repeat;
  mask-size:contain;
  -webkit-mask-position:center;
  -webkit-mask-repeat:no-repeat;
  -webkit-mask-size:contain;
}
.arttree-dash-icon-home{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 11 9-8 9 8'/%3E%3Cpath d='M5 10v10h14V10'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 11 9-8 9 8'/%3E%3Cpath d='M5 10v10h14V10'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E")}
.arttree-dash-icon-user{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c1.8-4 5-6 8-6s6.2 2 8 6'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c1.8-4 5-6 8-6s6.2 2 8 6'/%3E%3C/svg%3E")}
.arttree-dash-icon-briefcase{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='7' width='18' height='13' rx='2'/%3E%3Cpath d='M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3Cpath d='M3 12h18'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='7' width='18' height='13' rx='2'/%3E%3Cpath d='M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3Cpath d='M3 12h18'/%3E%3C/svg%3E")}
.arttree-dash-icon-scale{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v18'/%3E%3Cpath d='M5 7h14'/%3E%3Cpath d='M6 7l-3 6h6L6 7Z'/%3E%3Cpath d='M18 7l-3 6h6l-3-6Z'/%3E%3Cpath d='M8 21h8'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v18'/%3E%3Cpath d='M5 7h14'/%3E%3Cpath d='M6 7l-3 6h6L6 7Z'/%3E%3Cpath d='M18 7l-3 6h6l-3-6Z'/%3E%3Cpath d='M8 21h8'/%3E%3C/svg%3E")}
.arttree-dash-icon-calendar{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v4'/%3E%3Cpath d='M16 3v4'/%3E%3Cpath d='M3 11h18'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v4'/%3E%3Cpath d='M16 3v4'/%3E%3Cpath d='M3 11h18'/%3E%3C/svg%3E")}
.arttree-dash-icon-settings{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.9-.3 1.7 1.7 0 0 0-1 1.6v.2a2 2 0 1 1-4 0V21a1.7 1.7 0 0 0-1-1.6 1.7 1.7 0 0 0-1.9.3l-.1.1A2 2 0 1 1 4.2 17l.1-.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0-1.6-1H3a2 2 0 1 1 0-4h.2a1.7 1.7 0 0 0 1.6-1 1.7 1.7 0 0 0-.3-1.9L4.4 7A2 2 0 1 1 7.2 4.2l.1.1a1.7 1.7 0 0 0 1.9.3 1.7 1.7 0 0 0 1-1.6V3a2 2 0 1 1 4 0v.2a1.7 1.7 0 0 0 1 1.6 1.7 1.7 0 0 0 1.9-.3l.1-.1A2 2 0 1 1 19.8 7l-.1.1a1.7 1.7 0 0 0-.3 1.9 1.7 1.7 0 0 0 1.6 1h.2a2 2 0 1 1 0 4H21a1.7 1.7 0 0 0-1.6 1Z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.9-.3 1.7 1.7 0 0 0-1 1.6v.2a2 2 0 1 1-4 0V21a1.7 1.7 0 0 0-1-1.6 1.7 1.7 0 0 0-1.9.3l-.1.1A2 2 0 1 1 4.2 17l.1-.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0-1.6-1H3a2 2 0 1 1 0-4h.2a1.7 1.7 0 0 0 1.6-1 1.7 1.7 0 0 0-.3-1.9L4.4 7A2 2 0 1 1 7.2 4.2l.1.1a1.7 1.7 0 0 0 1.9.3 1.7 1.7 0 0 0 1-1.6V3a2 2 0 1 1 4 0v.2a1.7 1.7 0 0 0 1 1.6 1.7 1.7 0 0 0 1.9-.3l.1-.1A2 2 0 1 1 19.8 7l-.1.1a1.7 1.7 0 0 0-.3 1.9 1.7 1.7 0 0 0 1.6 1h.2a2 2 0 1 1 0 4H21a1.7 1.7 0 0 0-1.6 1Z'/%3E%3C/svg%3E")}
.arttree-dash-icon-logout{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 17l5-5-5-5'/%3E%3Cpath d='M15 12H3'/%3E%3Cpath d='M21 3v18'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 17l5-5-5-5'/%3E%3Cpath d='M15 12H3'/%3E%3Cpath d='M21 3v18'/%3E%3C/svg%3E")}
.arttree-dashboard-shell.is-sidebar-hidden{grid-template-columns:1fr}
.arttree-dashboard-shell.is-sidebar-hidden .arttree-dashboard-sidebar{opacity:0;transform:translateX(16px);max-width:0;padding:0;border-width:0;pointer-events:none}
.arttree-dashboard-shell.is-sidebar-hidden .arttree-dashboard-content{grid-column:1/-1}
.arttree-dashboard-shell.is-sidebar-hidden .arttree-dashboard-toggle span:last-child{font-size:0}
.arttree-dashboard-shell.is-sidebar-hidden .arttree-dashboard-toggle:after{content:'إظهار القائمة';font-size:14px}
@media(max-width:900px){
  .arttree-dashboard-toggle{position:relative;top:auto;inset-inline-start:auto;margin:0 16px -24px;z-index:4}
  .arttree-dashboard-shell{padding-top:36px}
  .arttree-dashboard-shell.is-sidebar-hidden .arttree-dashboard-sidebar{display:none}
  .arttree-dashboard-sidebar a{min-width:max-content}
  .arttree-dash-icon{width:20px;height:20px}
}

/* v1.0.37 - applicant users are portal-only and cannot access wp-admin */

/* v1.0.39 - portal frontend keeps applicant toolbar hidden through PHP filters */


/* v1.0.39 - single job details */
.arttree-single-job{
  background:#fbfaf6 !important;
  color:#17130c !important;
  padding-bottom:80px !important;
}
.arttree-single-job .arttree-single-job-hero{
  max-width:980px;
  padding-top:120px;
  padding-bottom:52px;
}
.arttree-job-detail-wrap{
  width:min(1180px, calc(100% - 40px));
  margin:0 auto;
  display:grid;
  grid-template-columns:minmax(0, 1fr) 360px;
  gap:24px;
  align-items:start;
}
.arttree-job-detail-main,
.arttree-job-detail-side{
  background:#fff;
  border:1px solid rgba(23,19,12,.1);
  border-radius:28px;
  box-shadow:0 20px 60px rgba(23,19,12,.08);
  padding:28px;
}
.arttree-job-detail-main h3,
.arttree-job-detail-side h3{
  margin:0 0 18px;
  font-size:28px;
  line-height:1.35;
  color:#17130c;
  font-weight:900;
}
.arttree-job-content{
  color:#4c4435;
  font-size:18px;
  line-height:2;
}
.arttree-job-content p{margin:0 0 16px}
.arttree-job-content ul,
.arttree-job-content ol{padding-inline-start:24px;margin:0 0 18px}
.arttree-job-detail-side dl{margin:0 0 22px;display:grid;gap:12px}
.arttree-job-detail-side dl div{
  display:flex;
  justify-content:space-between;
  gap:16px;
  padding:14px 0;
  border-bottom:1px solid rgba(23,19,12,.08);
}
.arttree-job-detail-side dt{font-size:14px;color:#8a7b63;font-weight:700}
.arttree-job-detail-side dd{margin:0;font-size:16px;color:#17130c;font-weight:800;text-align:left}
.arttree-job-apply-wide{width:100%;justify-content:center;text-align:center}
@media(max-width:900px){
  .arttree-single-job .arttree-single-job-hero{padding-top:96px}
  .arttree-job-detail-wrap{grid-template-columns:1fr;width:min(100% - 28px, 680px)}
  .arttree-job-detail-main,
  .arttree-job-detail-side{padding:22px;border-radius:22px}
}


/* v1.0.40 - Single training/workshop details page */
.arttree-single-program {
    background: #f7f4ed;
    color: #17201b;
}
.arttree-program-hero {
    padding: 150px 24px 72px;
    background:
        radial-gradient(circle at 20% 20%, rgba(169, 132, 78, .18), transparent 32%),
        linear-gradient(180deg, #f7f4ed 0%, #efe8dc 100%);
    text-align: center;
}
.arttree-program-wrap {
    max-width: 980px;
    margin: 0 auto;
}
.arttree-back-link {
    display: inline-flex;
    margin-bottom: 22px;
    color: #8a6a3f;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
}
.arttree-program-hero h1 {
    margin: 12px auto 18px;
    max-width: 900px;
    font-size: clamp(42px, 6vw, 78px);
    line-height: 1.05;
    letter-spacing: 0;
}
.arttree-program-hero p {
    max-width: 760px;
    margin: 0 auto;
    font-size: 20px;
    line-height: 1.9;
    color: #4a514d;
}
.arttree-program-actions {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 32px;
}
.arttree-program-details {
    max-width: 1180px;
    margin: 0 auto;
    padding: 70px 24px 100px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: start;
}
.arttree-program-main {
    display: grid;
    gap: 22px;
}
.arttree-program-content,
.arttree-program-info-card {
    background: rgba(255, 255, 255, .78);
    border: 1px solid rgba(23, 32, 27, .09);
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(24, 20, 14, .08);
}
.arttree-program-content {
    padding: 34px;
}
.arttree-program-content h2,
.arttree-program-info-card h3 {
    margin: 0 0 16px;
    font-size: 32px;
    line-height: 1.2;
}
.arttree-program-text,
.arttree-program-content p {
    font-size: 18px;
    line-height: 2;
    color: #454d49;
}
.arttree-topic-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 12px;
}
.arttree-topic-list li {
    position: relative;
    padding: 14px 44px 14px 16px;
    border-radius: 18px;
    background: #f7f4ed;
    font-size: 17px;
    color: #2c332f;
}
.arttree-topic-list li::before {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #a9844e;
    transform: translateY(-50%);
}
.arttree-program-side {
    position: sticky;
    top: 96px;
}
.arttree-program-info-card {
    padding: 28px;
}
.arttree-program-info-card dl {
    margin: 0;
    display: grid;
    gap: 12px;
}
.arttree-program-info-card dl div {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(23, 32, 27, .08);
}
.arttree-program-info-card dt {
    color: #6d746f;
    font-size: 14px;
    font-weight: 700;
}
.arttree-program-info-card dd {
    margin: 0;
    color: #18211c;
    font-size: 15px;
    font-weight: 800;
    text-align: left;
}
.arttree-program-full-btn {
    width: 100%;
    justify-content: center;
    margin-top: 24px;
}
@media (max-width: 900px) {
    .arttree-program-details {
        grid-template-columns: 1fr;
        padding-top: 42px;
    }
    .arttree-program-side {
        position: static;
    }
    .arttree-program-hero {
        padding-top: 120px;
    }
    .arttree-program-content h2,
    .arttree-program-info-card h3 {
        font-size: 26px;
    }
}


/* v1.0.41 - force Thmanyah on portal pages */
.arttree-rt,.arttree-rt *,.arttree-portal-page,.arttree-portal-page *,.arttree-training-page,.arttree-training-page *{
  font-family:'Thmanyah Sans','ThmanyahSans','Tahoma','Arial',sans-serif !important;
  font-synthesis:none;
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}

/* v1.0.42 - make single training/workshop details match the homepage visual system */
.arttree-program-detail-page,
.arttree-rt.arttree-program-detail-page{
  width:100% !important;
  max-width:none !important;
  margin:0 !important;
  padding:0 !important;
  border:0 !important;
  border-radius:0 !important;
  overflow:visible !important;
  background:#fbfaf6 !important;
  color:#15111d !important;
}
.arttree-program-detail-page .arttree-program-hero{
  padding:138px 0 84px !important;
  background:radial-gradient(circle at 15% 10%,rgba(80,61,122,.16),transparent 34%),linear-gradient(180deg,#fbfaf6,#f6f1e8) !important;
  text-align:right !important;
}
.arttree-program-hero-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) 390px;
  gap:44px;
  align-items:center;
}
.arttree-program-hero-copy h1{
  margin:0 0 24px;
  font-size:clamp(44px,6vw,88px);
  line-height:.98;
  font-weight:900;
  color:#15111d;
  text-wrap:balance;
}
.arttree-program-hero-copy p{
  margin:0 0 30px;
  max-width:760px;
  color:#6b6278;
  font-size:20px;
  line-height:1.8;
}
.arttree-program-detail-page .arttree-back-link{
  display:inline-flex;
  color:#503d7a;
  background:rgba(80,61,122,.08);
  border:1px solid rgba(80,61,122,.14);
  padding:8px 14px;
  border-radius:999px;
  margin:0 0 18px;
  font-size:14px;
  font-weight:900;
}
.arttree-program-detail-page .eyebrow{
  display:inline-flex;
  color:#503d7a !important;
  background:transparent !important;
  border:0 !important;
  padding:0 !important;
  margin-bottom:14px !important;
}
.arttree-program-detail-page .arttree-program-actions{
  justify-content:flex-start;
  margin-top:0;
}
.arttree-program-summary{
  background:rgba(255,255,255,.82);
  border:1px solid #e7dfd4;
  border-radius:30px;
  box-shadow:0 24px 70px rgba(34,24,52,.10);
  padding:28px;
}
.arttree-program-status{
  display:inline-flex;
  border-radius:999px;
  padding:8px 13px;
  font-size:13px;
  font-weight:900;
  margin-bottom:18px;
}
.arttree-program-status.open{background:rgba(32,122,74,.09);color:#207a4a;border:1px solid rgba(32,122,74,.20)}
.arttree-program-status.closed{background:rgba(169,61,61,.09);color:#a93d3d;border:1px solid rgba(169,61,61,.20)}
.arttree-program-summary-row{
  display:flex;
  justify-content:space-between;
  gap:16px;
  padding:15px 0;
  border-bottom:1px solid rgba(21,17,29,.08);
}
.arttree-program-summary-row:last-child{border-bottom:0}
.arttree-program-summary-row strong{font-size:14px;color:#6b6278;font-weight:800}
.arttree-program-summary-row span{font-size:16px;color:#15111d;font-weight:900;text-align:left}
.arttree-program-overview,
.arttree-program-body-section{background:#fbfaf6 !important;color:#15111d !important}
.arttree-program-body-section.muted{background:#f2efe8 !important}
.arttree-program-overview .section-head,
.arttree-program-body-section .section-head{text-align:right}
.arttree-program-info-grid.cards article,
.arttree-program-content.clean-card,
.arttree-program-info-card.clean-card{
  background:#fff !important;
  border:1px solid #e7dfd4 !important;
  border-radius:30px !important;
  box-shadow:0 24px 70px rgba(34,24,52,.10) !important;
  color:#15111d !important;
}
.arttree-program-info-grid.cards article h3{font-size:28px;color:#15111d;margin:0 0 10px;font-weight:900}
.arttree-program-info-grid.cards article p{font-size:16px;color:#6b6278;margin:0;line-height:1.8}
.arttree-program-detail-layout{
  display:grid;
  grid-template-columns:minmax(0,1fr) 380px;
  gap:28px;
  align-items:start;
}
.arttree-program-detail-page .arttree-program-main{display:grid;gap:22px}
.arttree-program-detail-page .arttree-program-content{padding:34px}
.arttree-program-detail-page .arttree-program-content h2,
.arttree-program-detail-page .arttree-program-info-card h3{
  margin:0 0 16px;
  color:#15111d;
  font-size:40px;
  line-height:1.18;
  font-weight:900;
}
.arttree-program-detail-page .arttree-program-text,
.arttree-program-detail-page .arttree-program-content p{
  font-size:18px;
  line-height:2;
  color:#5d5469;
}
.arttree-program-detail-page .arttree-topic-list{display:grid;gap:12px;margin:0;padding:0;list-style:none}
.arttree-program-detail-page .arttree-topic-list li{
  position:relative;
  background:#fbfaf6;
  border:1px solid #e7dfd4;
  border-radius:20px;
  color:#15111d;
  padding:15px 44px 15px 16px;
  font-size:17px;
  line-height:1.7;
}
.arttree-program-detail-page .arttree-topic-list li:before{
  content:'';
  position:absolute;
  right:18px;
  top:50%;
  width:10px;
  height:10px;
  border-radius:50%;
  background:#503d7a;
  transform:translateY(-50%);
}
.arttree-program-detail-page .arttree-program-side{position:sticky;top:102px}
.arttree-program-detail-page .arttree-program-info-card{padding:28px}
.arttree-program-detail-page .arttree-program-info-card dl{margin:0;display:grid;gap:0}
.arttree-program-detail-page .arttree-program-info-card dl div{
  display:flex;
  justify-content:space-between;
  gap:16px;
  padding:14px 0;
  border-bottom:1px solid rgba(21,17,29,.08);
}
.arttree-program-detail-page .arttree-program-info-card dl div:last-child{border-bottom:0}
.arttree-program-detail-page .arttree-program-info-card dt{font-size:14px;color:#6b6278;font-weight:800}
.arttree-program-detail-page .arttree-program-info-card dd{margin:0;font-size:16px;color:#15111d;font-weight:900;text-align:left}
.arttree-program-detail-page .arttree-program-full-btn{width:100%;margin-top:22px;text-align:center;justify-content:center}
@media(max-width:900px){
  .arttree-program-detail-page .arttree-program-hero{padding:118px 0 56px !important;text-align:center !important}
  .arttree-program-hero-grid{grid-template-columns:1fr;gap:24px;width:min(100% - 28px,680px)}
  .arttree-program-hero-copy h1{font-size:44px;text-align:center}
  .arttree-program-hero-copy p{text-align:center;font-size:18px}
  .arttree-program-detail-page .arttree-program-actions{justify-content:center}
  .arttree-program-summary{padding:22px;border-radius:24px}
  .arttree-program-detail-layout{grid-template-columns:1fr;width:min(100% - 28px,680px)}
  .arttree-program-detail-page .arttree-program-side{position:static}
  .arttree-program-detail-page .arttree-program-content{padding:24px;border-radius:24px}
  .arttree-program-detail-page .arttree-program-content h2,
  .arttree-program-detail-page .arttree-program-info-card h3{font-size:32px}
  .arttree-program-detail-page .arttree-program-text,
  .arttree-program-detail-page .arttree-program-content p{font-size:16px}
}


/* v1.0.63 - workshop QR scanner and supervisor check-in */
.arttree-checkin-page{background:#fbfaf6;color:#251c32;border:0;border-radius:0;max-width:none;width:100vw;margin:0 calc(50% - 50vw)}
.arttree-checkin-page .arttree-rt-hero{max-width:none;text-align:right;align-items:flex-start;padding:132px max(24px,calc((100vw - 1180px)/2)) 72px;background:linear-gradient(180deg,#fbfaf6,#f7f2ea);border-bottom:1px solid #e7dfd4}
.arttree-checkin-page .arttree-rt-hero:before{display:none}
.arttree-checkin-page .arttree-rt-hero h2{font-size:64px;line-height:1.05;color:#251c32;max-width:900px}
.arttree-checkin-page .arttree-rt-hero p{font-size:20px;color:#6f6579;max-width:780px;margin:0}
.arttree-checkin-grid{max-width:1180px;margin:0 auto;padding:60px 24px 90px;display:grid;grid-template-columns:1fr 1fr;gap:22px}
.arttree-checkin-card,.arttree-checkin-result{background:#fff;border:1px solid #e7dfd4;border-radius:30px;padding:30px;box-shadow:0 14px 42px rgba(34,24,52,.06);max-width:1180px;margin:34px auto 0;color:#251c32}
.arttree-checkin-card h3{font-size:30px;margin:0 0 12px;color:#251c32}.arttree-checkin-card p{color:#6f6579;font-size:16px;line-height:1.8}.arttree-checkin-card label{display:grid;gap:8px;color:#6f6579;font-weight:800}.arttree-checkin-card input{border:1px solid #e7dfd4;border-radius:16px;padding:14px 16px;font:inherit;color:#251c32;background:#fbfaf6}.arttree-checkin-card button{margin-top:14px;margin-inline-end:8px}.arttree-camera-box{position:relative;overflow:hidden;border-radius:24px;background:#17111f;min-height:320px;border:1px solid #e7dfd4;margin:18px 0}.arttree-camera-box video{width:100%;height:320px;object-fit:cover;display:block}.arttree-camera-box div{position:absolute;left:16px;right:16px;bottom:16px;background:rgba(0,0,0,.58);color:#fff;border-radius:14px;padding:10px 12px;font-size:14px}.arttree-checkin-result{padding:24px 30px}.arttree-checkin-result.success{border-color:rgba(32,122,74,.28);background:rgba(32,122,74,.06)}.arttree-checkin-result.already{border-color:rgba(184,148,77,.32);background:rgba(184,148,77,.08)}.arttree-checkin-result.error{border-color:rgba(169,61,61,.28);background:rgba(169,61,61,.06)}.arttree-checkin-result strong{font-size:22px}.arttree-checkin-details{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:18px}.arttree-checkin-details p{margin:0;background:#fff;border:1px solid #e7dfd4;border-radius:18px;padding:14px;color:#251c32}.arttree-checkin-details span{display:block;color:#6f6579;font-size:13px;font-weight:900;margin-bottom:5px}.arttree-checkin-details code{direction:ltr;display:inline-block;white-space:normal}
@media(max-width:900px){.arttree-checkin-page .arttree-rt-hero{padding:104px 18px 54px}.arttree-checkin-page .arttree-rt-hero h2{font-size:40px}.arttree-checkin-grid{grid-template-columns:1fr;padding:38px 18px 70px}.arttree-checkin-details{grid-template-columns:1fr}.arttree-checkin-card,.arttree-checkin-result{margin-inline:18px}.arttree-camera-box,.arttree-camera-box video{min-height:260px;height:260px}}


/* v1.0.64 - mobile scanner fallback and flat system pages */
.arttree-flat-system-page .arttree-checkin-card,
.arttree-flat-system-page .arttree-rt-form,
.arttree-flat-system-page .arttree-system-card{
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
  border-radius:0 !important;
  padding:0 !important;
}
.arttree-checkin-page .arttree-checkin-grid{align-items:start;gap:52px}
.arttree-checkin-page .arttree-checkin-card{max-width:none;margin:0;color:#251c32}
.arttree-checkin-page .arttree-checkin-result{box-shadow:none;border:0;border-radius:24px}
.arttree-camera-box [data-arttree-html5-reader]{display:none;min-height:320px;background:#17111f;color:#fff}
.arttree-camera-box [data-arttree-html5-reader] video{border-radius:24px}
.arttree-camera-box [data-arttree-html5-reader] button,
.arttree-camera-box [data-arttree-html5-reader] select{font-family:inherit !important}
.arttree-camera-box [data-arttree-html5-reader] a{color:#fff !important}
@media(max-width:900px){
  .arttree-checkin-page .arttree-checkin-grid{gap:40px}
  .arttree-camera-box [data-arttree-html5-reader]{min-height:260px}
}


/* v1.0.65 - remove outer cards for workshop scanner and future generated system pages */
.arttree-fullwidth-page,
.arttree-fullwidth-page .arttree-rt,
.arttree-flat-system-page,
.arttree-checkin-page{
  background:#fbfaf6 !important;
  border:0 !important;
  box-shadow:none !important;
  border-radius:0 !important;
}
.arttree-fullwidth-page .post-card,
.arttree-fullwidth-page article,
.arttree-flat-system-page .post-card,
.arttree-flat-system-page article{
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
  border-radius:0 !important;
  padding:0 !important;
}
.arttree-checkin-page .arttree-checkin-card,
.arttree-checkin-page form.arttree-checkin-card,
.arttree-checkin-page .arttree-checkin-result{
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
  border-radius:0 !important;
}
.arttree-checkin-page .arttree-checkin-result.success,
.arttree-checkin-page .arttree-checkin-result.already,
.arttree-checkin-page .arttree-checkin-result.error{
  background:transparent !important;
  border:0 !important;
}
.arttree-checkin-page .arttree-checkin-details p{
  box-shadow:none !important;
}

/* v1.0.66 - remove full-width system page outer frame completely */
.arttree-fullwidth-page{
  width:100% !important;
  max-width:none !important;
  margin:0 !important;
  padding:0 !important;
  background:#fbfaf6 !important;
  border:0 !important;
  box-shadow:none !important;
  border-radius:0 !important;
  overflow:visible !important;
}
.arttree-fullwidth-page > .arttree-rt,
.arttree-fullwidth-page .arttree-rt.arttree-flat-system-page,
.arttree-fullwidth-page .arttree-checkin-page,
.arttree-flat-system-page,
.arttree-checkin-page{
  width:100% !important;
  max-width:none !important;
  min-width:0 !important;
  margin:0 !important;
  padding:0 !important;
  background:#fbfaf6 !important;
  border:0 !important;
  outline:0 !important;
  box-shadow:none !important;
  border-radius:0 !important;
  overflow:visible !important;
}
.arttree-fullwidth-page > .arttree-rt::before,
.arttree-fullwidth-page > .arttree-rt::after,
.arttree-flat-system-page::before,
.arttree-flat-system-page::after,
.arttree-checkin-page::before,
.arttree-checkin-page::after{
  display:none !important;
  content:none !important;
}
.arttree-fullwidth-page .arttree-rt-hero,
.arttree-flat-system-page .arttree-rt-hero,
.arttree-checkin-page .arttree-rt-hero{
  width:min(1180px,calc(100% - 44px)) !important;
  max-width:1180px !important;
  margin-inline:auto !important;
  border:0 !important;
  box-shadow:none !important;
  background:transparent !important;
}
.arttree-fullwidth-page .arttree-checkin-grid,
.arttree-flat-system-page .arttree-checkin-grid,
.arttree-checkin-page .arttree-checkin-grid{
  width:min(1180px,calc(100% - 44px)) !important;
  max-width:1180px !important;
  margin-inline:auto !important;
  border:0 !important;
  box-shadow:none !important;
  background:transparent !important;
}
.arttree-fullwidth-page .arttree-checkin-card,
.arttree-fullwidth-page form.arttree-checkin-card,
.arttree-fullwidth-page .arttree-checkin-result,
.arttree-flat-system-page .arttree-checkin-card,
.arttree-flat-system-page form.arttree-checkin-card,
.arttree-flat-system-page .arttree-checkin-result,
.arttree-checkin-page .arttree-checkin-card,
.arttree-checkin-page form.arttree-checkin-card,
.arttree-checkin-page .arttree-checkin-result{
  border:0 !important;
  box-shadow:none !important;
  background:transparent !important;
  border-radius:0 !important;
  outline:0 !important;
}
@media(max-width:900px){
  .arttree-fullwidth-page .arttree-rt-hero,
  .arttree-flat-system-page .arttree-rt-hero,
  .arttree-checkin-page .arttree-rt-hero,
  .arttree-fullwidth-page .arttree-checkin-grid,
  .arttree-flat-system-page .arttree-checkin-grid,
  .arttree-checkin-page .arttree-checkin-grid{
    width:min(100% - 30px,1180px) !important;
  }
}


/* v1.0.67 - supervisor registrations table and colored barcode states */
.arttree-checkin-page .arttree-checkin-result{
  padding:22px 26px !important;
  margin:26px auto 0 !important;
  width:min(1180px,calc(100% - 44px)) !important;
  border-radius:22px !important;
  border:1px solid transparent !important;
  box-shadow:none !important;
}
.arttree-checkin-page .arttree-checkin-result.success{
  background:#eaf7ef !important;
  border-color:#9bd3b0 !important;
  color:#17623a !important;
}
.arttree-checkin-page .arttree-checkin-result.already{
  background:#fff7dd !important;
  border-color:#e9cf75 !important;
  color:#7a5a00 !important;
}
.arttree-checkin-page .arttree-checkin-result.error{
  background:#fdecec !important;
  border-color:#e6aaaa !important;
  color:#8d2727 !important;
}
.arttree-checkin-table-wrap{
  width:min(1180px,calc(100% - 44px));
  margin:0 auto 90px;
  background:transparent;
  border:0;
  box-shadow:none;
  color:#251c32;
}
.arttree-checkin-table-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:18px;
  margin-bottom:18px;
}
.arttree-checkin-table-head span{display:block;color:#6f6579;font-weight:900;margin-bottom:6px}
.arttree-checkin-table-head h3{margin:0;font-size:34px;line-height:1.2;color:#251c32}
.arttree-checkin-table-head p{margin:8px 0 0;color:#6f6579}
.arttree-checkin-table-head strong{background:#fff;border:1px solid #e7dfd4;border-radius:999px;padding:10px 16px;color:#503d7a;white-space:nowrap}
.arttree-checkin-table-scroll{overflow:auto;border:1px solid #e7dfd4;border-radius:24px;background:#fff}
.arttree-checkin-table{width:100%;border-collapse:separate;border-spacing:0;min-width:900px;direction:rtl}
.arttree-checkin-table th,.arttree-checkin-table td{padding:16px 14px;text-align:right;border-bottom:1px solid #eee8de;vertical-align:middle;font-size:14px}
.arttree-checkin-table th{background:#f7f2ea;color:#6f6579;font-weight:900;position:sticky;top:0;z-index:1}
.arttree-checkin-table tbody tr:last-child td{border-bottom:0}
.arttree-checkin-table tbody tr.is-attended{background:#f3fbf6}
.arttree-checkin-table tbody tr.is-pending{background:#fffdf4}
.arttree-checkin-table code{direction:ltr;display:inline-block;background:#fbfaf6;border:1px solid #e7dfd4;border-radius:10px;padding:6px 8px;font-size:12px;color:#251c32}
.arttree-checkin-status-pill{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;padding:7px 11px;font-weight:900;font-size:12px;white-space:nowrap}
.arttree-checkin-status-pill.attended{background:#dff3e7;color:#17623a;border:1px solid #9bd3b0}
.arttree-checkin-status-pill.pending{background:#fff1bf;color:#7a5a00;border:1px solid #e9cf75}
@media(max-width:900px){
  .arttree-checkin-page .arttree-checkin-result,
  .arttree-checkin-table-wrap{width:min(100% - 30px,1180px)}
  .arttree-checkin-table-head{display:block}
  .arttree-checkin-table-head h3{font-size:28px}
  .arttree-checkin-table-head strong{display:inline-block;margin-top:14px}
}

/* v1.0.72 applicant workshop detail pages */
.arttree-workshop-overview-list{display:grid;gap:18px;margin-top:22px}.arttree-workshop-overview-card{display:grid;grid-template-columns:1fr auto;gap:18px;align-items:center;padding:22px;border:1px solid rgba(80,61,122,.14);border-radius:24px;background:#fff}.arttree-workshop-overview-card h4{margin:10px 0 0;color:#251a3d;font-size:22px}.arttree-workshop-compact-meta{display:flex;flex-wrap:wrap;gap:10px;margin-top:12px}.arttree-workshop-compact-meta span{background:#f6f2fb;border-radius:999px;padding:8px 12px;font-size:13px;color:#4d3a74}.arttree-workshop-status{display:inline-flex;border-radius:999px;padding:7px 12px;font-size:12px;font-weight:800}.arttree-workshop-status.done{background:#e8f7ef;color:#167345}.arttree-workshop-status.pending{background:#fff7dc;color:#936a00}.arttree-workshop-status.registered{background:#eef0ff;color:#46349a}.arttree-workshop-detail-page{display:grid;gap:22px}.arttree-workshop-detail-head{padding:22px;border-radius:24px;background:linear-gradient(135deg,#503d7a,#7656aa);color:#fff}.arttree-workshop-detail-head a{display:inline-flex;margin-bottom:14px;color:#fff;text-decoration:underline}.arttree-workshop-detail-head h4{margin:0 0 8px;font-size:28px}.arttree-workshop-detail-head p{margin:0;color:rgba(255,255,255,.84)}.arttree-workshop-detail-grid{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(260px,.7fr);gap:18px}.arttree-workshop-info-panel,.arttree-workshop-ticket-panel,.arttree-evaluation-summary{background:#fff;border:1px solid rgba(80,61,122,.12);border-radius:24px;padding:22px}.arttree-workshop-info-panel h5,.arttree-workshop-ticket-panel h5,.arttree-evaluation-summary h5{margin:0 0 16px;color:#251a3d;font-size:20px}.arttree-workshop-info-list,.arttree-evaluation-summary-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.arttree-workshop-info-list p,.arttree-evaluation-summary-grid p,.arttree-evaluation-notes p{margin:0;background:#faf8fd;border-radius:18px;padding:14px}.arttree-workshop-info-list strong,.arttree-evaluation-summary-grid strong,.arttree-evaluation-notes strong{display:block;font-size:12px;color:#7a6b91;margin-bottom:6px}.arttree-workshop-info-list span,.arttree-evaluation-summary-grid span,.arttree-evaluation-notes span{display:block;color:#302146;font-weight:700}.arttree-workshop-ticket-panel{text-align:center}.arttree-workshop-ticket-panel img{width:180px;max-width:100%;border-radius:18px;background:#fff;padding:10px;border:1px solid rgba(80,61,122,.12)}.arttree-workshop-ticket-panel code{display:block;margin-top:12px;white-space:normal;word-break:break-word}.arttree-evaluation-notes{display:grid;gap:12px;margin-top:12px}.arttree-certificate-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px}.arttree-certificate-actions a{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:#503d7a;color:#fff;text-decoration:none;padding:10px 16px}.arttree-certificate-actions a+ a{background:#f1edf8;color:#503d7a}.arttree-cancel-registration-form{margin-top:4px}.arttree-cancel-registration-form button{background:#fff1f1!important;color:#a51616!important;border:1px solid #ffd3d3!important;border-radius:999px!important;padding:10px 18px!important;box-shadow:none!important}.arttree-workshop-evaluation{background:#fff;border:1px solid rgba(80,61,122,.12);border-radius:24px;padding:22px}@media(max-width:800px){.arttree-workshop-overview-card,.arttree-workshop-detail-grid{grid-template-columns:1fr}.arttree-workshop-info-list,.arttree-evaluation-summary-grid{grid-template-columns:1fr}.arttree-workshop-overview-card .arttree-details-btn{width:100%;justify-content:center}}


/* v1.0.73 - unify careers, training, workshops, and portal cards with site design */
.arttree-rt.arttree-jobs-page .arttree-rt-card,
.arttree-rt.arttree-training-page .arttree-rt-card,
.arttree-rt.arttree-combined-page .arttree-rt-card,
.arttree-rt.arttree-portal-page .arttree-portal-card,
.arttree-rt.arttree-applicant-portal .arttree-portal-card,
.arttree-workshop-overview-card,
.arttree-workshop-info-panel,
.arttree-workshop-ticket-panel,
.arttree-evaluation-summary,
.arttree-workshop-evaluation,
.arttree-program-info-grid.cards article,
.arttree-program-content.clean-card,
.arttree-program-info-card.clean-card{
  background:#fff !important;
  border:1px solid rgba(80,61,122,.13) !important;
  border-radius:32px !important;
  box-shadow:0 18px 48px rgba(34,24,52,.055) !important;
  overflow:hidden !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-card,
.arttree-rt.arttree-training-page .arttree-rt-card,
.arttree-rt.arttree-combined-page .arttree-rt-card,
.arttree-rt.arttree-portal-page .arttree-portal-card,
.arttree-rt.arttree-applicant-portal .arttree-portal-card,
.arttree-workshop-overview-card{
  padding:28px !important;
  min-height:100% !important;
  transition:transform .22s ease,border-color .22s ease,box-shadow .22s ease !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-card:hover,
.arttree-rt.arttree-training-page .arttree-rt-card:hover,
.arttree-rt.arttree-combined-page .arttree-rt-card:hover,
.arttree-rt.arttree-portal-page .arttree-portal-card:hover,
.arttree-rt.arttree-applicant-portal .arttree-portal-card:hover,
.arttree-workshop-overview-card:hover{
  transform:translateY(-6px) !important;
  border-color:rgba(80,61,122,.28) !important;
  box-shadow:0 24px 70px rgba(34,24,52,.09) !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-card h3,
.arttree-rt.arttree-training-page .arttree-rt-card h3,
.arttree-rt.arttree-combined-page .arttree-rt-card h3,
.arttree-rt.arttree-portal-page .arttree-portal-card h3,
.arttree-rt.arttree-applicant-portal .arttree-portal-card h3,
.arttree-workshop-overview-card h4{
  color:#251a3d !important;
  font-weight:900 !important;
  letter-spacing:-.02em !important;
}
.arttree-rt.arttree-jobs-page .arttree-rt-card p,
.arttree-rt.arttree-training-page .arttree-rt-card p,
.arttree-rt.arttree-combined-page .arttree-rt-card p,
.arttree-rt.arttree-portal-page .arttree-portal-card p,
.arttree-rt.arttree-applicant-portal .arttree-portal-card p,
.arttree-workshop-overview-card p{
  color:#6f6579 !important;
}
.arttree-workshop-compact-meta span,
.arttree-chip,
.arttree-tag{
  border-radius:999px !important;
  background:#f4effa !important;
  border:1px solid rgba(80,61,122,.09) !important;
  color:#503d7a !important;
}
.arttree-rt .arttree-rt-primary,
.arttree-rt .arttree-details-btn,
.arttree-workshop-overview-card .arttree-details-btn,
.arttree-certificate-actions a{
  border-radius:999px !important;
  box-shadow:0 12px 28px rgba(80,61,122,.16) !important;
}
.arttree-rt-card.is-closed,
.arttree-workshop-overview-card.is-closed{
  opacity:1 !important;
  filter:none !important;
  background:linear-gradient(180deg,#fff,#fbfaf6) !important;
}
@media(max-width:800px){
  .arttree-rt.arttree-jobs-page .arttree-rt-card,
  .arttree-rt.arttree-training-page .arttree-rt-card,
  .arttree-rt.arttree-combined-page .arttree-rt-card,
  .arttree-rt.arttree-portal-page .arttree-portal-card,
  .arttree-rt.arttree-applicant-portal .arttree-portal-card,
  .arttree-workshop-overview-card,
  .arttree-workshop-info-panel,
  .arttree-workshop-ticket-panel,
  .arttree-evaluation-summary,
  .arttree-workshop-evaluation{
    border-radius:24px !important;
    padding:22px !important;
  }
}


/* v1.0.74 - workshop detail action layout and locked cancellation */
.arttree-action-detail-page{
  display:grid;
  gap:22px;
}
.arttree-workshop-detail-head .arttree-workshop-status{
  display:inline-flex;
  margin-bottom:12px;
}
.arttree-workshop-action-bar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin:8px 0 2px;
}
.arttree-action-pill,
.arttree-inline-action{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:42px;
  padding:10px 18px;
  border-radius:999px;
  border:1px solid rgba(80,61,122,.18);
  background:#fff;
  color:#503d7a;
  font-weight:800;
  text-decoration:none;
  box-shadow:0 12px 28px rgba(43,34,58,.08);
  transition:transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.arttree-action-pill:hover,
.arttree-inline-action:hover{
  transform:translateY(-2px);
  box-shadow:0 18px 34px rgba(43,34,58,.12);
}
.arttree-action-pill.primary{
  background:#503d7a;
  color:#fff;
  border-color:#503d7a;
}
.arttree-action-panel{
  background:#fff;
  border:1px solid rgba(80,61,122,.12);
  border-radius:28px;
  box-shadow:0 18px 44px rgba(43,34,58,.08);
  padding:24px;
}
.arttree-ticket-action-panel{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:22px;
  align-items:center;
}
.arttree-ticket-box.large{
  min-width:230px;
  justify-content:center;
}
.arttree-ticket-box.large img{
  width:190px;
  height:190px;
}
.arttree-panel-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}
.arttree-workshop-info-list.action-list,
.arttree-evaluation-notes.action-list{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}
.arttree-workshop-info-list.action-list p,
.arttree-evaluation-notes.action-list p{
  margin:0;
  padding:14px 16px;
  border-radius:18px;
  background:#f8f6fb;
  border:1px solid rgba(80,61,122,.08);
}
.arttree-cancel-locked{
  display:inline-flex;
  align-items:center;
  width:fit-content;
  padding:12px 18px;
  border-radius:999px;
  background:#eef8f0;
  color:#166534;
  border:1px solid rgba(22,101,52,.18);
  font-weight:800;
}
.arttree-certificate-actions a{
  border-radius:999px;
}
@media(max-width:760px){
  .arttree-ticket-action-panel{
    grid-template-columns:1fr;
  }
  .arttree-workshop-info-list.action-list,
  .arttree-evaluation-notes.action-list{
    grid-template-columns:1fr;
  }
  .arttree-action-pill,
  .arttree-inline-action{
    width:100%;
  }
}

/* v1.0.75 - icon meta cards and Google Maps action */
.arttree-card-meta-icons{
  display:grid !important;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px !important;
  margin:14px 0 16px !important;
}
.arttree-card-meta-icons span{
  display:flex !important;
  align-items:center;
  gap:10px;
  border:1px solid rgba(80,61,122,.12) !important;
  background:#f8f5fc !important;
  border-radius:18px !important;
  padding:12px 13px !important;
  color:#34224e !important;
  min-width:0;
}
.arttree-card-meta-icons svg{
  width:22px;
  height:22px;
  flex:0 0 22px;
  fill:#503d7a;
}
.arttree-card-meta-icons b{
  display:block;
  color:#7b6b91;
  font-size:11px;
  line-height:1.2;
  margin-bottom:3px;
}
.arttree-card-meta-icons em{
  display:block;
  color:#251a3d;
  font-style:normal;
  font-size:13px;
  line-height:1.35;
  font-weight:800;
  white-space:normal;
  overflow-wrap:anywhere;
}
.arttree-map-card-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  width:100%;
  margin:0 0 14px;
  padding:11px 14px;
  border-radius:999px;
  background:#f1edf8;
  color:#503d7a !important;
  border:1px solid rgba(80,61,122,.16);
  text-decoration:none !important;
  font-size:14px;
  font-weight:900;
  transition:transform .2s ease,box-shadow .2s ease,background .2s ease;
}
.arttree-map-card-btn:hover{
  transform:translateY(-2px);
  background:#ece5f6;
  box-shadow:0 12px 28px rgba(80,61,122,.12);
}
.arttree-map-card-btn svg{
  width:20px;
  height:20px;
  fill:currentColor;
}
.arttree-workshop-overview-card .arttree-map-card-btn{
  margin:0;
}
@media(max-width:760px){
  .arttree-card-meta-icons{grid-template-columns:1fr !important;}
}

/* v1.0.76 - refined workshop/event cards and smaller icons */
.arttree-rt-card:has(.arttree-card-meta-icons),
.arttree-workshop-overview-card{
  position:relative !important;
  overflow:hidden !important;
  display:flex !important;
  flex-direction:column !important;
  gap:14px !important;
  padding:24px !important;
  border-radius:28px !important;
  border:1px solid rgba(80,61,122,.12) !important;
  background:linear-gradient(180deg,#fff 0%,#fcfbfe 100%) !important;
  box-shadow:0 18px 48px rgba(37,26,61,.07) !important;
}
.arttree-rt-card:has(.arttree-card-meta-icons)::before,
.arttree-workshop-overview-card::before{
  content:"";
  position:absolute;
  inset:0 0 auto 0;
  height:5px;
  background:linear-gradient(90deg,#503d7a,#bca7df);
  opacity:.82;
}
.arttree-rt-card:has(.arttree-card-meta-icons) .arttree-card-top,
.arttree-workshop-overview-card .arttree-card-top{
  margin-bottom:0 !important;
}
.arttree-rt-card:has(.arttree-card-meta-icons) h3,
.arttree-workshop-overview-card h4{
  margin:2px 0 0 !important;
  font-size:clamp(20px,2.1vw,25px) !important;
  line-height:1.35 !important;
}
.arttree-rt-card:has(.arttree-card-meta-icons) p,
.arttree-workshop-overview-card p{
  margin:0 !important;
  line-height:1.8 !important;
}
.arttree-card-meta-icons{
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  gap:8px !important;
  margin:4px 0 2px !important;
}
.arttree-card-meta-icons span{
  display:grid !important;
  grid-template-columns:18px minmax(0,1fr) !important;
  align-items:center !important;
  column-gap:8px !important;
  row-gap:2px !important;
  padding:10px 11px !important;
  border-radius:16px !important;
  background:#f8f5fc !important;
  min-height:58px !important;
}
.arttree-card-meta-icons svg{
  grid-row:1 / span 2;
  width:15px !important;
  height:15px !important;
  flex:0 0 15px !important;
  fill:#503d7a !important;
  opacity:.9 !important;
}
.arttree-card-meta-icons b{
  font-size:10px !important;
  line-height:1.1 !important;
  margin:0 !important;
  color:#847493 !important;
}
.arttree-card-meta-icons em{
  font-size:12.5px !important;
  line-height:1.35 !important;
  font-weight:850 !important;
}
.arttree-map-card-btn{
  width:auto !important;
  align-self:flex-start !important;
  min-height:38px !important;
  margin:0 !important;
  padding:9px 14px !important;
  gap:7px !important;
  border-radius:999px !important;
  background:#fff !important;
  color:#503d7a !important;
  border:1px solid rgba(80,61,122,.18) !important;
  box-shadow:0 10px 24px rgba(80,61,122,.08) !important;
  font-size:13px !important;
}
.arttree-map-card-btn svg{
  width:14px !important;
  height:14px !important;
  flex:0 0 14px !important;
}
.arttree-rt-card:has(.arttree-card-meta-icons) .arttree-rt-actions,
.arttree-workshop-overview-card .arttree-rt-actions{
  margin-top:auto !important;
  display:flex !important;
  flex-wrap:wrap !important;
  gap:10px !important;
  align-items:center !important;
}
.arttree-rt-card:has(.arttree-card-meta-icons) .arttree-rt-primary,
.arttree-rt-card:has(.arttree-card-meta-icons) .arttree-rt-secondary,
.arttree-rt-card:has(.arttree-card-meta-icons) .arttree-details-btn,
.arttree-workshop-overview-card .arttree-details-btn,
.arttree-workshop-overview-card .arttree-rt-primary,
.arttree-workshop-overview-card .arttree-rt-secondary{
  min-height:40px !important;
  padding:10px 16px !important;
  font-size:13px !important;
}
.arttree-workshop-overview-card{
  grid-template-columns:none !important;
  align-items:stretch !important;
}
.arttree-workshop-overview-card > div:last-child{
  display:flex !important;
  justify-content:flex-start !important;
  align-items:center !important;
  gap:10px !important;
  flex-wrap:wrap !important;
}
@media(max-width:980px){
  .arttree-card-meta-icons{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
}
@media(max-width:760px){
  .arttree-rt-card:has(.arttree-card-meta-icons),
  .arttree-workshop-overview-card{
    padding:20px !important;
    border-radius:24px !important;
  }
  .arttree-card-meta-icons{
    grid-template-columns:1fr !important;
  }
  .arttree-card-meta-icons span{
    min-height:52px !important;
  }
  .arttree-map-card-btn,
  .arttree-rt-card:has(.arttree-card-meta-icons) .arttree-rt-primary,
  .arttree-rt-card:has(.arttree-card-meta-icons) .arttree-rt-secondary,
  .arttree-rt-card:has(.arttree-card-meta-icons) .arttree-details-btn,
  .arttree-workshop-overview-card .arttree-details-btn,
  .arttree-workshop-overview-card .arttree-rt-primary,
  .arttree-workshop-overview-card .arttree-rt-secondary{
    width:100% !important;
    justify-content:center !important;
  }
}

/* v1.0.77 - attended registration state */
.arttree-registered-btn.is-attended{
  background:rgba(34,197,94,.14)!important;
  color:#15803d!important;
  border-color:rgba(34,197,94,.35)!important;
}
.arttree-registered-btn.is-registered{
  background:rgba(80,61,122,.10)!important;
  color:#503d7a!important;
  border-color:rgba(80,61,122,.22)!important;
}


/* v1.0.79 - applicant portal mobile drawer menu inspired by modern account panels */
.arttree-dashboard-mobile-bar,
.arttree-dashboard-dim,
.arttree-dashboard-drawer-head{display:none}
.arttree-dashboard-sidebar .arttree-dashboard-drawer-head strong{margin:0;font-size:18px;line-height:1.4;color:#251c32}
.arttree-dashboard-sidebar .arttree-dashboard-drawer-head span{display:block;color:#6f6579;font-size:13px;font-weight:900;margin-bottom:2px}
@media(max-width:900px){
  .arttree-dashboard-shell{
    width:100%;
    padding:34px 16px 64px;
    display:grid;
    grid-template-columns:1fr;
    gap:18px;
  }
  .arttree-dashboard-mobile-bar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    background:#fff;
    border:1px solid #ece5db;
    border-radius:22px;
    padding:12px 14px;
    box-shadow:0 18px 50px rgba(37,28,50,.08);
    position:relative;
    z-index:7;
  }
  .arttree-dashboard-mobile-user{display:flex;align-items:center;gap:12px;min-width:0;color:#251c32;font-weight:900;font-size:17px}
  .arttree-dashboard-mobile-user img{width:48px;height:48px;border-radius:50%;object-fit:cover;border:2px solid #fff;box-shadow:0 10px 24px rgba(37,28,50,.12)}
  .arttree-dashboard-mobile-user span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:190px}
  .arttree-dashboard-mobile-toggle{
    width:48px;
    height:48px;
    border:0;
    border-radius:16px;
    background:#fbfaf6;
    color:#6f6579;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    box-shadow:none;
    cursor:pointer;
  }
  .arttree-dashboard-mobile-toggle .arttree-dashboard-toggle-icon{width:26px;height:26px}
  .arttree-dashboard-toggle{display:none!important}
  .arttree-dashboard-dim{
    display:block;
    position:fixed;
    inset:0;
    background:rgba(37,37,42,.48);
    z-index:9997;
    opacity:0;
    pointer-events:none;
    border:0;
    padding:0;
    transition:opacity .24s ease;
  }
  .arttree-dashboard-sidebar{
    position:fixed;
    inset-block:0;
    inset-inline-end:0;
    top:0;
    width:min(78vw,360px);
    max-width:none;
    height:100dvh;
    overflow-y:auto;
    background:#fff;
    border:0;
    border-radius:0;
    padding:28px 22px 32px;
    box-shadow:-20px 0 70px rgba(37,28,50,.18);
    z-index:9998;
    display:grid;
    align-content:start;
    gap:10px;
    transform:translateX(-110%);
    opacity:1;
    pointer-events:none;
    transition:transform .28s ease;
  }
  html[dir="rtl"] .arttree-dashboard-sidebar,
  body.rtl .arttree-dashboard-sidebar{transform:translateX(-110%)}
  .arttree-dashboard-shell.is-mobile-menu-open .arttree-dashboard-sidebar{transform:translateX(0);pointer-events:auto}
  .arttree-dashboard-shell.is-mobile-menu-open .arttree-dashboard-dim{opacity:1;pointer-events:auto}
  .arttree-dashboard-shell.is-sidebar-hidden .arttree-dashboard-sidebar{display:grid;opacity:1;max-width:none;padding:28px 22px 32px;border-width:0;pointer-events:none}
  .arttree-dashboard-sidebar > strong{display:none!important}
  .arttree-dashboard-drawer-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-bottom:12px;
    padding-bottom:18px;
    border-bottom:1px solid #eee7de;
  }
  .arttree-dashboard-drawer-head button{
    width:38px;
    height:38px;
    border:0;
    border-radius:12px;
    background:#fbfaf6;
    color:#6f6579;
    font-size:28px;
    line-height:1;
    cursor:pointer;
  }
  .arttree-dashboard-sidebar a{
    display:grid;
    grid-template-columns:auto 1fr;
    align-items:center;
    gap:14px;
    min-width:0;
    padding:14px 15px;
    border-radius:16px;
    font-size:17px;
    border:1px solid transparent;
    color:#6f6579;
    background:transparent;
  }
  .arttree-dashboard-sidebar a.is-active{
    background:#503d7a;
    border-color:#503d7a;
    color:#fff;
    box-shadow:0 12px 30px rgba(80,61,122,.20);
  }
  .arttree-dashboard-sidebar a.is-active .arttree-dash-icon{color:#fff;opacity:1}
  .arttree-dashboard-sidebar a:hover{transform:none;background:rgba(80,61,122,.07)}
  .arttree-dashboard-sidebar a.is-active:hover{background:#503d7a;color:#fff}
  .arttree-dash-icon{width:24px;height:24px;color:#6f6579}
  .arttree-dashboard-content{display:grid;gap:16px}
  .arttree-dashboard-panel{border-radius:22px;padding:20px;box-shadow:0 14px 42px rgba(37,28,50,.06)}
}
@media(max-width:480px){
  .arttree-dashboard-shell{padding-inline:14px}
  .arttree-dashboard-sidebar{width:74vw;padding:24px 18px 30px}
  .arttree-dashboard-mobile-user span{max-width:150px;font-size:16px}
  .arttree-dashboard-sidebar a{font-size:16px;padding:13px 12px}
}

/* v1.0.80 - applicant profile and quick job application */
.arttree-profile-form{display:block;margin-top:20px}
.arttree-profile-edit-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-bottom:18px}
.arttree-profile-edit-grid label{display:flex;flex-direction:column;gap:8px;background:#fff;border:1px solid rgba(80,61,122,.12);border-radius:22px;padding:16px;box-shadow:0 14px 35px rgba(39,28,50,.06)}
.arttree-profile-edit-grid input{width:100%;border:1px solid rgba(80,61,122,.16);border-radius:16px;padding:13px 14px;font:inherit;color:#251c32;background:#fbfaf7}
.arttree-profile-edit-grid input[type=file]{background:#fff;padding:11px}
.arttree-inline-apply-form{display:inline-flex;margin:0}
.arttree-inline-apply-form button{border:0;cursor:pointer;font:inherit}
.arttree-job-apply-wide.arttree-inline-apply-form{display:block;width:100%}
.arttree-job-apply-wide.arttree-inline-apply-form button{width:100%}
@media(max-width:720px){.arttree-profile-edit-grid{grid-template-columns:1fr}.arttree-inline-apply-form{width:100%}.arttree-inline-apply-form button{width:100%}}

/* v1.0.83 - applicant profile management */
.arttree-profile-management .arttree-profile-head{margin-bottom:22px}
.arttree-profile-management .arttree-profile-head>span{display:inline-flex;align-items:center;border-radius:999px;background:rgba(80,61,122,.08);color:#503d7a;font-weight:800;padding:8px 14px;margin-bottom:10px}
.arttree-profile-management .arttree-profile-head h3{margin:0 0 8px;color:#251c32;font-size:clamp(28px,4vw,42px)}
.arttree-profile-section-card{background:#fff;border:1px solid rgba(80,61,122,.12);border-radius:28px;padding:22px;margin:18px 0;box-shadow:0 18px 45px rgba(39,28,50,.07)}
.arttree-profile-section-title{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:16px;border-bottom:1px solid rgba(80,61,122,.08);padding-bottom:14px}
.arttree-profile-section-title h4{margin:0;color:#251c32;font-size:24px}
.arttree-profile-section-title p{margin:4px 0 0;color:#6f6878}
.arttree-profile-edit-grid textarea{width:100%;border:1px solid rgba(80,61,122,.16);border-radius:16px;padding:13px 14px;font:inherit;color:#251c32;background:#fbfaf7;resize:vertical}
.arttree-profile-edit-grid small{color:#6f6878;font-size:13px}
.arttree-wide-field{grid-column:1/-1}
.arttree-current-cv{display:flex;align-items:center;justify-content:space-between;gap:14px;background:#fbfaf7;border:1px dashed rgba(80,61,122,.22);border-radius:20px;padding:14px 16px;margin-top:14px}
.arttree-current-cv strong{color:#251c32}
.arttree-current-cv a{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:#503d7a;color:#fff;text-decoration:none;padding:10px 16px;font-weight:800}
.arttree-profile-actions{display:flex;justify-content:flex-end;margin-top:18px}
.arttree-profile-actions .arttree-rt-primary{min-width:190px}
@media(max-width:720px){.arttree-profile-section-card{padding:16px;border-radius:22px}.arttree-profile-section-title,.arttree-current-cv{display:block}.arttree-current-cv a{margin-top:12px;width:100%}.arttree-profile-actions .arttree-rt-primary{width:100%}}

/* v1.0.84 - complete certificates rendering */
.arttree-certificate-document{margin-top:24px;display:grid;gap:18px;justify-items:center}
.arttree-certificate-frame{width:min(900px,100%);background:linear-gradient(180deg,#fff,#fbf8ff);border:1px solid rgba(80,61,122,.18);border-radius:34px;padding:44px 34px;text-align:center;box-shadow:0 18px 45px rgba(80,61,122,.10);position:relative;overflow:hidden}
.arttree-certificate-frame:before{content:"";position:absolute;inset:18px;border:1px solid rgba(80,61,122,.18);border-radius:26px;pointer-events:none}
.arttree-certificate-kicker{display:inline-flex;border-radius:999px;background:#f2edf8;color:#503d7a;padding:8px 16px;font-weight:800;margin-bottom:18px}
.arttree-certificate-frame h2{margin:0;color:#503d7a;font-size:42px;line-height:1.2}
.arttree-certificate-frame h3{margin:12px 0;color:#221637;font-size:34px;line-height:1.3}
.arttree-certificate-frame h4{margin:12px auto;color:#503d7a;font-size:26px;line-height:1.45;max-width:720px}
.arttree-certificate-text{margin:14px 0;color:#6d607d;font-size:18px}
.arttree-certificate-meta{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:22px}
.arttree-certificate-meta span{background:#fff;border:1px solid rgba(80,61,122,.14);border-radius:999px;padding:10px 16px;color:#35244f;font-weight:800}
.arttree-certificate-verify{margin-top:24px;display:grid;justify-items:center;gap:8px;color:#6d607d}
.arttree-certificate-verify img{width:130px;height:130px;border-radius:18px;border:1px solid rgba(80,61,122,.12);padding:8px;background:#fff}
.arttree-certificate-actions.no-print button{border:0;cursor:pointer}
@media print{body *{visibility:hidden!important}.arttree-certificate-print-page,.arttree-certificate-print-page *{visibility:visible!important}.arttree-certificate-print-page{position:absolute;inset:0;background:#fff!important}.no-print{display:none!important}.arttree-certificate-frame{box-shadow:none!important;border-color:#503d7a!important;margin:0 auto;page-break-inside:avoid}}
@media(max-width:640px){.arttree-certificate-frame{padding:34px 20px}.arttree-certificate-frame h2{font-size:32px}.arttree-certificate-frame h3{font-size:26px}.arttree-certificate-frame h4{font-size:21px}}

/* v1.0.85 - staff dashboard */
.arttree-staff-portal .arttree-auth-card{max-width:720px;margin-inline:auto}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar .arttree-dash-icon-certificate:before{content:""}
.arttree-staff-quick-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-top:18px}
.arttree-staff-quick-grid a{display:flex;align-items:center;justify-content:center;text-align:center;min-height:86px;border-radius:24px;background:#fff;border:1px solid rgba(80,61,122,.12);box-shadow:0 14px 38px rgba(37,28,50,.07);color:#503d7a;font-weight:900;text-decoration:none;padding:16px;transition:.2s ease}
.arttree-staff-quick-grid a:hover{transform:translateY(-3px);box-shadow:0 18px 45px rgba(37,28,50,.10)}
.arttree-staff-table-wrap{overflow:auto;background:#fff;border:1px solid rgba(80,61,122,.10);border-radius:26px;box-shadow:0 16px 40px rgba(37,28,50,.06);margin-top:18px}
.arttree-staff-table{width:100%;border-collapse:separate;border-spacing:0;min-width:760px;color:#251c32}
.arttree-staff-table th{background:#fbfaf7;color:#503d7a;font-weight:900;text-align:right;padding:16px;border-bottom:1px solid rgba(80,61,122,.10)}
.arttree-staff-table td{padding:15px 16px;border-bottom:1px solid rgba(80,61,122,.08);vertical-align:middle}
.arttree-staff-table tr:last-child td{border-bottom:0}
.arttree-staff-table a{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:#503d7a;color:#fff;text-decoration:none;padding:8px 14px;font-weight:800}
.arttree-staff-table code{direction:ltr;display:inline-block;background:#f4f0f8;border-radius:12px;color:#503d7a;padding:6px 10px}
.arttree-staff-badge{display:inline-flex;align-items:center;border-radius:999px;padding:7px 12px;font-weight:900;font-size:13px}
.arttree-staff-badge.attended{background:#e7f8ee;color:#167846}
.arttree-staff-badge.pending{background:#fff7df;color:#9b6a00}
.arttree-staff-actions{margin-top:18px;display:flex;justify-content:flex-end}
@media(max-width:900px){.arttree-staff-quick-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:560px){.arttree-staff-quick-grid{grid-template-columns:1fr}.arttree-staff-quick-grid a{min-height:70px}.arttree-staff-actions .arttree-rt-primary{width:100%}}

/* v1.0.86 - staff dashboard management modules */
.arttree-staff-manager-panel{display:block}
.arttree-staff-section-title{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:20px}
.arttree-staff-section-title span{display:inline-flex;margin-bottom:8px;color:#8b6bb8;font-weight:900;font-size:13px}
.arttree-staff-section-title h3{margin:0;color:#251c32;font-size:28px;line-height:1.35}
.arttree-staff-section-title p{margin:8px 0 0;color:#6b6176;line-height:1.8}
.arttree-staff-subnav{display:flex;flex-wrap:wrap;gap:10px;margin:0 0 20px}
.arttree-staff-subnav a{display:inline-flex;align-items:center;justify-content:center;min-height:42px;border-radius:999px;background:#f6f1fb;color:#503d7a;text-decoration:none;font-weight:900;padding:8px 16px;border:1px solid rgba(80,61,122,.10)}
.arttree-staff-manager-grid{display:grid;grid-template-columns:minmax(280px,420px) minmax(0,1fr);gap:22px;align-items:start}
.arttree-staff-form-card,.arttree-staff-list-card,.arttree-staff-detail-block{background:#fff;border:1px solid rgba(80,61,122,.10);border-radius:28px;box-shadow:0 16px 42px rgba(37,28,50,.06);padding:22px}
.arttree-staff-form-card h4,.arttree-staff-list-card h4,.arttree-staff-detail-block h4{margin:0 0 16px;color:#251c32;font-size:21px}
.arttree-staff-list-subtitle{margin-top:24px !important;padding-top:20px;border-top:1px solid rgba(80,61,122,.10)}
.arttree-staff-form-card form{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.arttree-staff-form-card label{display:flex;flex-direction:column;gap:8px;color:#503d7a;font-weight:900;font-size:13px}
.arttree-staff-form-card label.wide{grid-column:1/-1}
.arttree-staff-form-card input,.arttree-staff-form-card select,.arttree-staff-form-card textarea{width:100%;border:1px solid rgba(80,61,122,.16);border-radius:18px;background:#fbfaf7;color:#251c32;padding:13px 14px;font:inherit;outline:none}
.arttree-staff-form-card textarea{resize:vertical;min-height:112px}
.arttree-staff-form-card button{grid-column:1/-1;width:100%;border:0;cursor:pointer}
.arttree-staff-row-actions{display:flex;flex-wrap:wrap;gap:8px}
.arttree-staff-table td small{display:block;margin-top:5px;color:#81758b;font-size:12px;line-height:1.5}
.arttree-staff-detail-block{margin-bottom:22px}
.arttree-staff-detail-block .arttree-staff-table-wrap{margin-top:14px}
@media(max-width:980px){.arttree-staff-manager-grid{grid-template-columns:1fr}.arttree-staff-section-title{flex-direction:column}.arttree-staff-section-title>a{width:100%}.arttree-staff-form-card form{grid-template-columns:1fr}}

/* v1.0.87 - staff theme and systems control panel */
.arttree-theme-control-panel .arttree-panel-title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;margin-bottom:24px}
.arttree-theme-control-panel .arttree-panel-title-row span{display:inline-flex;color:var(--arttree-control-accent,#d7b46a);font-weight:800;margin-bottom:8px}
.arttree-theme-control-panel .arttree-panel-title-row h3{margin:0 0 8px;color:#251c32;font-size:clamp(24px,3vw,36px)}
.arttree-theme-control-panel .arttree-panel-title-row p{margin:0;color:#6f687b;line-height:1.9;max-width:760px}
.arttree-theme-control-form{display:grid;gap:24px}
.arttree-control-section{border:1px solid rgba(80,61,122,.12);background:linear-gradient(180deg,#fff,rgba(250,248,252,.82));border-radius:28px;padding:24px;box-shadow:0 14px 35px rgba(37,28,50,.06)}
.arttree-control-section h4{margin:0 0 18px;color:#251c32;font-size:22px}
.arttree-control-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.arttree-control-switch{position:relative;display:grid;grid-template-columns:auto 1fr;grid-template-areas:"toggle title" "toggle desc";align-items:center;column-gap:12px;row-gap:4px;border:1px solid rgba(80,61,122,.10);background:#fff;border-radius:20px;padding:16px;cursor:pointer;transition:.2s ease}
.arttree-control-switch:hover{transform:translateY(-2px);border-color:rgba(80,61,122,.24);box-shadow:0 12px 24px rgba(37,28,50,.07)}
.arttree-control-switch input{position:absolute;opacity:0;pointer-events:none}
.arttree-control-switch span{grid-area:toggle;width:46px;height:26px;border-radius:99px;background:#d9d5e3;position:relative;transition:.2s ease}
.arttree-control-switch span:before{content:"";position:absolute;width:20px;height:20px;border-radius:50%;background:#fff;right:3px;top:3px;box-shadow:0 2px 6px rgba(0,0,0,.18);transition:.2s ease}
.arttree-control-switch input:checked + span{background:var(--arttree-control-primary,#503d7a)}
.arttree-control-switch input:checked + span:before{right:23px;background:var(--arttree-control-accent,#d7b46a)}
.arttree-control-switch strong{grid-area:title;color:#251c32;font-size:16px}
.arttree-control-switch small{grid-area:desc;color:#777184;line-height:1.5;word-break:break-word}
.arttree-control-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.arttree-control-fields label{display:grid;gap:8px;color:#251c32;font-weight:800}
.arttree-control-fields input{width:100%;border:1px solid rgba(80,61,122,.16);background:#fff;border-radius:16px;padding:13px 14px;color:#251c32;outline:none}
.arttree-control-fields input:focus{border-color:var(--arttree-control-primary,#503d7a);box-shadow:0 0 0 4px rgba(80,61,122,.10)}
.arttree-theme-control-form>.arttree-rt-primary{justify-self:start;min-width:190px;border:0}
@media(max-width:980px){.arttree-control-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:640px){.arttree-control-grid,.arttree-control-fields{grid-template-columns:1fr}.arttree-control-section{padding:18px;border-radius:22px}.arttree-theme-control-form>.arttree-rt-primary{width:100%}}

/* v1.0.89 - coming soon and maintenance controls */
.arttree-control-note{margin:0 0 16px;color:#756b82;line-height:1.8}
.arttree-control-fields select,.arttree-control-fields textarea{width:100%;border:1px solid rgba(80,61,122,.16);background:#fff;border-radius:16px;padding:13px 14px;color:#251c32;outline:none;font:inherit}
.arttree-control-fields textarea{resize:vertical;min-height:96px;line-height:1.8}
.arttree-control-fields label.wide{grid-column:1/-1}
.arttree-control-fields select:focus,.arttree-control-fields textarea:focus{border-color:var(--arttree-control-primary,#503d7a);box-shadow:0 0 0 4px rgba(80,61,122,.10)}

/* v1.0.90 - staff roles and permissions */
.arttree-staff-users-panel .arttree-role-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:16px}
.arttree-role-card{border:1px solid rgba(80,61,122,.12);border-radius:22px;background:#fff;padding:18px;box-shadow:0 14px 34px rgba(37,28,50,.06)}
.arttree-role-card h5{margin:0 0 12px;color:#503d7a;font-size:18px}
.arttree-role-card ul{margin:0;padding:0;list-style:none;display:grid;gap:8px}
.arttree-role-card li{position:relative;padding-inline-start:20px;color:#43364f;font-size:14px;line-height:1.7}
.arttree-role-card li:before{content:"";position:absolute;inset-inline-start:0;top:.72em;width:8px;height:8px;border-radius:50%;background:#d7b46a}
.arttree-staff-users-table-card{margin-top:22px}
.arttree-inline-role-form{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.arttree-inline-role-form select{min-width:170px;border:1px solid rgba(80,61,122,.18);border-radius:14px;padding:10px 12px;background:#fff;color:#251c32;font-family:inherit}
.arttree-inline-role-form button{border:0;border-radius:14px;background:#503d7a;color:#fff;padding:10px 16px;font-weight:800;font-family:inherit;cursor:pointer}
.arttree-muted{color:#81768f;font-size:13px}
@media(max-width:720px){.arttree-staff-users-panel .arttree-role-grid{grid-template-columns:1fr}.arttree-inline-role-form{display:grid}.arttree-inline-role-form select,.arttree-inline-role-form button{width:100%}}


/* v1.0.91 - staff control panel full browser layout */
.arttree-rt.arttree-staff-portal{
  max-width:none!important;
  width:100%!important;
  margin:0!important;
  border:0!important;
  border-radius:0!important;
  overflow:visible!important;
  background:#f7f7f8!important;
  color:#251c32!important;
  min-height:100vh!important;
  padding:0!important;
}
.arttree-staff-dashboard-shell{
  width:100%!important;
  max-width:none!important;
  margin:0!important;
  padding:20px 20px 64px!important;
  display:grid!important;
  direction:ltr;
  grid-template-columns:minmax(0,1fr) 270px!important;
  grid-template-areas:
    "top sidebar"
    "content sidebar"!important;
  gap:18px!important;
  min-height:100vh;
  background:#f7f7f8;
}
.arttree-staff-dashboard-shell > *{direction:rtl}
.arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar{
  grid-area:top;
  display:flex!important;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  background:#fff;
  border:1px solid rgba(80,61,122,.07);
  border-radius:12px;
  padding:12px 18px;
  box-shadow:0 10px 32px rgba(37,28,50,.04);
  position:relative;
  z-index:2;
}
.arttree-staff-dashboard-shell .arttree-dashboard-mobile-user{display:flex;align-items:center;gap:12px;min-width:0;color:#251c32;font-weight:900}
.arttree-staff-dashboard-shell .arttree-dashboard-mobile-user img{width:42px;height:42px;border-radius:50%;object-fit:cover;border:2px solid #fff;box-shadow:0 8px 18px rgba(37,28,50,.10)}
.arttree-staff-dashboard-shell .arttree-dashboard-mobile-user span{font-size:15px;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:260px}
.arttree-staff-dashboard-shell .arttree-dashboard-mobile-toggle,
.arttree-staff-dashboard-shell .arttree-dashboard-toggle,
.arttree-staff-dashboard-shell .arttree-dashboard-dim{display:none!important}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
  grid-area:sidebar;
  position:sticky!important;
  top:0!important;
  height:calc(100vh - 40px);
  max-height:calc(100vh - 40px);
  overflow:auto;
  align-self:start;
  display:grid;
  align-content:start;
  gap:8px;
  background:#fff;
  border:1px solid rgba(80,61,122,.08);
  border-radius:0 0 18px 18px;
  padding:22px 18px 26px;
  box-shadow:0 18px 50px rgba(37,28,50,.06);
  transform:none!important;
  opacity:1!important;
  max-width:none!important;
  pointer-events:auto!important;
}
.arttree-staff-dashboard-shell .arttree-staff-brand{
  display:grid;
  justify-items:center;
  gap:10px;
  padding:8px 8px 18px;
  margin-bottom:8px;
  border-bottom:1px solid rgba(80,61,122,.08);
}
.arttree-staff-dashboard-shell .arttree-staff-brand img{max-width:142px;max-height:78px;object-fit:contain;display:block}
.arttree-staff-dashboard-shell .arttree-staff-brand strong{font-size:15px;color:#251c32;margin:0;font-weight:900}
.arttree-staff-dashboard-shell .arttree-dashboard-drawer-head{display:none!important}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar > strong{display:none!important}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar a{
  display:grid;
  grid-template-columns:22px 1fr;
  align-items:center;
  gap:11px;
  min-height:44px;
  border-radius:10px;
  padding:10px 12px;
  color:#625c6f;
  background:transparent;
  border:1px solid transparent;
  font-size:14px;
  font-weight:900;
  text-decoration:none;
  transform:none!important;
}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar a:hover{background:#f4f1f7;color:#251c32;border-color:rgba(80,61,122,.08)}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar a.is-active{
  background:#503d7a;
  color:#fff;
  border-color:#503d7a;
  box-shadow:0 12px 30px rgba(80,61,122,.18);
}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar a.is-active .arttree-dash-icon{color:#fff}
.arttree-staff-dashboard-shell .arttree-dash-icon{width:20px;height:20px;color:#6f6579}
.arttree-staff-dashboard-shell .arttree-dashboard-content{
  grid-area:content;
  min-width:0;
  display:grid;
  gap:20px;
  padding:0 0 24px;
}
.arttree-staff-dashboard-shell .arttree-dashboard-panel{
  border-radius:14px;
  border:1px solid rgba(80,61,122,.07);
  box-shadow:0 15px 38px rgba(37,28,50,.045);
  padding:26px;
  background:#fff;
}
.arttree-staff-dashboard-shell .arttree-dashboard-panel.hero-panel{
  background:#fff;
}
.arttree-staff-dashboard-shell .arttree-dashboard-stats{grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}
.arttree-staff-dashboard-shell .arttree-dashboard-stats b{
  border-radius:14px;
  min-height:118px;
  box-shadow:0 14px 38px rgba(37,28,50,.045);
}
.arttree-staff-dashboard-shell .arttree-staff-quick-grid{grid-template-columns:repeat(5,minmax(0,1fr));gap:16px}
.arttree-staff-dashboard-shell .arttree-staff-quick-grid a{border-radius:14px;min-height:78px;box-shadow:0 14px 36px rgba(37,28,50,.045)}
.arttree-staff-dashboard-shell .arttree-staff-table-wrap,
.arttree-staff-dashboard-shell .arttree-staff-form-card,
.arttree-staff-dashboard-shell .arttree-staff-list-card,
.arttree-staff-dashboard-shell .arttree-staff-detail-block{border-radius:14px;box-shadow:0 14px 36px rgba(37,28,50,.045)}
@media(min-width:1200px){
  .arttree-staff-dashboard-shell{padding-inline:26px!important;grid-template-columns:minmax(0,1fr) 286px!important}
}
@media(max-width:1100px){
  .arttree-staff-dashboard-shell{grid-template-columns:minmax(0,1fr) 240px!important;padding:16px!important}
  .arttree-staff-dashboard-shell .arttree-staff-quick-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media(max-width:900px){
  .arttree-staff-dashboard-shell{
    direction:rtl;
    grid-template-columns:1fr!important;
    grid-template-areas:"top" "content"!important;
    padding:34px 16px 64px!important;
  }
  .arttree-staff-dashboard-shell .arttree-dashboard-mobile-toggle{display:inline-flex!important}
  .arttree-staff-dashboard-shell .arttree-dashboard-dim{display:block!important}
  .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    position:fixed!important;
    inset-block:0!important;
    inset-inline-end:0!important;
    width:min(78vw,360px)!important;
    height:100dvh!important;
    max-height:none!important;
    border:0!important;
    border-radius:0!important;
    padding:28px 22px 32px!important;
    z-index:9998;
    transform:translateX(-110%)!important;
    pointer-events:none!important;
  }
  .arttree-staff-dashboard-shell.is-mobile-menu-open .arttree-dashboard-sidebar{transform:translateX(0)!important;pointer-events:auto!important}
  .arttree-staff-dashboard-shell .arttree-staff-brand{display:none!important}
  .arttree-staff-dashboard-shell .arttree-dashboard-drawer-head{display:flex!important}
  .arttree-staff-dashboard-shell .arttree-staff-quick-grid,
  .arttree-staff-dashboard-shell .arttree-dashboard-stats{grid-template-columns:1fr}
}

/* v1.0.92 - true full browser staff dashboard and grouped settings menu */
body.dewan-staff-dashboard-view{
  background:#f7f7f8!important;
  overflow-x:hidden!important;
}
body.dewan-staff-dashboard-view .site-header,
body.dewan-staff-dashboard-view .site-footer{
  display:none!important;
}
.arttree-staff-fullscreen-page,
.arttree-staff-fullscreen-page > .arttree-rt.arttree-staff-portal{
  width:100vw!important;
  max-width:none!important;
  min-height:100vh!important;
  margin:0 calc(50% - 50vw)!important;
  padding:0!important;
  background:#f7f7f8!important;
  overflow:visible!important;
}
.arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
  width:100vw!important;
  max-width:none!important;
  min-height:100vh!important;
  margin:0!important;
  padding:18px 22px 54px!important;
  grid-template-columns:minmax(0,1fr) 292px!important;
  gap:18px!important;
}
.arttree-staff-dashboard-shell .arttree-dashboard-content{
  width:100%!important;
  max-width:none!important;
}
.arttree-staff-dashboard-shell .arttree-dashboard-panel,
.arttree-staff-dashboard-shell .arttree-staff-table-wrap,
.arttree-staff-dashboard-shell .arttree-staff-form-card,
.arttree-staff-dashboard-shell .arttree-staff-list-card,
.arttree-staff-dashboard-shell .arttree-staff-detail-block{
  max-width:none!important;
}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
  border-radius:0 0 18px 18px!important;
  padding:20px 16px 26px!important;
}
.arttree-staff-menu-group{
  display:grid;
  gap:6px;
  padding:8px 0 12px;
  border-bottom:1px solid rgba(80,61,122,.08);
}
.arttree-staff-menu-group:last-child{border-bottom:0;padding-bottom:0}
.arttree-staff-menu-group > strong{
  display:block!important;
  margin:0 8px 4px!important;
  color:#9a91a6!important;
  font-size:12px!important;
  line-height:1.4!important;
  font-weight:900!important;
}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar .arttree-staff-menu-group a{
  display:grid;
  grid-template-columns:20px 1fr;
  align-items:center;
  gap:10px;
  min-height:40px;
  padding:9px 11px;
  border-radius:10px;
}
.arttree-staff-menu-logout{margin-top:8px;border-top:1px solid rgba(80,61,122,.08);border-bottom:0!important}
.arttree-staff-subtabs{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin:18px 0 22px;
}
.arttree-staff-subtabs a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:42px;
  padding:10px 15px;
  border-radius:999px;
  border:1px solid rgba(80,61,122,.12);
  background:#fff;
  color:#625c6f;
  font-weight:900;
  text-decoration:none;
  box-shadow:0 10px 26px rgba(37,28,50,.035);
}
.arttree-staff-subtabs a.is-active{
  background:#503d7a;
  color:#fff;
  border-color:#503d7a;
  box-shadow:0 14px 32px rgba(80,61,122,.18);
}
@media(min-width:1440px){
  .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    grid-template-columns:minmax(0,1fr) 312px!important;
    padding-inline:28px!important;
  }
}
@media(max-width:1100px){
  .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    grid-template-columns:minmax(0,1fr) 246px!important;
    padding:16px!important;
  }
}
@media(max-width:900px){
  body.dewan-staff-dashboard-view .site-header{display:block!important}
  .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    width:100%!important;
    grid-template-columns:1fr!important;
    padding:34px 16px 64px!important;
  }
  .arttree-staff-subtabs{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .arttree-staff-subtabs a{border-radius:14px;padding:10px 8px;font-size:13px}
}
@media(max-width:560px){.arttree-staff-subtabs{grid-template-columns:1fr}}


/* v1.0.93 - staff dashboard full width with sidebar on far left */
body.dewan-staff-dashboard-view{
  width:100vw!important;
  max-width:100vw!important;
  margin:0!important;
  padding:0!important;
  overflow-x:hidden!important;
}
body.dewan-staff-dashboard-view #page,
body.dewan-staff-dashboard-view .site,
body.dewan-staff-dashboard-view .site-main,
body.dewan-staff-dashboard-view main,
body.dewan-staff-dashboard-view .content-area,
body.dewan-staff-dashboard-view .entry-content,
body.dewan-staff-dashboard-view article,
body.dewan-staff-dashboard-view .container,
body.dewan-staff-dashboard-view .wrap{
  width:100vw!important;
  max-width:none!important;
  margin:0!important;
  padding:0!important;
}
body.dewan-staff-dashboard-view .entry-header,
body.dewan-staff-dashboard-view .page-header,
body.dewan-staff-dashboard-view .post-thumbnail{display:none!important}
.arttree-staff-fullscreen-page,
.arttree-staff-fullscreen-page > .arttree-rt.arttree-staff-portal,
body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal{
  width:100vw!important;
  max-width:100vw!important;
  margin:0!important;
  padding:0!important;
  min-height:100vh!important;
}
.arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
  width:100vw!important;
  max-width:100vw!important;
  min-height:100vh!important;
  margin:0!important;
  padding:18px 22px 54px!important;
  direction:ltr!important;
  grid-template-columns:312px minmax(0,1fr)!important;
  grid-template-areas:
    "sidebar top"
    "sidebar content"!important;
  gap:18px!important;
}
.arttree-staff-dashboard-shell > *{direction:rtl!important}
.arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
  grid-area:sidebar!important;
  justify-self:stretch!important;
  width:312px!important;
  max-width:312px!important;
  inset-inline-start:auto!important;
  inset-inline-end:auto!important;
  border-radius:0 0 18px 18px!important;
}
.arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar{grid-area:top!important;width:100%!important;max-width:none!important}
.arttree-staff-dashboard-shell .arttree-dashboard-content{grid-area:content!important;width:100%!important;max-width:none!important}
@media(max-width:1200px){
  .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{grid-template-columns:264px minmax(0,1fr)!important;padding:16px!important}
  .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{width:264px!important;max-width:264px!important}
}
@media(max-width:900px){
  body.dewan-staff-dashboard-view .site-header{display:block!important}
  .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    width:100%!important;
    max-width:100%!important;
    direction:rtl!important;
    grid-template-columns:1fr!important;
    grid-template-areas:"top" "content"!important;
    padding:34px 16px 64px!important;
  }
  .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    position:fixed!important;
    inset-block:0!important;
    inset-inline-end:0!important;
    width:min(78vw,360px)!important;
    max-width:min(78vw,360px)!important;
    border-radius:0!important;
  }
}

/* v1.0.94 - remove right blank space and make staff dashboard truly edge to edge */
html:has(body.dewan-staff-dashboard-view),
body.dewan-staff-dashboard-view{
  width:100%!important;
  max-width:none!important;
  min-width:0!important;
  margin:0!important;
  padding:0!important;
  background:#f7f7f8!important;
  overflow-x:hidden!important;
}
body.dewan-staff-dashboard-view #page,
body.dewan-staff-dashboard-view .site,
body.dewan-staff-dashboard-view .site-main,
body.dewan-staff-dashboard-view main,
body.dewan-staff-dashboard-view .content-area,
body.dewan-staff-dashboard-view .entry-content,
body.dewan-staff-dashboard-view .hentry,
body.dewan-staff-dashboard-view article,
body.dewan-staff-dashboard-view .container,
body.dewan-staff-dashboard-view .wrap,
body.dewan-staff-dashboard-view .section-pad,
body.dewan-staff-dashboard-view .post-card{
  width:100%!important;
  max-width:none!important;
  min-width:0!important;
  margin:0!important;
  padding:0!important;
  border:0!important;
  box-shadow:none!important;
  background:transparent!important;
}
body.dewan-staff-dashboard-view .site-header,
body.dewan-staff-dashboard-view .site-footer,
body.dewan-staff-dashboard-view .entry-header,
body.dewan-staff-dashboard-view .page-header,
body.dewan-staff-dashboard-view .post-thumbnail,
body.dewan-staff-dashboard-view .wp-block-post-title{
  display:none!important;
}
body.dewan-staff-dashboard-view .arttree-staff-fullscreen-page,
body.dewan-staff-dashboard-view .arttree-staff-fullscreen-page > .arttree-rt.arttree-staff-portal,
body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal{
  position:relative!important;
  inset:auto!important;
  width:100vw!important;
  max-width:100vw!important;
  min-width:100vw!important;
  min-height:100vh!important;
  margin:0!important;
  padding:0!important;
  background:#f7f7f8!important;
  overflow:visible!important;
}
body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
  width:100vw!important;
  max-width:100vw!important;
  min-width:100vw!important;
  min-height:100vh!important;
  margin:0!important;
  padding:0!important;
  gap:0!important;
  direction:ltr!important;
  display:grid!important;
  grid-template-columns:300px minmax(0,1fr)!important;
  grid-template-rows:auto minmax(0,1fr)!important;
  grid-template-areas:"sidebar top" "sidebar content"!important;
  background:#f7f7f8!important;
  box-sizing:border-box!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell > *{direction:rtl!important;box-sizing:border-box!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
  grid-area:sidebar!important;
  position:sticky!important;
  top:0!important;
  left:0!important;
  right:auto!important;
  align-self:start!important;
  justify-self:stretch!important;
  width:300px!important;
  max-width:300px!important;
  min-width:300px!important;
  height:100vh!important;
  max-height:100vh!important;
  margin:0!important;
  padding:22px 16px 28px!important;
  border-radius:0!important;
  border:0!important;
  border-inline-end:1px solid rgba(80,61,122,.08)!important;
  background:#fff!important;
  overflow:auto!important;
  box-shadow:18px 0 50px rgba(37,28,50,.045)!important;
  transform:none!important;
  opacity:1!important;
  pointer-events:auto!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar{
  grid-area:top!important;
  width:100%!important;
  max-width:none!important;
  margin:0!important;
  border-radius:0!important;
  border:0!important;
  border-bottom:1px solid rgba(80,61,122,.08)!important;
  box-shadow:none!important;
  min-height:76px!important;
  padding:14px 24px!important;
  background:#fff!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
  grid-area:content!important;
  width:100%!important;
  max-width:none!important;
  min-width:0!important;
  justify-self:stretch!important;
  align-self:stretch!important;
  padding:22px 24px 64px!important;
  margin:0!important;
  display:grid!important;
  gap:22px!important;
  background:#f7f7f8!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-panel,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-table-wrap,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-form-card,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-list-card,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-detail-block{
  width:100%!important;
  max-width:none!important;
  margin-inline:0!important;
}
@media(min-width:1440px){
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    grid-template-columns:320px minmax(0,1fr)!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    width:320px!important;max-width:320px!important;min-width:320px!important;
  }
}
@media(max-width:1100px){
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    grid-template-columns:260px minmax(0,1fr)!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    width:260px!important;max-width:260px!important;min-width:260px!important;
  }
}
@media(max-width:900px){
  body.dewan-staff-dashboard-view .site-header{display:block!important}
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal,
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    width:100%!important;max-width:100%!important;min-width:0!important;
  }
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    direction:rtl!important;
    grid-template-columns:1fr!important;
    grid-template-areas:"top" "content"!important;
    grid-template-rows:auto auto!important;
    gap:0!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar{
    border-radius:0!important;
    min-height:auto!important;
    padding:14px 16px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    padding:18px 16px 64px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    position:fixed!important;
    inset-block:0!important;
    inset-inline-end:0!important;
    inset-inline-start:auto!important;
    width:min(82vw,360px)!important;
    min-width:0!important;
    max-width:min(82vw,360px)!important;
    height:100dvh!important;
    max-height:none!important;
    border-radius:0!important;
    border:0!important;
    box-shadow:-18px 0 50px rgba(37,28,50,.18)!important;
    transform:translateX(110%)!important;
    pointer-events:none!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-mobile-menu-open .arttree-dashboard-sidebar{
    transform:translateX(0)!important;
    pointer-events:auto!important;
  }
}


/* v1.0.96 - move staff dashboard sidebar to the far right */
@media(min-width:901px){
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    direction:rtl!important;
    grid-template-columns:minmax(0,1fr) 300px!important;
    grid-template-areas:"top sidebar" "content sidebar"!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    left:auto!important;
    right:0!important;
    border-inline-start:1px solid rgba(80,61,122,.08)!important;
    border-inline-end:0!important;
    box-shadow:-18px 0 50px rgba(37,28,50,.045)!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    width:100%!important;
    max-width:none!important;
    margin:0!important;
  }
}
@media(min-width:1440px){
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    grid-template-columns:minmax(0,1fr) 320px!important;
  }
}
@media(min-width:901px) and (max-width:1100px){
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    grid-template-columns:minmax(0,1fr) 260px!important;
  }
}


/* v1.0.97 - definitive right sidebar layout and grouped staff menu */
@media(min-width:901px){
  body.dewan-staff-dashboard-view,
  body.dewan-staff-dashboard-view .site,
  body.dewan-staff-dashboard-view .site-main,
  body.dewan-staff-dashboard-view .content-area,
  body.dewan-staff-dashboard-view .entry-content{
    width:100vw!important;
    max-width:100vw!important;
    margin:0!important;
    padding:0!important;
    overflow-x:hidden!important;
  }
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    display:block!important;
    position:relative!important;
    width:100vw!important;
    max-width:100vw!important;
    min-height:100vh!important;
    margin:0!important;
    padding:0!important;
    background:#f7f7f8!important;
    direction:rtl!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    position:fixed!important;
    top:0!important;
    right:0!important;
    left:auto!important;
    bottom:0!important;
    width:300px!important;
    min-width:300px!important;
    max-width:300px!important;
    height:100vh!important;
    margin:0!important;
    padding:22px 16px 28px!important;
    border-radius:0!important;
    border:0!important;
    border-left:1px solid rgba(80,61,122,.08)!important;
    border-right:0!important;
    background:#fff!important;
    box-shadow:-18px 0 50px rgba(37,28,50,.05)!important;
    overflow:auto!important;
    transform:none!important;
    opacity:1!important;
    pointer-events:auto!important;
    z-index:20!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    width:calc(100vw - 300px)!important;
    max-width:calc(100vw - 300px)!important;
    margin-right:300px!important;
    margin-left:0!important;
    box-sizing:border-box!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar{
    min-height:76px!important;
    padding:14px 24px!important;
    border-radius:0!important;
    border:0!important;
    border-bottom:1px solid rgba(80,61,122,.08)!important;
    background:#fff!important;
    box-shadow:none!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    min-height:calc(100vh - 76px)!important;
    padding:24px 26px 64px!important;
    display:grid!important;
    gap:22px!important;
    background:#f7f7f8!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand{
    margin-bottom:20px!important;
    padding:0 4px 18px!important;
    border-bottom:1px solid rgba(80,61,122,.08)!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group{
    padding:12px 0!important;
    border-bottom:1px solid rgba(80,61,122,.06)!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group > strong{
    display:block!important;
    margin:0 8px 8px!important;
    color:#503d7a!important;
    font-size:13px!important;
    font-weight:900!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group a{
    min-height:42px!important;
    margin:3px 0!important;
    padding:10px 12px!important;
    border-radius:16px!important;
  }
}
@media(min-width:1440px){
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    width:320px!important;min-width:320px!important;max-width:320px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    width:calc(100vw - 320px)!important;max-width:calc(100vw - 320px)!important;margin-right:320px!important;
  }
}
@media(min-width:901px) and (max-width:1100px){
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    width:260px!important;min-width:260px!important;max-width:260px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    width:calc(100vw - 260px)!important;max-width:calc(100vw - 260px)!important;margin-right:260px!important;
  }
}
@media(max-width:900px){
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    right:0!important;
    left:auto!important;
  }
}


/* v1.0.98 - Dewan logo in staff sidebar */
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand{
  display:flex!important;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:18px 12px 20px;
  margin:0 0 12px;
  text-align:center;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand img,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand img{
  width:150px;
  max-width:78%;
  height:auto;
  max-height:88px;
  object-fit:contain;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand strong,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand strong{
  margin:2px 0 0;
  font-size:17px;
  font-weight:950;
  color:#251c32;
  line-height:1.3;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand small,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand small{
  display:block;
  font-size:12px;
  font-weight:900;
  color:#7b7186;
  line-height:1.2;
}
@media(max-width:980px){
  .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand{display:none!important}
}

/* v1.0.99 - staff dashboard overview statistics and notifications */
.arttree-staff-overview-hero{margin-bottom:0!important}
.arttree-staff-stats-panel .arttree-panel-title-row,
.arttree-staff-notifications-panel .arttree-panel-title-row,
.arttree-staff-shortcuts-panel .arttree-panel-title-row{margin-bottom:18px}
.arttree-staff-stat-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}
.arttree-staff-stat-card{display:grid;gap:7px;align-content:start;min-height:142px;padding:22px;border-radius:22px;background:linear-gradient(180deg,#fff,#fbfafc);border:1px solid rgba(80,61,122,.10);box-shadow:0 14px 36px rgba(37,28,50,.045);text-decoration:none;color:#251c32;transition:.2s ease}
.arttree-staff-stat-card:hover{transform:translateY(-3px);box-shadow:0 18px 44px rgba(37,28,50,.075);border-color:rgba(80,61,122,.18)}
.arttree-staff-stat-card strong{font-size:38px;line-height:1;color:#503d7a;font-weight:900;letter-spacing:-.02em}
.arttree-staff-stat-card span{font-size:16px;font-weight:900;color:#251c32}
.arttree-staff-stat-card small{font-size:13px;font-weight:800;color:#6f6579;line-height:1.5}
.arttree-staff-notifications-list{display:grid;gap:12px}
.arttree-staff-notification{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:18px 20px;border-radius:20px;border:1px solid rgba(80,61,122,.10);background:#fff;box-shadow:0 12px 32px rgba(37,28,50,.04)}
.arttree-staff-notification strong{display:block;color:#251c32;font-weight:900;margin-bottom:5px}
.arttree-staff-notification p{margin:0;color:#6f6579;font-size:14px;line-height:1.7;font-weight:700}
.arttree-staff-notification a{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;border-radius:999px;padding:9px 16px;font-weight:900;text-decoration:none;background:#503d7a;color:#fff}
.arttree-staff-notification.is-success{border-color:rgba(32,122,74,.18);background:#f3fbf6}
.arttree-staff-notification.is-success a{background:#207a4a}
.arttree-staff-notification.is-warning{border-color:rgba(199,132,0,.22);background:#fff9e8}
.arttree-staff-notification.is-warning a{background:#a46f00}
.arttree-staff-notification.is-info{border-color:rgba(80,61,122,.18);background:#f7f3fb}
.arttree-staff-notification.is-quiet{background:#fbfaf7;color:#6f6579}
@media(max-width:1100px){.arttree-staff-stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:640px){.arttree-staff-stat-grid{grid-template-columns:1fr}.arttree-staff-notification{display:grid}.arttree-staff-notification a{width:100%}.arttree-staff-stat-card{min-height:auto}}

/* v1.0.100 - staff dashboard KPI cards */
.arttree-staff-kpi-grid{
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:16px!important;
}
.arttree-staff-stat-card{
  position:relative;
  display:grid!important;
  grid-template-columns:52px minmax(0,1fr)!important;
  align-items:center!important;
  gap:15px!important;
  min-height:134px!important;
  padding:18px!important;
  overflow:hidden!important;
}
.arttree-staff-stat-card:after,
.arttree-staff-kpi-card:after{
  content:"";
  position:absolute;
  inset:auto -34px -46px auto;
  width:110px;
  height:110px;
  border-radius:50%;
  background:rgba(80,61,122,.055);
  pointer-events:none;
}
.arttree-kpi-card-body{display:grid;gap:6px;min-width:0}
.arttree-staff-stat-card strong,
.arttree-staff-kpi-card strong{
  font-size:34px!important;
  line-height:1!important;
  color:#251c32!important;
  font-weight:900!important;
  letter-spacing:-.02em!important;
}
.arttree-staff-stat-card span:not(.arttree-kpi-icon),
.arttree-staff-kpi-card span:not(.arttree-kpi-icon){font-size:15px!important;font-weight:900!important;color:#251c32!important;line-height:1.35!important}
.arttree-staff-stat-card small,
.arttree-staff-kpi-card small{font-size:12.5px!important;font-weight:800!important;color:#726a7e!important;line-height:1.55!important}
.arttree-kpi-icon{
  width:52px;
  height:52px;
  border-radius:16px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#f4f1f8;
  color:#503d7a;
  border:1px solid rgba(80,61,122,.10);
  box-shadow:0 10px 22px rgba(37,28,50,.045);
  flex:0 0 auto;
}
.arttree-kpi-icon:before{content:"";width:24px;height:24px;display:block;background:currentColor;mask-size:contain;mask-position:center;mask-repeat:no-repeat;-webkit-mask-size:contain;-webkit-mask-position:center;-webkit-mask-repeat:no-repeat}
.arttree-kpi-icon.is-briefcase:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M10 6V5a2 2 0 0 1 2-2h0a2 2 0 0 1 2 2v1'/%3E%3Crect x='3' y='6' width='18' height='14' rx='3'/%3E%3Cpath d='M3 11h18M10 13h4'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M10 6V5a2 2 0 0 1 2-2h0a2 2 0 0 1 2 2v1'/%3E%3Crect x='3' y='6' width='18' height='14' rx='3'/%3E%3Cpath d='M3 11h18M10 13h4'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-bell:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M18 8a6 6 0 1 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9'/%3E%3Cpath d='M10 21h4'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M18 8a6 6 0 1 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9'/%3E%3Cpath d='M10 21h4'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-target:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-calendar:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Crect x='3' y='5' width='18' height='16' rx='3'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-users:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9.5' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9.5' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-check:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2.4'%3E%3Cpath d='m20 6-11 11-5-5'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2.4'%3E%3Cpath d='m20 6-11 11-5-5'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-clock:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6l4 2'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6l4 2'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-certificate:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M6 3h12v18l-6-3-6 3V3Z'/%3E%3Cpath d='M9 8h6M9 12h6'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M6 3h12v18l-6-3-6 3V3Z'/%3E%3Cpath d='M9 8h6M9 12h6'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-door:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M7 21V3h10v18'/%3E%3Cpath d='M10 12h.01M4 21h16'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M7 21V3h10v18'/%3E%3Cpath d='M10 12h.01M4 21h16'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-shield:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-page:before,.arttree-kpi-icon.is-post:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9Z'/%3E%3Cpath d='M14 3v6h6M8 13h8M8 17h5'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9Z'/%3E%3Cpath d='M14 3v6h6M8 13h8M8 17h5'/%3E%3C/svg%3E")}
.arttree-kpi-icon.is-chart:before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M4 19V5M4 19h16'/%3E%3Cpath d='M8 16v-5M12 16V8M16 16v-7'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M4 19V5M4 19h16'/%3E%3Cpath d='M8 16v-5M12 16V8M16 16v-7'/%3E%3C/svg%3E")}
.arttree-staff-stat-card.is-success .arttree-kpi-icon,.arttree-staff-kpi-card.is-success .arttree-kpi-icon{background:#ecfdf3;color:#0b7a48;border-color:rgba(11,122,72,.14)}
.arttree-staff-stat-card.is-warning .arttree-kpi-icon,.arttree-staff-kpi-card.is-warning .arttree-kpi-icon{background:#fffbeb;color:#a16207;border-color:rgba(161,98,7,.14)}
.arttree-staff-stat-card.is-danger .arttree-kpi-icon,.arttree-staff-kpi-card.is-danger .arttree-kpi-icon{background:#fef2f2;color:#b42318;border-color:rgba(180,35,24,.14)}
.arttree-staff-stat-card.is-neutral .arttree-kpi-icon,.arttree-staff-kpi-card.is-neutral .arttree-kpi-icon{background:#f4f4f5;color:#52525b;border-color:rgba(82,82,91,.14)}
.arttree-staff-kpi-strip{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.arttree-staff-kpi-card{position:relative;display:grid;grid-template-columns:52px minmax(0,1fr);gap:14px;align-items:center;padding:18px;border-radius:22px;background:#fff;border:1px solid rgba(80,61,122,.10);box-shadow:0 14px 36px rgba(37,28,50,.045);text-decoration:none;color:#251c32;overflow:hidden;transition:.2s ease}
.arttree-staff-kpi-card:hover{transform:translateY(-3px);box-shadow:0 18px 44px rgba(37,28,50,.075);border-color:rgba(80,61,122,.18)}
.arttree-staff-kpi-card > div{display:grid;gap:6px;min-width:0}
.arttree-kpi-source-note{margin:18px 0 0;color:#6f6579;font-size:13px;font-weight:800;line-height:1.7}
@media(max-width:1280px){.arttree-staff-kpi-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important}.arttree-staff-kpi-strip{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:760px){.arttree-staff-kpi-grid,.arttree-staff-kpi-strip{grid-template-columns:1fr!important}.arttree-staff-stat-card,.arttree-staff-kpi-card{grid-template-columns:46px minmax(0,1fr)!important;min-height:auto!important;padding:16px!important}.arttree-kpi-icon{width:46px;height:46px;border-radius:14px}.arttree-staff-stat-card strong,.arttree-staff-kpi-card strong{font-size:30px!important}}

/* v1.0.110 - Dashboard-only scoped barcode reader */
.arttree-dashboard-checkin-panel{
  display:block;
  margin:18px 0 26px;
  padding:20px;
  border:1px solid rgba(80,61,122,.12);
  border-radius:28px;
  background:linear-gradient(135deg, rgba(255,255,255,.98), rgba(250,247,255,.94));
  box-shadow:0 18px 50px rgba(35,25,55,.08);
}
.arttree-dashboard-checkin-grid{
  align-items:stretch;
  margin-top:16px;
}
.arttree-checkin-select-form label,
.arttree-dashboard-checkin-panel form label{
  display:grid;
  gap:8px;
  font-weight:900;
  color:#2a2036;
}
.arttree-checkin-select-form select,
.arttree-dashboard-checkin-panel input[type="text"]{
  width:100%;
  min-height:48px;
  border:1px solid rgba(80,61,122,.18);
  border-radius:16px;
  padding:10px 14px;
  background:#fff;
  color:#251c32;
  font-weight:800;
}
.arttree-dashboard-checkin-panel .arttree-checkin-card{
  border:1px solid rgba(80,61,122,.1);
  box-shadow:0 14px 34px rgba(35,25,55,.07);
}
.arttree-dashboard-checkin-panel .arttree-camera-box{
  min-height:240px;
  border-radius:22px;
  overflow:hidden;
}
.arttree-dashboard-checkin-panel .arttree-checkin-result{
  margin:14px 0;
}
@media(max-width:780px){
  .arttree-dashboard-checkin-panel{padding:14px;border-radius:22px}
  .arttree-dashboard-checkin-panel .arttree-camera-box{min-height:210px}
}

/* v1.0.111 - Staff workshop add/edit form inside dashboard */
.arttree-staff-title-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
}
.arttree-staff-form-card-wide,
.arttree-staff-list-card-wide{
  width:100%;
  max-width:none;
}
.arttree-staff-form-card-wide form{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}
.arttree-staff-form-card-wide form label.wide,
.arttree-staff-form-card-wide .arttree-staff-form-actions{
  grid-column:1/-1;
}
.arttree-staff-form-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  justify-content:flex-start;
  margin-top:4px;
}
.arttree-staff-row-actions a[href*="edit_training_id"]{
  font-weight:900;
}
@media(max-width:760px){
  .arttree-staff-form-card-wide form{grid-template-columns:1fr}
  .arttree-staff-title-actions{justify-content:flex-start;width:100%}
}


/* v1.0.112 - Conditional follow-up questions for low workshop ratings */
.arttree-low-rating-followup{
  margin:18px 0;
  padding:18px;
  border-radius:22px;
  background:linear-gradient(135deg, rgba(255,248,236,.96), rgba(255,255,255,.98));
  border:1px solid rgba(184,119,34,.2);
  box-shadow:0 16px 36px rgba(122,76,22,.08);
  display:grid;
  gap:14px;
}
.arttree-low-rating-followup[hidden]{display:none!important}
.arttree-low-rating-head{
  display:grid;
  gap:5px;
}
.arttree-low-rating-head strong{
  font-size:18px;
  color:#2b2039;
  font-weight:950;
}
.arttree-low-rating-head span{
  color:#7f6f4d;
  font-weight:800;
  line-height:1.8;
}
.arttree-low-rating-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}
.arttree-low-rating-followup label{
  display:grid;
  gap:8px;
  color:#2b2039;
  font-weight:900;
}
.arttree-low-rating-followup select,
.arttree-low-rating-followup textarea{
  width:100%;
  border:1px solid rgba(80,61,122,.18);
  border-radius:16px;
  background:#fff;
  padding:12px 14px;
  color:#2b2039;
  font-weight:800;
}
.arttree-low-rating-followup textarea{
  min-height:104px;
  resize:vertical;
  line-height:1.8;
}
@media(max-width:760px){
  .arttree-low-rating-grid{grid-template-columns:1fr}
  .arttree-low-rating-followup{padding:14px;border-radius:18px}
}

/* v1.0.113 - Staff dashboard responsive hardening for mobile and iPad */
body.dewan-staff-dashboard-view{
  touch-action:manipulation;
  -webkit-text-size-adjust:100%;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell *{
  box-sizing:border-box;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-toggle{
  display:none!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
  overflow:hidden!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-panel,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-form-card,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-list-card,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-detail-block,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-checkin-card{
  min-width:0!important;
  overflow:hidden;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-table-wrap,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-responsive-table,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell table{
  max-width:100%!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-table-wrap,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-responsive-table{
  overflow-x:auto!important;
  -webkit-overflow-scrolling:touch;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell table{
  min-width:760px;
  border-collapse:separate;
  border-spacing:0;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell input,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell select,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell textarea,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell button,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-btn,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .button{
  max-width:100%;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell input,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell select,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell textarea{
  font-size:16px!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-dim{
  display:none;
}
@media(min-width:901px) and (max-width:1180px){
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    width:250px!important;
    min-width:250px!important;
    max-width:250px!important;
    padding:18px 12px 24px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    width:calc(100vw - 250px)!important;
    max-width:calc(100vw - 250px)!important;
    margin-right:250px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group a{
    padding:9px 10px!important;
    font-size:13px!important;
    min-height:40px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    padding:20px 18px 56px!important;
  }
  .arttree-staff-kpi-grid,
  .arttree-staff-stat-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}
@media(max-width:900px){
  html:has(body.dewan-staff-dashboard-view),
  body.dewan-staff-dashboard-view{
    overflow-x:hidden!important;
    background:#f7f7f8!important;
  }
  body.dewan-staff-dashboard-view.is-dashboard-menu-locked{
    overflow:hidden!important;
  }
  body.dewan-staff-dashboard-view .site-header,
  body.dewan-staff-dashboard-view .site-footer,
  body.dewan-staff-dashboard-view .entry-header,
  body.dewan-staff-dashboard-view .page-header{
    display:none!important;
  }
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal,
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    width:100vw!important;
    max-width:100vw!important;
    min-width:0!important;
    min-height:100dvh!important;
  }
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell{
    display:block!important;
    padding:0!important;
    margin:0!important;
    background:#f7f7f8!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-bar{
    position:sticky!important;
    top:0!important;
    z-index:35!important;
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    width:100%!important;
    max-width:100%!important;
    margin:0!important;
    padding:12px 14px!important;
    min-height:64px!important;
    background:rgba(255,255,255,.96)!important;
    backdrop-filter:blur(14px);
    border-bottom:1px solid rgba(80,61,122,.10)!important;
    box-shadow:0 10px 26px rgba(37,28,50,.045)!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-user{
    min-width:0!important;
    display:flex!important;
    align-items:center!important;
    gap:9px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-user span{
    max-width:58vw!important;
    overflow:hidden!important;
    white-space:nowrap!important;
    text-overflow:ellipsis!important;
    font-size:13px!important;
    font-weight:900!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-toggle{
    flex:0 0 auto!important;
    min-width:46px!important;
    min-height:46px!important;
    border-radius:15px!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    width:100%!important;
    max-width:100%!important;
    margin:0!important;
    padding:16px 12px 44px!important;
    display:grid!important;
    gap:14px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    position:fixed!important;
    top:0!important;
    right:0!important;
    left:auto!important;
    bottom:0!important;
    width:min(88vw,360px)!important;
    min-width:0!important;
    max-width:min(88vw,360px)!important;
    height:100dvh!important;
    padding:18px 14px 26px!important;
    border-radius:0!important;
    z-index:50!important;
    background:#fff!important;
    overflow:auto!important;
    -webkit-overflow-scrolling:touch;
    transform:translate3d(110%,0,0)!important;
    transition:transform .24s ease!important;
    box-shadow:-18px 0 48px rgba(37,28,50,.18)!important;
    pointer-events:none!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-mobile-menu-open .arttree-dashboard-sidebar{
    transform:translate3d(0,0,0)!important;
    pointer-events:auto!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-dim{
    display:block!important;
    position:fixed!important;
    inset:0!important;
    z-index:45!important;
    width:100vw!important;
    height:100dvh!important;
    background:rgba(37,28,50,.42)!important;
    border:0!important;
    opacity:0!important;
    visibility:hidden!important;
    pointer-events:none!important;
    transition:opacity .2s ease,visibility .2s ease!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-mobile-menu-open .arttree-dashboard-dim{
    opacity:1!important;
    visibility:visible!important;
    pointer-events:auto!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-drawer-head{
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:10px!important;
    margin-bottom:12px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand{
    display:flex!important;
    padding:12px 8px 14px!important;
    margin-bottom:10px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand img{
    width:124px!important;
    max-height:74px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group{
    padding:8px 0!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group a{
    min-height:44px!important;
    margin:3px 0!important;
    border-radius:14px!important;
    font-size:13px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-panel-title-row,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-title-actions,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-form-actions,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-form-actions{
    flex-direction:column!important;
    align-items:stretch!important;
    justify-content:flex-start!important;
    gap:10px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-panel-title-row > *,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-title-actions > *,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-form-actions > *,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-form-actions > *{
    width:100%!important;
  }
  .arttree-staff-kpi-grid,
  .arttree-staff-stat-grid,
  .arttree-dashboard-checkin-grid,
  .arttree-low-rating-grid,
  .arttree-staff-form-card-wide form{
    grid-template-columns:1fr!important;
  }
}
@media(max-width:640px){
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-panel,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-form-card,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-list-card,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-detail-block,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-checkin-card{
    padding:14px!important;
    border-radius:20px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell h1,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-panel h2{
    font-size:clamp(20px,6vw,28px)!important;
    line-height:1.35!important;
  }
  .arttree-staff-kpi-card,
  .arttree-staff-stat-card{
    min-height:auto!important;
    padding:16px!important;
    border-radius:18px!important;
  }
  .arttree-staff-kpi-card strong,
  .arttree-staff-stat-card strong{
    font-size:30px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell table{
    min-width:680px!important;
    font-size:13px!important;
  }
}
@media(max-width:420px){
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-content{
    padding-inline:10px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-sidebar{
    width:92vw!important;
    max-width:92vw!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-mobile-user span{
    max-width:48vw!important;
  }
}

/* v1.0.114 - Complete evaluations dashboard */
.arttree-staff-evaluations-panel .arttree-staff-filter-bar{
  display:flex;
  align-items:flex-end;
  gap:12px;
  flex-wrap:wrap;
  margin:18px 0;
  padding:14px;
  border:1px solid rgba(80,61,122,.12);
  border-radius:20px;
  background:rgba(255,255,255,.76);
}
.arttree-staff-evaluations-panel .arttree-staff-filter-bar label{min-width:260px;flex:1}
.arttree-staff-evaluations-panel .arttree-staff-filter-bar span{display:block;margin-bottom:7px;font-weight:900;color:#3a2d55}
.arttree-staff-evaluations-panel .arttree-staff-filter-bar select{width:100%;min-height:46px;border-radius:14px;border:1px solid rgba(80,61,122,.18);padding:0 14px;background:#fff;color:#251c32;font-weight:800}
.arttree-staff-evaluation-kpis{margin-top:18px}
.arttree-staff-evaluation-issues{margin:18px 0;padding:18px;border-radius:22px;background:linear-gradient(135deg,rgba(80,61,122,.08),rgba(247,244,238,.86));border:1px solid rgba(80,61,122,.12)}
.arttree-staff-evaluation-issues h4{margin:0 0 12px;color:#251c32;font-size:18px}
.arttree-staff-evaluation-issue-list{display:flex;gap:10px;flex-wrap:wrap}
.arttree-staff-evaluation-issue-list span{display:inline-flex;align-items:center;gap:10px;padding:10px 14px;border-radius:999px;background:#fff;border:1px solid rgba(80,61,122,.12);box-shadow:0 8px 22px rgba(80,61,122,.08)}
.arttree-staff-evaluation-issue-list strong{font-size:13px;color:#3a2d55}
.arttree-staff-evaluation-issue-list em{font-style:normal;min-width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:#503d7a;color:#fff;font-weight:950;font-size:12px}
.arttree-staff-evaluations-table details{margin-top:8px}
.arttree-staff-evaluations-table summary{cursor:pointer;font-weight:900;color:#503d7a}
.arttree-staff-evaluations-table details p{margin:8px 0 0;line-height:1.7;white-space:normal;color:#4d435f}
.arttree-staff-score-badge{display:inline-flex;align-items:center;justify-content:center;min-width:72px;padding:8px 10px;border-radius:999px;font-weight:950;font-size:13px;background:rgba(35,132,67,.10);color:#1c6b38}
.arttree-staff-score-badge.danger{background:rgba(183,66,58,.10);color:#9f2f29}
.arttree-staff-evaluations-table tr.is-low-rating{background:rgba(183,66,58,.035)}
.arttree-staff-inline-link{display:inline-flex;align-items:center;justify-content:center;padding:8px 10px;border-radius:999px;background:rgba(80,61,122,.10);color:#503d7a!important;font-weight:950;text-decoration:none!important}
@media(max-width:780px){
  .arttree-staff-evaluations-panel .arttree-staff-filter-bar{align-items:stretch}
  .arttree-staff-evaluations-panel .arttree-staff-filter-bar label{min-width:100%}
  .arttree-staff-evaluations-panel .arttree-staff-filter-bar .arttree-rt-primary,
  .arttree-staff-evaluations-panel .arttree-staff-filter-bar .arttree-rt-secondary{width:100%;text-align:center;justify-content:center}
}


/* v1.0.116 - staged evaluation flow */
.arttree-workshop-evaluation .arttree-evaluation-grid{
  display:flex;
  flex-direction:column;
  gap:14px;
}
.arttree-workshop-evaluation .arttree-evaluation-stage{
  display:flex;
  flex-direction:column;
  gap:9px;
  padding:18px;
  border:1px solid rgba(80,61,122,.12);
  border-radius:22px;
  background:linear-gradient(180deg,#fff,rgba(248,245,239,.88));
  box-shadow:0 14px 34px rgba(37,28,50,.06);
  animation:arttreeStageIn .26s ease both;
}
.arttree-workshop-evaluation .arttree-evaluation-stage[hidden],
.arttree-workshop-evaluation [data-evaluation-open-notes][hidden],
.arttree-workshop-evaluation [data-evaluation-submit][hidden],
.arttree-workshop-evaluation [data-low-rating-followup][hidden]{
  display:none!important;
}
.arttree-workshop-evaluation .arttree-evaluation-step-index{
  align-self:flex-start;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:28px;
  padding:5px 12px;
  border-radius:999px;
  background:rgba(80,61,122,.09);
  color:#503d7a;
  font-size:12px;
  font-weight:950;
}
.arttree-workshop-evaluation .arttree-evaluation-stage strong{
  color:#251c32;
  font-size:17px;
  font-weight:950;
}
.arttree-workshop-evaluation .arttree-evaluation-stage small{
  color:#7b7186;
  font-weight:800;
  line-height:1.7;
}
.arttree-workshop-evaluation .arttree-evaluation-stage select,
.arttree-workshop-evaluation .arttree-evaluation-stage textarea,
.arttree-workshop-evaluation .arttree-low-rating-followup select,
.arttree-workshop-evaluation .arttree-low-rating-followup textarea{
  width:100%;
}
.arttree-workshop-evaluation .arttree-low-rating-followup.is-visible{
  margin-top:16px;
  border-color:rgba(202,92,92,.24);
  background:linear-gradient(180deg,#fff7f6,#fff);
}
.arttree-workshop-evaluation .arttree-evaluation-textareas.is-visible{
  display:flex;
  flex-direction:column;
  gap:14px;
  margin-top:16px;
}
.arttree-workshop-evaluation .arttree-evaluation-submit.is-visible{
  display:inline-flex;
  margin-top:16px;
}
@keyframes arttreeStageIn{
  from{opacity:0;transform:translateY(8px)}
  to{opacity:1;transform:translateY(0)}
}
@media(max-width:720px){
  .arttree-workshop-evaluation .arttree-evaluation-stage{padding:15px;border-radius:18px}
}

/* v1.0.117 - low rating reason inside current evaluation stage */
.arttree-workshop-evaluation .arttree-low-rating-followup{
  margin:0 0 18px;
  border:1px solid rgba(183,66,58,.16);
  background:linear-gradient(135deg,rgba(255,247,237,.96),rgba(255,255,255,.98));
}
.arttree-workshop-evaluation .arttree-low-rating-followup.is-visible{
  animation:arttreeLowRatingIn .22s ease both;
}
.arttree-low-rating-actions{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}
.arttree-low-rating-actions button{
  border:0;
  border-radius:999px;
  min-height:44px;
  padding:0 20px;
  font-weight:950;
  cursor:pointer;
}
.arttree-low-rating-next{
  background:#503d7a;
  color:#fff;
  box-shadow:0 12px 24px rgba(80,61,122,.18);
}
.arttree-low-rating-back{
  background:#f1edf8;
  color:#503d7a;
}
@keyframes arttreeLowRatingIn{
  from{opacity:0;transform:translateY(-6px)}
  to{opacity:1;transform:translateY(0)}
}
@media(max-width:640px){
  .arttree-low-rating-actions button{width:100%;justify-content:center}
}

/* v1.0.119 - custom attendance certificate layout */
.arttree-certificate-document{margin-top:24px;display:grid;gap:18px;justify-items:center}
.arttree-certificate-frame{width:min(1120px,100%);min-height:760px;background:linear-gradient(180deg,#ffffff,#faf7ff);border:2px solid rgba(80,61,122,.18);border-radius:36px;padding:68px 64px 190px;box-shadow:0 22px 60px rgba(80,61,122,.12);position:relative;overflow:hidden;direction:rtl}
.arttree-certificate-frame:before{content:"";position:absolute;inset:18px;border:1px solid rgba(80,61,122,.14);border-radius:28px;pointer-events:none}
.arttree-certificate-brand{position:absolute;top:34px;right:34px;width:132px;height:132px;display:flex;align-items:center;justify-content:center}
.arttree-certificate-brand img{max-width:100%;max-height:100%;object-fit:contain}
.arttree-certificate-body{text-align:center;max-width:760px;margin:0 auto;padding-top:18px}
.arttree-certificate-ar-title{margin:0;color:#503d7a;font-size:54px;line-height:1.15;font-weight:900}
.arttree-certificate-en-title{margin:12px 0 0;color:#7a6b91;font-size:24px;font-weight:800;letter-spacing:.18em}
.arttree-certificate-company{margin:48px 0 10px;color:#221637;font-size:26px;font-weight:700;line-height:1.9}
.arttree-certificate-line{margin:8px 0;color:#4d3a74;font-size:25px;line-height:2}
.arttree-certificate-line strong{color:#251a3d;font-size:1.06em}
.arttree-certificate-subject{margin-top:18px}
.arttree-certificate-training-name{display:inline-block;margin-top:12px;padding:8px 18px;border-radius:999px;background:#f4eefc;color:#503d7a;font-weight:800;font-size:24px;line-height:1.8}
.arttree-certificate-wish{margin:34px 0 18px;color:#6d607d;font-size:24px;font-weight:700}
.arttree-certificate-signature{margin-top:26px;display:grid;gap:8px;justify-items:center}
.arttree-certificate-signature strong{font-size:28px;color:#251a3d}
.arttree-certificate-signature span{font-size:20px;color:#7a6b91;font-weight:700}
.arttree-certificate-side-meta{position:absolute;left:38px;bottom:34px;max-width:280px;text-align:right;background:rgba(255,255,255,.92);border:1px solid rgba(80,61,122,.12);border-radius:24px;padding:18px 18px 16px;box-shadow:0 12px 30px rgba(80,61,122,.08)}
.arttree-certificate-side-meta-item{display:grid;gap:4px;margin-bottom:12px}
.arttree-certificate-side-meta-item:last-of-type{margin-bottom:0}
.arttree-certificate-side-meta strong{font-size:14px;color:#7a6b91}
.arttree-certificate-side-meta span,.arttree-certificate-side-meta code{font-size:18px;color:#251a3d;font-weight:800;word-break:break-word}
.arttree-certificate-side-meta code{font-family:inherit;background:#f4eefc;border-radius:12px;padding:6px 10px}
.arttree-certificate-qr{display:grid;grid-template-columns:76px 1fr;gap:12px;align-items:center;margin:14px 0 10px}
.arttree-certificate-qr img{width:76px;height:76px;border-radius:14px;background:#fff;padding:6px;border:1px solid rgba(80,61,122,.10)}
.arttree-certificate-qr-badge{display:inline-flex;align-items:center;justify-content:center;min-width:52px;border-radius:999px;background:#503d7a;color:#fff;padding:8px 14px;font-weight:800;letter-spacing:.12em}
.arttree-certificate-verify-note{margin:0;color:#6d607d;font-size:15px;line-height:1.8}
.arttree-certificate-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px;justify-content:center}
.arttree-certificate-actions a,.arttree-certificate-actions button{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:#503d7a;color:#fff;text-decoration:none;padding:10px 18px;border:0;font-size:15px;cursor:pointer}
.arttree-certificate-actions a + a,.arttree-certificate-actions button + a{background:#f1edf8;color:#503d7a}
@media(max-width:900px){.arttree-certificate-frame{padding:52px 28px 210px;min-height:auto}.arttree-certificate-brand{top:22px;right:22px;width:94px;height:94px}.arttree-certificate-ar-title{font-size:40px}.arttree-certificate-company,.arttree-certificate-line{font-size:21px}.arttree-certificate-training-name{font-size:21px}.arttree-certificate-wish{font-size:21px}.arttree-certificate-signature strong{font-size:24px}.arttree-certificate-side-meta{position:static;max-width:none;margin-top:34px}}
@media(max-width:640px){.arttree-certificate-en-title{font-size:18px;letter-spacing:.08em}.arttree-certificate-company,.arttree-certificate-line{font-size:18px;line-height:1.9}.arttree-certificate-training-name{font-size:18px}.arttree-certificate-side-meta{padding:16px}.arttree-certificate-qr{grid-template-columns:64px 1fr}.arttree-certificate-qr img{width:64px;height:64px}}

/* v1.0.120 - certificate PDF layout and stage-by-stage evaluation */
.arttree-certificate-signature{position:absolute!important;left:46px!important;bottom:48px!important;margin:0!important;display:grid!important;gap:6px!important;justify-items:flex-start!important;text-align:left!important}
.arttree-certificate-signature strong{font-size:24px!important;color:#251a3d!important}
.arttree-certificate-signature span{font-size:16px!important;color:#7a6b91!important;font-weight:700!important}
.arttree-certificate-side-meta{position:absolute!important;right:38px!important;bottom:34px!important;left:auto!important;max-width:245px!important;text-align:right!important;background:rgba(255,255,255,.72)!important;border:1px solid rgba(80,61,122,.10)!important;border-radius:20px!important;padding:14px 14px 12px!important;box-shadow:0 10px 24px rgba(80,61,122,.06)!important}
.arttree-certificate-side-meta strong{font-size:12px!important;color:#7a6b91!important}
.arttree-certificate-side-meta span,.arttree-certificate-side-meta code{font-size:14px!important;color:#251a3d!important;font-weight:800!important;word-break:break-word!important}
.arttree-certificate-qr{display:grid!important;grid-template-columns:56px 1fr!important;gap:10px!important;align-items:center!important;margin:10px 0 8px!important}
.arttree-certificate-qr img{width:56px!important;height:56px!important;border-radius:12px!important;background:#fff!important;padding:5px!important;border:1px solid rgba(80,61,122,.10)!important}
.arttree-certificate-verify-note{margin:0!important;color:#6d607d!important;font-size:12px!important;line-height:1.6!important}
.arttree-workshop-evaluation .arttree-evaluation-stage.is-collapsed{display:none!important}
.arttree-workshop-evaluation .arttree-evaluation-stage.is-visible{display:grid!important;animation:arttreeEvalStageIn .22s ease both}
@keyframes arttreeEvalStageIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
@media(max-width:900px){.arttree-certificate-signature{position:static!important;margin-top:26px!important;justify-items:center!important;text-align:center!important}.arttree-certificate-side-meta{position:static!important;max-width:none!important;margin-top:28px!important}.arttree-certificate-frame{padding-bottom:52px!important}}

/* v1.0.121 - direct certificate PDF download and softer certificate footer */
.arttree-pdf-workarea .arttree-certificate-document{margin:0!important}
.arttree-certificate-actions [data-certificate-pdf-download],
.arttree-action-pill[data-certificate-pdf-download]{cursor:pointer}
.arttree-certificate-signature{left:38px!important;bottom:42px!important;text-align:left!important;justify-items:flex-start!important}
.arttree-certificate-signature strong{font-size:22px!important;font-weight:900!important}
.arttree-certificate-signature span{font-size:14px!important;color:#7d6d91!important}
.arttree-certificate-side-meta{right:34px!important;left:auto!important;bottom:30px!important;max-width:220px!important;padding:12px!important;border-radius:18px!important;background:rgba(255,255,255,.66)!important;box-shadow:0 8px 22px rgba(80,61,122,.05)!important}
.arttree-certificate-side-meta strong{font-size:11px!important}
.arttree-certificate-side-meta span,.arttree-certificate-side-meta code{font-size:13px!important}
.arttree-certificate-qr{grid-template-columns:48px 1fr!important;gap:8px!important;margin:8px 0!important}
.arttree-certificate-qr img{width:48px!important;height:48px!important;border-radius:10px!important;padding:4px!important}
.arttree-certificate-qr-badge{min-width:42px!important;padding:6px 10px!important;font-size:11px!important}
.arttree-certificate-verify-note{font-size:11px!important;line-height:1.5!important}
@media(max-width:900px){.arttree-certificate-signature{position:static!important;margin-top:28px!important;text-align:center!important;justify-items:center!important}.arttree-certificate-side-meta{position:static!important;max-width:none!important;margin-top:24px!important}}

/* v1.0.122 - one page hero style certificate */
.arttree-certificate-document{margin:0;display:grid;gap:16px;justify-items:center}
.arttree-certificate-frame{width:min(1120px,100%);min-height:720px;background:radial-gradient(circle at 12% 18%,rgba(170,132,220,.30),transparent 32%),radial-gradient(circle at 85% 88%,rgba(80,61,122,.18),transparent 30%),linear-gradient(135deg,#ffffff 0%,#faf7ff 48%,#f2ebfb 100%)!important;border:0!important;border-radius:0!important;padding:54px 62px 78px!important;box-shadow:none!important;position:relative;overflow:hidden;direction:rtl;display:grid;grid-template-columns:minmax(235px,.72fr) minmax(0,1.25fr) minmax(220px,.66fr);gap:28px;align-items:stretch}
.arttree-certificate-frame:before{content:""!important;position:absolute;inset:auto -90px -130px auto!important;width:460px!important;height:460px!important;border:0!important;border-radius:50%!important;background:rgba(80,61,122,.08)!important;pointer-events:none}
.arttree-certificate-frame:after{content:"";position:absolute;inset:-140px auto auto -110px;width:390px;height:390px;border-radius:50%;background:rgba(80,61,122,.09);pointer-events:none}
.arttree-certificate-brand{position:absolute!important;top:34px!important;right:34px!important;width:116px!important;height:116px!important;display:flex;align-items:center;justify-content:center;z-index:2}
.arttree-certificate-brand img{max-width:100%;max-height:100%;object-fit:contain}
.arttree-certificate-body{position:relative;z-index:2;text-align:center;max-width:680px;margin:0 auto;padding-top:32px;grid-column:2}
.arttree-certificate-ar-title{margin:0;color:#503d7a;font-size:50px;line-height:1.15;font-weight:950}
.arttree-certificate-en-title{margin:10px 0 0;color:#7a6b91;font-size:21px;font-weight:900;letter-spacing:.16em}
.arttree-certificate-company{margin:42px 0 8px;color:#221637;font-size:24px;font-weight:800;line-height:1.85}
.arttree-certificate-line{margin:8px 0;color:#4d3a74;font-size:23px;line-height:1.85}
.arttree-certificate-line strong{color:#251a3d;font-size:1.06em}
.arttree-certificate-subject{margin-top:16px}
.arttree-certificate-training-name{display:inline-block;margin-top:10px;padding:8px 18px;border-radius:28px;background:rgba(255,255,255,.68);color:#503d7a;font-weight:900;font-size:22px;line-height:1.7;box-shadow:0 10px 30px rgba(80,61,122,.08)}
.arttree-certificate-wish{margin:30px 0 0;color:#6d607d;font-size:22px;font-weight:800}
.arttree-certificate-signature{position:relative!important;z-index:2;grid-column:1;align-self:end;justify-self:start;margin:0!important;display:grid;gap:6px;text-align:right;padding:0 0 8px 0}
.arttree-certificate-signature strong{font-size:24px;color:#251a3d}
.arttree-certificate-signature span{font-size:16px;color:#7a6b91;font-weight:800}
.arttree-certificate-side-meta{position:relative!important;z-index:2;grid-column:3;align-self:end;justify-self:end;max-width:220px;text-align:right;background:rgba(255,255,255,.42)!important;backdrop-filter:blur(6px);border:0!important;border-radius:22px;padding:12px 14px 12px;box-shadow:none!important}
.arttree-certificate-side-meta-item{display:grid;gap:3px;margin-bottom:10px}
.arttree-certificate-side-meta-item:last-of-type{margin-bottom:0}
.arttree-certificate-side-meta strong{font-size:11px;color:#7a6b91}
.arttree-certificate-side-meta span,.arttree-certificate-side-meta code{font-size:13px;color:#251a3d;font-weight:900;word-break:break-word}
.arttree-certificate-side-meta code{font-family:inherit;background:rgba(80,61,122,.08);border-radius:10px;padding:5px 8px}
.arttree-certificate-qr{display:flex;align-items:center;gap:8px;margin:8px 0 7px}
.arttree-certificate-qr img{width:48px!important;height:48px!important;border-radius:10px;background:#fff;padding:4px;border:0!important}
.arttree-certificate-qr-badge{display:inline-flex;align-items:center;justify-content:center;min-width:40px;border-radius:999px;background:#503d7a;color:#fff;padding:6px 10px;font-weight:900;font-size:11px;letter-spacing:.10em}
.arttree-certificate-verify-note{margin:0;color:#6d607d;font-size:11px;line-height:1.55}
@media print{.arttree-certificate-document{margin:0!important}.arttree-certificate-frame{width:100%!important;min-height:100vh!important;box-shadow:none!important}}
@media(max-width:900px){.arttree-certificate-frame{min-height:auto;grid-template-columns:1fr;padding:38px 24px 42px!important}.arttree-certificate-brand{position:relative!important;top:auto!important;right:auto!important;width:88px!important;height:88px!important;margin:0 auto;grid-column:auto}.arttree-certificate-body,.arttree-certificate-signature,.arttree-certificate-side-meta{grid-column:auto;justify-self:center;text-align:center}.arttree-certificate-ar-title{font-size:38px}.arttree-certificate-company,.arttree-certificate-line{font-size:19px}.arttree-certificate-training-name{font-size:18px}.arttree-certificate-wish{font-size:19px}.arttree-certificate-signature{justify-self:center}.arttree-certificate-side-meta{max-width:100%;margin-top:8px}.arttree-certificate-qr{justify-content:center}}
@media(max-width:640px){.arttree-certificate-en-title{font-size:16px;letter-spacing:.08em}.arttree-certificate-company,.arttree-certificate-line{font-size:17px;line-height:1.8}.arttree-certificate-training-name{font-size:17px}}

/* v1.0.123 - staff sidebar expandable groups and icon-only mode */
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-toggle{
  display:inline-flex!important;
  position:fixed!important;
  top:18px!important;
  left:18px!important;
  z-index:45!important;
  align-items:center!important;
  gap:8px!important;
  height:42px!important;
  padding:0 14px!important;
  border:1px solid rgba(80,61,122,.12)!important;
  border-radius:999px!important;
  background:#fff!important;
  color:#503d7a!important;
  box-shadow:0 12px 28px rgba(37,28,50,.08)!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only{
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  padding:14px 8px 18px!important;
  margin:0 0 14px!important;
  border-bottom:1px solid rgba(80,61,122,.08)!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only img,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only img{
  width:176px!important;
  max-width:88%!important;
  height:auto!important;
  max-height:116px!important;
  object-fit:contain!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only strong,
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only small,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only strong,
.arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only small{display:none!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-details{
  border:1px solid rgba(80,61,122,.08)!important;
  border-radius:18px!important;
  padding:6px!important;
  background:#faf8fd!important;
  margin:0 0 10px!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-details summary{
  list-style:none!important;
  cursor:pointer!important;
  display:flex!important;
  align-items:center!important;
  gap:10px!important;
  min-height:42px!important;
  padding:9px 10px!important;
  border-radius:14px!important;
  color:#251c32!important;
  font-weight:950!important;
  user-select:none!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-details summary::-webkit-details-marker{display:none!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-details summary:hover{background:#f1edf8!important;color:#503d7a!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-details summary strong{font-size:13px!important;line-height:1.3!important;flex:1!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-caret{width:9px!important;height:9px!important;border-inline-end:2px solid currentColor!important;border-bottom:2px solid currentColor!important;transform:rotate(45deg)!important;transition:transform .2s ease!important;opacity:.65!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-details[open] .arttree-staff-menu-caret{transform:rotate(225deg)!important;margin-top:5px!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-sublist{display:grid!important;gap:6px!important;padding:4px 2px 4px!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group > strong{display:none!important}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group a{
  display:flex!important;
  align-items:center!important;
  gap:10px!important;
  border-radius:14px!important;
  min-height:42px!important;
}
body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-menu-group a span:last-child{white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
@media(min-width:901px){
  body.dewan-staff-dashboard-view .arttree-rt.arttree-staff-portal .arttree-staff-dashboard-shell.is-sidebar-hidden{
    grid-template-columns:96px minmax(0,1fr)!important;
    grid-template-areas:"sidebar top" "sidebar content"!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-dashboard-sidebar{
    width:96px!important;
    min-width:96px!important;
    max-width:96px!important;
    padding:18px 10px 22px!important;
    transform:none!important;
    opacity:1!important;
    pointer-events:auto!important;
    overflow-x:hidden!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-dashboard-mobile-bar,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-dashboard-content{
    width:calc(100vw - 96px)!important;
    max-width:calc(100vw - 96px)!important;
    margin-right:96px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-brand.dewan-staff-brand.is-logo-only img{
    width:58px!important;
    max-width:58px!important;
    max-height:58px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-dashboard-drawer-head,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-menu-details summary strong,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-menu-caret,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-menu-group a span:last-child,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-dashboard-toggle span:not(.arttree-dashboard-toggle-icon){display:none!important}
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-menu-details{
    background:transparent!important;
    border-color:transparent!important;
    padding:2px!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-menu-details summary,
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-menu-group a{
    justify-content:center!important;
    padding:10px!important;
    gap:0!important;
  }
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell.is-sidebar-hidden .arttree-staff-menu-sublist{padding:4px 0!important}
}
@media(max-width:900px){
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-dashboard-toggle{display:none!important}
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only{display:flex!important;padding:12px 8px!important}
  body.dewan-staff-dashboard-view .arttree-staff-dashboard-shell .arttree-staff-brand.dewan-staff-brand.is-logo-only img{width:128px!important;max-height:82px!important}
}


/* v1.0.124 - final one-page certificate fix */
';
        }
        return $label . ': ' . $value . "\n";
    }

    private function send_system_email($to, $subject, $message) {
        if (!$this->notifications_enabled()) {
            return false;
        }
        $to = sanitize_email($to);
        if (!$to) {
            return false;
        }
        $site_name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
        $subject = '[' . $site_name . '] ' . wp_specialchars_decode($subject, ENT_QUOTES);
        $body = trim((string) $message) . "\n\n" . 'هذه رسالة آلية من نظام ديوان الحلول.';
        return wp_mail($to, $subject, $body, ['Content-Type: text/plain; charset=UTF-8']);
    }

    private function notify_admin_event($subject, $message, $channel = 'general') {
        $this->send_system_email($this->notification_email($channel), $subject, $message);
    }

    private function notify_account_created($user_id) {
        $user = get_userdata($user_id);
        if (!$user) {
            return;
        }
        $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: $user->display_name;
        $phone = get_user_meta($user_id, 'arttree_applicant_phone', true);
        $portal_url = home_url('/registration-portal/');
        $this->send_system_email($user->user_email, 'تم إنشاء حسابك', "مرحباً " . $full_name . "\nتم إنشاء حسابك في بوابة المتقدم بنجاح.\nيمكنك الدخول إلى لوحة المتقدم من الرابط التالي:\n" . $portal_url);
        $message = "تم إنشاء حساب متقدم جديد.\n";
        $message .= $this->mail_line('الاسم', $full_name);
        $message .= $this->mail_line('البريد', $user->user_email);
        $message .= $this->mail_line('الجوال', $phone);
        $message .= $this->mail_line('رابط لوحة المتقدم', $portal_url);
        $this->notify_admin_event('تسجيل متقدم جديد', $message, 'general');
    }

    private function notify_profile_updated($user_id) {
        $user = get_userdata($user_id);
        if (!$user) {
            return;
        }
        $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: $user->display_name;
        $this->send_system_email($user->user_email, 'تم تحديث بياناتك', "مرحباً " . $full_name . "\nتم تحديث بياناتك في لوحة المتقدم بنجاح.");
        $message = "قام متقدم بتحديث بياناته.\n";
        $message .= $this->mail_line('الاسم', $full_name);
        $message .= $this->mail_line('البريد', $user->user_email);
        $message .= $this->mail_line('الجوال', get_user_meta($user_id, 'arttree_applicant_phone', true));
        $this->notify_admin_event('تحديث بيانات متقدم', $message, 'general');
    }

    private function notify_job_application_created($user_id, $job_id, $candidate_id = 0) {
        $user = get_userdata($user_id);
        if (!$user) {
            return;
        }
        $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: $user->display_name;
        $job_title = get_the_title($job_id);
        $this->send_system_email($user->user_email, 'تم استلام طلبك الوظيفي', "مرحباً " . $full_name . "\nتم استلام طلبك على وظيفة: " . $job_title . "\nيمكنك متابعة حالة الطلب من لوحة المتقدم.");
        $message = "تم استقبال طلب وظيفة جديد.\n";
        $message .= $this->mail_line('الوظيفة', $job_title);
        $message .= $this->mail_line('اسم المتقدم', $full_name);
        $message .= $this->mail_line('البريد', $user->user_email);
        $message .= $this->mail_line('الجوال', get_user_meta($user_id, 'arttree_applicant_phone', true));
        if ($candidate_id) {
            $message .= $this->mail_line('رقم الطلب', $candidate_id);
        }
        $this->notify_admin_event('طلب وظيفة جديد', $message, 'hr');
    }

    private function notify_training_registration_created($user_id, $item_id, $ticket_code = '') {
        $user = get_userdata($user_id);
        if (!$user) {
            return;
        }
        $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: $user->display_name;
        $title = get_the_title($item_id);
        $message_user = "مرحباً " . $full_name . "\nتم تسجيلك في: " . $title . "\n";
        $message_user .= $this->mail_line('التاريخ', $this->field($item_id, '_art_training_date'));
        $message_user .= $this->mail_line('الوقت', $this->field($item_id, '_art_training_time'));
        $message_user .= $this->mail_line('الموقع', $this->field($item_id, '_art_training_venue') ?: $this->field($item_id, '_art_training_location'));
        $message_user .= $this->mail_line('رمز الدخول', $ticket_code);
        $message_user .= "يمكنك عرض الباركود والتفاصيل من لوحة المتقدم:\n" . add_query_arg('portal_section', 'workshops', home_url('/registration-portal/'));
        $this->send_system_email($user->user_email, 'تم استلام تسجيلك', $message_user);
        $message_admin = "تم تسجيل مشارك جديد.\n";
        $message_admin .= $this->mail_line('الفعالية', $title);
        $message_admin .= $this->mail_line('اسم المشارك', $full_name);
        $message_admin .= $this->mail_line('البريد', $user->user_email);
        $message_admin .= $this->mail_line('الجوال', get_user_meta($user_id, 'arttree_applicant_phone', true));
        $message_admin .= $this->mail_line('رمز الدخول', $ticket_code);
        $this->notify_admin_event('تسجيل جديد في ورشة أو لقاء', $message_admin, 'training');
    }

    private function notify_training_registration_cancelled($user_id, $item_id) {
        $user = get_userdata($user_id);
        if (!$user) {
            return;
        }
        $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: $user->display_name;
        $title = get_the_title($item_id);
        $this->send_system_email($user->user_email, 'تم إلغاء تسجيلك', "مرحباً " . $full_name . "\nتم إلغاء تسجيلك في: " . $title);
        $message = "تم إلغاء تسجيل مشارك.\n";
        $message .= $this->mail_line('الفعالية', $title);
        $message .= $this->mail_line('اسم المشارك', $full_name);
        $message .= $this->mail_line('البريد', $user->user_email);
        $this->notify_admin_event('إلغاء تسجيل في ورشة أو لقاء', $message, 'training');
    }

    public function notify_password_reset_requested($user_login, $key) {
        $user = get_user_by('login', $user_login);
        if (!$user) {
            return;
        }
        $message = "تم طلب إعادة تعيين كلمة مرور.\n";
        $message .= $this->mail_line('اسم المستخدم', $user->display_name ?: $user->user_login);
        $message .= $this->mail_line('البريد', $user->user_email);
        $this->notify_admin_event('طلب تغيير كلمة مرور', $message, 'general');
    }

    public function notify_after_password_reset($user, $new_pass) {
        if (!$user instanceof WP_User) {
            return;
        }
        $this->send_system_email($user->user_email, 'تم تغيير كلمة المرور', "مرحباً " . ($user->display_name ?: $user->user_login) . "\nتم تغيير كلمة المرور لحسابك بنجاح. إذا لم تقم بهذا الإجراء يرجى التواصل مع إدارة الموقع فوراً.");
        $message = "تم تغيير كلمة مرور مستخدم.\n";
        $message .= $this->mail_line('اسم المستخدم', $user->display_name ?: $user->user_login);
        $message .= $this->mail_line('البريد', $user->user_email);
        $this->notify_admin_event('تم تغيير كلمة مرور', $message, 'general');
    }

    public function dashboard_page() {
        echo '<div class="wrap"><h1>Arttree HR - التوظيف والتدريب واللقاءات والورش</h1><p>هذا الإصدار يحتوي على الوظائف الشاغرة، طلبات المرشحين، مراحل التوظيف، التدريب، اللقاءات والورش، والشهادات.</p>';
        echo '<div class="arttree-admin-cards">';
        $cards = [
            'edit.php?post_type=art_job' => 'إدارة الوظائف الشاغرة',
            'edit.php?post_type=art_candidate' => 'طلبات المرشحين',
            'edit.php?post_type=art_training' => 'التدريب واللقاءات والورش',
            'edit.php?post_type=art_certificate' => 'الشهادات والتحقق',
            'admin.php?page=arttree-rt-settings' => 'إعدادات البريد',
            'post.php?post=' . $this->get_or_create_page('قارئ باركود الورش', 'workshop-checkin', '[arttree_workshop_checkin]') . '&action=edit' => 'صفحة قارئ باركود الورش',
        ];
        foreach ($cards as $url => $title) {
            printf('<a class="arttree-admin-card" href="%s">%s</a>', esc_url(admin_url($url)), esc_html($title));
        }
        echo '</div><h2>الشورتكودات</h2><code>[arttree_recruitment_portal]</code><br><code>[arttree_jobs]</code><br><code>[arttree_training_programs]</code><br><code>[arttree_events_workshops]</code><br><code>[arttree_trainings]</code><br><code>[arttree_certificate_verify]</code></div>';
    }

    public function settings_page() {
        $settings = $this->get_settings();
        echo '<div class="wrap"><h1>إعدادات Arttree Recruitment & Training</h1><form method="post" action="options.php">';
        settings_fields('arttree_rt_settings_group');
        echo '<table class="form-table" role="presentation">';
        printf('<tr><th>اسم الشركة</th><td><input class="regular-text" name="%s[company_name]" value="%s"></td></tr>', esc_attr(self::OPTION_KEY), esc_attr($settings['company_name']));
        printf('<tr><th>بريد الموارد البشرية</th><td><input class="regular-text" type="email" name="%s[hr_email]" value="%s"></td></tr>', esc_attr(self::OPTION_KEY), esc_attr($settings['hr_email']));
        printf('<tr><th>بريد التدريب</th><td><input class="regular-text" type="email" name="%s[training_email]" value="%s"></td></tr>', esc_attr(self::OPTION_KEY), esc_attr($settings['training_email']));
        printf('<tr><th>بريد الإشعارات العامة</th><td><input class="regular-text" type="email" name="%s[notifications_email]" value="%s"><p class="description">تصل إليه تنبيهات إنشاء الحسابات وتغيير كلمات المرور وتحديث بيانات المتقدمين.</p></td></tr>', esc_attr(self::OPTION_KEY), esc_attr($settings['notifications_email']));
        printf('<tr><th>تفعيل إشعارات البريد</th><td><label><input type="checkbox" name="%s[enable_email_notifications]" value="1" %s> تفعيل إرسال التنبيهات والإشعارات عبر البريد الإلكتروني</label></td></tr>', esc_attr(self::OPTION_KEY), checked(!empty($settings['enable_email_notifications']), true, false));
        echo '</table>';
        submit_button('حفظ الإعدادات');
        echo '</form></div>';
    }

    public function enqueue_assets() {
        wp_enqueue_style('arttree-rt', get_template_directory_uri() . '/assets/rt/css/public.css', [], self::VERSION);
        $controls = $this->get_theme_controls();
        wp_add_inline_style('arttree-rt', ':root{--arttree-control-primary:' . esc_html($controls['primary_color']) . ';--arttree-control-accent:' . esc_html($controls['accent_color']) . ';}');
        wp_enqueue_script('arttree-rt', get_template_directory_uri() . '/assets/rt/js/public.js', [], self::VERSION, true);
    }

    public function enqueue_admin_assets() {
        wp_enqueue_style('arttree-rt-admin', get_template_directory_uri() . '/assets/rt/css/admin.css', [], self::VERSION);
    }


    private function get_or_create_page($title, $slug, $content) {
        $existing = get_page_by_path($slug, OBJECT, 'page');
        if ($existing) {
            if (strpos((string) $existing->post_content, '[arttree_') !== false && trim((string) $existing->post_content) !== trim($content)) {
                wp_update_post([
                    'ID' => (int) $existing->ID,
                    'post_title' => $title,
                    'post_content' => $content,
                ]);
            }
            return (int) $existing->ID;
        }
        return (int) wp_insert_post([
            'post_type' => 'page',
            'post_status' => 'publish',
            'post_title' => $title,
            'post_name' => $slug,
            'post_content' => $content,
            'comment_status' => 'closed',
            'ping_status' => 'closed',
        ]);
    }

    private function create_demo_post_once($post_type, $title, $content, array $meta = []) {
        $found = get_page_by_title($title, OBJECT, $post_type);
        if ($found) {
            foreach ($meta as $key => $value) {
                if (get_post_meta($found->ID, $key, true) === '') {
                    update_post_meta($found->ID, $key, $value);
                }
            }
            return (int) $found->ID;
        }
        $post_id = wp_insert_post([
            'post_type' => $post_type,
            'post_status' => 'publish',
            'post_title' => $title,
            'post_content' => $content,
        ]);
        if ($post_id && !is_wp_error($post_id)) {
            foreach ($meta as $key => $value) {
                update_post_meta($post_id, $key, $value);
            }
            return (int) $post_id;
        }
        return 0;
    }

    public function maybe_seed_demo_content() {
        $seed_version = '1.0.48';
        if (get_option('arttree_rt_seed_version') === $seed_version) {
            return;
        }

        $this->get_or_create_page('بوابة المتقدمين', 'registration-portal', '[arttree_recruitment_portal]');
        $this->get_or_create_page('لوحة الموظفين', 'staff-dashboard', '[arttree_staff_dashboard]');
        $this->get_or_create_page('التوظيف والتدريب', 'careers', '[arttree_jobs]');
        $this->get_or_create_page('التجربة المهنية للمحاماة', 'training-programs', '[arttree_training_programs]');
        $this->get_or_create_page('اللقاءات والورش', 'events-workshops', '[arttree_events_workshops]');
        $this->get_or_create_page('التحقق من الشهادة', 'certificate-verify', '[arttree_certificate_verify]');
        $this->get_or_create_page('قارئ باركود الورش', 'workshop-checkin', '[arttree_workshop_checkin]');

        $jobs = [
            [
                'title' => 'محامي متدرب',
                'content' => 'فرصة تدريبية للانضمام إلى فريق التقاضي والعمل على ملفات قانونية متنوعة تحت إشراف محامين مرخصين.',
                'meta' => [
                    '_art_job_department' => 'الإدارة القانونية',
                    '_art_job_city' => 'الخبر',
                    '_art_job_status' => 'open',
                    '_art_job_type' => 'دوام كامل',
                    '_art_job_experience' => 'حديث تخرج',
                ],
            ],
            [
                'title' => 'مستشار قانوني عقود',
                'content' => 'نبحث عن مستشار قانوني لديه خبرة في صياغة العقود التجارية ومراجعة الاتفاقيات وتقديم الرأي النظامي.',
                'meta' => [
                    '_art_job_department' => 'العقود والاستشارات',
                    '_art_job_city' => 'الخبر',
                    '_art_job_status' => 'open',
                    '_art_job_type' => 'دوام كامل',
                    '_art_job_experience' => '3 سنوات فأكثر',
                ],
            ],
            [
                'title' => 'أخصائي علاقات عملاء',
                'content' => 'إدارة تواصل العملاء وتنظيم المواعيد ومتابعة طلبات الاستشارة بالتنسيق مع الفريق القانوني.',
                'meta' => [
                    '_art_job_department' => 'خدمة العملاء',
                    '_art_job_city' => 'الخبر',
                    '_art_job_status' => 'open',
                    '_art_job_type' => 'دوام كامل',
                    '_art_job_experience' => 'سنة إلى سنتين',
                ],
            ],
            [
                'title' => 'باحث قانوني',
                'content' => 'وظيفة تجريبية مغلقة لعرض شكل الوظائف التي انتهى التقديم عليها داخل البوابة.',
                'meta' => [
                    '_art_job_department' => 'البحوث القانونية',
                    '_art_job_city' => 'الخبر',
                    '_art_job_status' => 'closed',
                    '_art_job_type' => 'دوام كامل',
                    '_art_job_experience' => 'سنتان فأكثر',
                    '_art_job_deadline' => '2025-12-31',
                ],
            ],
        ];
        foreach ($jobs as $job) {
            $this->create_demo_post_once('art_job', $job['title'], $job['content'], $job['meta']);
        }

        $trainings = [
            [
                'title' => 'برنامج التجربة المهنية للمحاماة',
                'content' => 'برنامج تدريبي عملي لتعريف المتدربين ببيئة العمل القانونية وصياغة المذكرات ومتابعة الإجراءات والتواصل المهني داخل منشأة قانونية.',
                'meta' => [
                    '_art_training_date' => '2026-07-15',
                    '_art_training_time' => '10:00 صباحا',
                    '_art_training_location' => 'شركة ديوان الحلول - الخبر',
                    '_art_training_venue' => 'قاعة التدريب في شركة ديوان الحلول',
                    '_art_training_map_url' => 'https://maps.app.goo.gl/UnGXBqdJS4NjWkdg7',
                    '_art_training_supervisor_phone' => '0566499929',
                    '_art_training_status' => 'open',
                    '_art_training_type' => 'training',
                    '_art_training_capacity' => '25',
                    '_art_training_presenter' => 'فريق التدريب القانوني',
                    '_art_training_duration' => '4 أسابيع',
                    '_art_training_topics' => 'بيئة العمل القانوني\nصياغة المذكرات\nإجراءات التقاضي\nمهارات التواصل مع العملاء',
                    '_art_training_requirements' => 'طلاب وخريجو القانون والمهتمون بالممارسة المهنية للمحاماة.',
                ],
            ],
            [
                'title' => 'إدارة القضايا العمالية',
                'content' => 'لقاء تدريبي يشرح أهم الإجراءات النظامية في القضايا العمالية ومسارات التسوية والتقاضي.',
                'meta' => [
                    '_art_training_date' => '2026-08-05',
                    '_art_training_time' => '07:00 مساء',
                    '_art_training_location' => 'عن بعد',
                    '_art_training_venue' => 'عن بعد عبر رابط اللقاء',
                    '_art_training_map_url' => '',
                    '_art_training_supervisor_phone' => '0566499929',
                    '_art_training_status' => 'open',
                    '_art_training_type' => 'workshop',
                    '_art_training_capacity' => '40',
                    '_art_training_presenter' => 'مستشار قانوني متخصص',
                    '_art_training_duration' => 'ساعتان',
                    '_art_training_topics' => 'مراحل الدعوى العمالية\nالتسوية الودية\nإعداد المستندات\nأخطاء شائعة في القضايا العمالية',
                    '_art_training_requirements' => 'مناسبة لأصحاب الأعمال والموظفين والمهتمين بنظام العمل.',
                ],
            ],
            [
                'title' => 'مقدمة في الحوكمة والامتثال',
                'content' => 'برنامج تدريبي قصير حول بناء سياسات الامتثال وإدارة المخاطر القانونية داخل المنشآت.',
                'meta' => [
                    '_art_training_date' => '2026-08-20',
                    '_art_training_time' => '05:30 مساء',
                    '_art_training_location' => 'حضوري وعن بعد',
                    '_art_training_venue' => 'حضوري في الخبر وعن بعد',
                    '_art_training_map_url' => 'https://maps.app.goo.gl/UnGXBqdJS4NjWkdg7',
                    '_art_training_supervisor_phone' => '0566499929',
                    '_art_training_status' => 'open',
                    '_art_training_type' => 'training',
                    '_art_training_capacity' => '25',
                    '_art_training_presenter' => 'فريق التدريب القانوني',
                    '_art_training_duration' => '4 أسابيع',
                    '_art_training_topics' => 'بيئة العمل القانوني\nصياغة المذكرات\nإجراءات التقاضي\nمهارات التواصل مع العملاء',
                    '_art_training_requirements' => 'طلاب وخريجو القانون والمهتمون بالممارسة المهنية للمحاماة.',
                ],
            ],
            [
                'title' => 'أساسيات نظام العمل السعودي',
                'content' => 'ورشة تجريبية منتهية لعرض شكل اللقاءات والورش التي انتهى التسجيل عليها داخل الصفحة.',
                'meta' => [
                    '_art_training_date' => '2025-11-10',
                    '_art_training_time' => '06:00 مساء',
                    '_art_training_location' => 'عن بعد',
                    '_art_training_venue' => 'عن بعد عبر رابط اللقاء',
                    '_art_training_map_url' => '',
                    '_art_training_supervisor_phone' => '0566499929',
                    '_art_training_status' => 'closed',
                    '_art_training_type' => 'workshop',
                    '_art_training_capacity' => '40',
                    '_art_training_presenter' => 'مستشار قانوني متخصص',
                    '_art_training_duration' => 'ساعتان',
                    '_art_training_topics' => 'مراحل الدعوى العمالية\nالتسوية الودية\nإعداد المستندات\nأخطاء شائعة في القضايا العمالية',
                    '_art_training_requirements' => 'مناسبة لأصحاب الأعمال والموظفين والمهتمين بنظام العمل.',
                ],
            ],
        ];
        foreach ($trainings as $training) {
            $this->create_demo_post_once('art_training', $training['title'], $training['content'], $training['meta']);
        }

        // v1.0.95: لا يتم إنشاء مستخدمين تجريبيين بكلمات مرور معروفة في بيئة الإنتاج.

        update_option('arttree_rt_seed_version', $seed_version, false);
    }

    private function is_job_closed($job_id) {
        $status = $this->field($job_id, '_art_job_status', 'open');
        $deadline = $this->field($job_id, '_art_job_deadline');
        if ($status !== 'open') {
            return true;
        }
        if ($deadline && strtotime($deadline . ' 23:59:59') < current_time('timestamp')) {
            return true;
        }
        return false;
    }

    private function is_training_closed($training_id) {
        $status = $this->field($training_id, '_art_training_status', 'open');
        $date = $this->field($training_id, '_art_training_date');
        if ($status !== 'open') {
            return true;
        }
        if ($date && strtotime($date . ' 23:59:59') < current_time('timestamp')) {
            return true;
        }
        return false;
    }

    private function login_url($redirect = '') {
        $redirect = $redirect ? $redirect : home_url('/registration-portal/');
        return wp_login_url($redirect);
    }

    private function register_url($redirect = '') {
        $url = get_option('users_can_register') ? wp_registration_url() : home_url('/registration-portal/#create-account');
        return $redirect ? add_query_arg('redirect_to', $redirect, $url) : $url;
    }

    private function gate_url($type, $item_id) {
        return add_query_arg([
            'arttree_gate' => sanitize_key($type),
            'item_id' => absint($item_id),
        ], home_url('/registration-portal/'));
    }

    private function gate_label($type) {
        if ($type === 'job') { return 'التقديم على الوظيفة'; }
        if ($type === 'workshop') { return 'التسجيل في الورشة أو اللقاء'; }
        return 'التسجيل في البرنامج';
    }

    private function create_demo_applicant_users() {
        $demo_users = [
            [
                'login' => 'demo.applicant1',
                'email' => 'applicant1@example.com',
                'name' => 'سارة محمد القحطاني',
                'phone' => '0500000001',
                'city' => 'الخبر',
                'qualification' => 'بكالوريوس قانون',
                'jobs' => [['title' => 'محامي متدرب', 'status' => 'تحت المراجعة', 'date' => '2026-06-01']],
                'training' => [['title' => 'برنامج التجربة المهنية للمحاماة', 'status' => 'تم استلام التسجيل', 'date' => '2026-06-03']],
            ],
            [
                'login' => 'demo.applicant2',
                'email' => 'applicant2@example.com',
                'name' => 'عبدالله ناصر الدوسري',
                'phone' => '0500000002',
                'city' => 'الدمام',
                'qualification' => 'ماجستير أنظمة',
                'jobs' => [['title' => 'مستشار قانوني عقود', 'status' => 'مرشح للمقابلة', 'date' => '2026-06-02']],
                'training' => [],
            ],
            [
                'login' => 'demo.applicant3',
                'email' => 'applicant3@example.com',
                'name' => 'نورة خالد العتيبي',
                'phone' => '0500000003',
                'city' => 'الرياض',
                'qualification' => 'بكالوريوس شريعة',
                'jobs' => [],
                'training' => [['title' => 'إدارة القضايا العمالية', 'status' => 'بانتظار الاعتماد', 'date' => '2026-06-04']],
            ],
        ];

        foreach ($demo_users as $demo) {
            $user = get_user_by('login', $demo['login']);
            if (!$user) {
                $user_id = wp_create_user($demo['login'], 'Demo@12345', $demo['email']);
                if (is_wp_error($user_id)) {
                    continue;
                }
                wp_update_user([
                    'ID' => $user_id,
                    'display_name' => $demo['name'],
                    'first_name' => $demo['name'],
                ]);
                $user = get_user_by('id', $user_id);
            }
            if ($user) {
                update_user_meta($user->ID, 'arttree_applicant_user', 1);
                update_user_meta($user->ID, 'show_admin_bar_front', 'false');
                update_user_meta($user->ID, 'arttree_applicant_full_name', $demo['name']);
                update_user_meta($user->ID, 'arttree_applicant_phone', $demo['phone']);
                update_user_meta($user->ID, 'arttree_applicant_city', $demo['city']);
                update_user_meta($user->ID, 'arttree_applicant_qualification', $demo['qualification']);
                update_user_meta($user->ID, 'arttree_job_applications', $demo['jobs']);
                update_user_meta($user->ID, 'arttree_training_registrations', $demo['training']);
            }
        }
    }

    private function portal_notice() {
        if (empty($_GET['arttree_notice'])) {
            return '';
        }
        $notice = sanitize_key(wp_unslash($_GET['arttree_notice']));
        $messages = [
            'registered' => 'تم إنشاء الحساب وربط الطلب بالبوابة بنجاح.',
            'portal_only' => 'بوابة المتقدمين تعمل من الواجهة فقط ولا يسمح بالدخول إلى لوحة تحكم ووردبريس.',
            'logged_in' => 'تم تسجيل الدخول بنجاح.',
            'request_saved' => 'تم حفظ طلبك داخل لوحة المتقدم.',
            'exists' => 'هذا الطلب موجود مسبقاً في حسابك.',
            'registration_cancelled' => 'تم إلغاء التسجيل بنجاح.',
            'cannot_cancel_after_attendance' => 'لا يمكن إلغاء التسجيل بعد تسجيل الحضور بالباركود.',
            'evaluation_saved' => 'تم حفظ التقييم وإصدار الشهادة.',
            'attendance_required' => 'يجب تسجيل الحضور بالباركود قبل التقييم وإصدار الشهادة.',
            'profile_saved' => 'تم حفظ بياناتك بنجاح.',
        ];
        if (!isset($messages[$notice])) {
            return '';
        }
        return '<div class="arttree-portal-notice">' . esc_html($messages[$notice]) . '</div>';
    }

    private function portal_error() {
        if (empty($_GET['arttree_error'])) {
            return '';
        }
        $error = sanitize_key(wp_unslash($_GET['arttree_error']));
        $messages = [
            'missing' => 'يرجى تعبئة البيانات المطلوبة.',
            'email_exists' => 'البريد الإلكتروني مستخدم مسبقاً، يمكنك تسجيل الدخول بدلاً من إنشاء حساب جديد.',
            'phone_exists' => 'رقم الجوال مستخدم مسبقاً، يمكنك تسجيل الدخول برقم الجوال.',
            'weak_password' => 'كلمة المرور يجب ألا تقل عن 8 أحرف.',
            'login_failed' => 'بيانات الدخول غير صحيحة.',
            'nonce' => 'انتهت صلاحية النموذج، يرجى المحاولة مرة أخرى.',
        ];
        if (!isset($messages[$error])) {
            return '';
        }
        return '<div class="arttree-portal-error">' . esc_html($messages[$error]) . '</div>';
    }

    private function applicant_profile_complete($user_id) {
        $user = get_userdata($user_id);
        if (!$user || !$user->user_email) {
            return false;
        }
        $required = [
            'arttree_applicant_full_name',
            'arttree_applicant_phone',
            'arttree_applicant_city',
            'arttree_applicant_qualification',
        ];
        foreach ($required as $key) {
            if (!trim((string) get_user_meta($user_id, $key, true))) {
                return false;
            }
        }
        return true;
    }

    private function applicant_cv_url($user_id) {
        return trim((string) get_user_meta($user_id, 'arttree_applicant_cv_url', true));
    }

    private function quick_apply_redirect($job_id, $notice = '') {
        $args = ['portal_section' => 'jobs'];
        if ($notice) {
            $args['arttree_notice'] = $notice;
        }
        if ($job_id) {
            $args['job_id'] = absint($job_id);
        }
        return add_query_arg($args, home_url('/registration-portal/'));
    }

    private function create_user_request($user_id, $type, $item_id) {
        $type = sanitize_key($type);
        $item_id = absint($item_id);
        if (!$user_id || !$item_id || !in_array($type, ['job', 'training', 'workshop'], true)) {
            return 'none';
        }
        $title = get_the_title($item_id);
        if (!$title) {
            return 'none';
        }
        if ($type === 'job') {
            $items = get_user_meta($user_id, 'arttree_job_applications', true);
            $items = is_array($items) ? $items : [];
            foreach ($items as $item) {
                if (($item['item_id'] ?? 0) == $item_id || ($item['title'] ?? '') === $title) {
                    return 'exists';
                }
            }
            $items[] = [
                'item_id' => $item_id,
                'title' => $title,
                'status' => 'تم استلام الطلب',
                'date' => current_time('Y-m-d'),
            ];
            update_user_meta($user_id, 'arttree_job_applications', $items);

            $user = get_userdata($user_id);
            $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: $user->display_name;
            $candidate_id = wp_insert_post([
                'post_type' => 'art_candidate',
                'post_status' => 'publish',
                'post_title' => $full_name . ' - ' . $title,
            ]);
            if ($candidate_id && !is_wp_error($candidate_id)) {
                update_post_meta($candidate_id, '_art_candidate_full_name', $full_name);
                update_post_meta($candidate_id, '_art_candidate_email', $user->user_email);
                update_post_meta($candidate_id, '_art_candidate_phone', get_user_meta($user_id, 'arttree_applicant_phone', true));
                update_post_meta($candidate_id, '_art_candidate_city', get_user_meta($user_id, 'arttree_applicant_city', true));
                update_post_meta($candidate_id, '_art_candidate_qualification', get_user_meta($user_id, 'arttree_applicant_qualification', true));
                update_post_meta($candidate_id, '_art_candidate_cv_url', $this->applicant_cv_url($user_id));
                update_post_meta($candidate_id, '_art_candidate_job_title', $title);
                update_post_meta($candidate_id, '_art_candidate_status', 'received');
                update_post_meta($candidate_id, '_art_candidate_user_id', $user_id);
            }
            $this->notify_job_application_created($user_id, $item_id, $candidate_id && !is_wp_error($candidate_id) ? $candidate_id : 0);
            return 'created';
        }

        $items = get_user_meta($user_id, 'arttree_training_registrations', true);
        $items = is_array($items) ? $items : [];
        foreach ($items as $item) {
            if (($item['item_id'] ?? 0) == $item_id || ($item['title'] ?? '') === $title) {
                return 'exists';
            }
        }
        $user = get_userdata($user_id);
        $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: ($user ? $user->display_name : 'متقدم');
        $email = $user ? $user->user_email : '';
        $phone = get_user_meta($user_id, 'arttree_applicant_phone', true);
        $ticket_code = 'DHL-' . $item_id . '-' . $user_id . '-' . strtoupper(wp_generate_password(6, false, false));
        $checkin_url = add_query_arg(['staff_section' => 'attendance', 'arttree_training_id' => $item_id, 'arttree_checkin' => rawurlencode($ticket_code)], home_url('/staff-dashboard/'));
        $items[] = [
            'item_id' => $item_id,
            'title' => $title,
            'status' => 'تم استلام التسجيل',
            'date' => current_time('Y-m-d'),
            'type' => $type,
            'training_date' => $this->field($item_id, '_art_training_date'),
            'training_time' => $this->field($item_id, '_art_training_time'),
            'training_location' => $this->field($item_id, '_art_training_location'),
            'training_venue' => $this->field($item_id, '_art_training_venue'),
            'training_map_url' => $this->field($item_id, '_art_training_map_url'),
            'training_supervisor_phone' => $this->field($item_id, '_art_training_supervisor_phone'),
            'ticket_code' => $ticket_code,
            'checkin_url' => $checkin_url,
        ];
        update_user_meta($user_id, 'arttree_training_registrations', $items);

        $registrations = get_post_meta($item_id, '_art_training_registrations', true);
        $registrations = is_array($registrations) ? $registrations : [];
        $registrations[] = [
            'user_id' => $user_id,
            'name' => $full_name,
            'email' => $email,
            'phone' => $phone,
            'type' => $type,
            'ticket_code' => $ticket_code,
            'checkin_url' => $checkin_url,
            'status' => 'registered',
            'date' => current_time('mysql'),
        ];
        update_post_meta($item_id, '_art_training_registrations', $registrations);
        $this->notify_training_registration_created($user_id, $item_id, $ticket_code);
        return 'created';
    }


    private function user_is_registered_for_training($item_id, $user_id = 0) {
        $item_id = absint($item_id);
        $user_id = $user_id ? absint($user_id) : get_current_user_id();
        if (!$item_id || !$user_id) {
            return false;
        }
        $title = get_the_title($item_id);
        $items = get_user_meta($user_id, 'arttree_training_registrations', true);
        $items = is_array($items) ? $items : [];
        foreach ($items as $item) {
            if ((isset($item['item_id']) && absint($item['item_id']) === $item_id) || ($title && isset($item['title']) && $item['title'] === $title)) {
                return true;
            }
        }
        return false;
    }

    private function user_training_registration_item($item_id, $user_id = 0) {
        $item_id = absint($item_id);
        $user_id = $user_id ? absint($user_id) : get_current_user_id();
        if (!$item_id || !$user_id) {
            return null;
        }
        $title = get_the_title($item_id);
        $items = get_user_meta($user_id, 'arttree_training_registrations', true);
        $items = is_array($items) ? $items : [];
        foreach ($items as $item) {
            $matches = (isset($item['item_id']) && absint($item['item_id']) === $item_id) || ($title && isset($item['title']) && $item['title'] === $title);
            if ($matches) {
                return $item;
            }
        }
        return null;
    }

    private function user_training_registration_attended($item_id, $user_id = 0) {
        $item = $this->user_training_registration_item($item_id, $user_id);
        return is_array($item) && (($item['attendance_status'] ?? '') === 'attended');
    }

    private function training_cancel_form($item_id, $compact = false) {
        if (!is_user_logged_in() || !$this->user_is_registered_for_training($item_id)) {
            return '';
        }
        $item_id = absint($item_id);
        if ($this->user_training_registration_attended($item_id)) {
            return '<div class="arttree-cancel-locked">لا يمكن إلغاء التسجيل بعد تسجيل الحضور بالباركود.</div>';
        }
        $class = $compact ? 'arttree-cancel-registration-form compact' : 'arttree-cancel-registration-form';
        $html = '<form class="' . esc_attr($class) . '" method="post" action="' . esc_url(admin_url('admin-post.php')) . '">';
        $html .= '<input type="hidden" name="action" value="arttree_cancel_training_registration">';
        $html .= '<input type="hidden" name="item_id" value="' . esc_attr($item_id) . '">';
        $html .= wp_nonce_field('arttree_cancel_training_registration_' . $item_id, 'arttree_cancel_nonce', true, false);
        $html .= '<button class="arttree-cancel-registration-btn" type="submit">إلغاء التسجيل</button>';
        $html .= '</form>';
        return $html;
    }

    public function handle_cancel_training_registration() {
        if (!is_user_logged_in()) {
            wp_safe_redirect(add_query_arg('arttree_error', 'login_failed', home_url('/registration-portal/#login')));
            exit;
        }
        $item_id = absint($_POST['item_id'] ?? 0);
        if (!$item_id || !isset($_POST['arttree_cancel_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_cancel_nonce'])), 'arttree_cancel_training_registration_' . $item_id)) {
            wp_safe_redirect(add_query_arg('arttree_error', 'nonce', wp_get_referer() ?: home_url('/registration-portal/')));
            exit;
        }
        $user_id = get_current_user_id();
        $user = get_userdata($user_id);
        $email = $user ? $user->user_email : '';
        $title = get_the_title($item_id);

        if ($this->user_training_registration_attended($item_id, $user_id)) {
            $redirect = wp_get_referer() ?: add_query_arg('portal_section', 'workshops', home_url('/registration-portal/'));
            wp_safe_redirect(add_query_arg('arttree_notice', 'cannot_cancel_after_attendance', $redirect));
            exit;
        }

        $items = get_user_meta($user_id, 'arttree_training_registrations', true);
        $items = is_array($items) ? $items : [];
        $new_items = [];
        $cancelled_ticket = '';
        foreach ($items as $item) {
            $matches = (isset($item['item_id']) && absint($item['item_id']) === $item_id) || ($title && isset($item['title']) && $item['title'] === $title);
            if ($matches) {
                $cancelled_ticket = $item['ticket_code'] ?? '';
                continue;
            }
            $new_items[] = $item;
        }
        update_user_meta($user_id, 'arttree_training_registrations', $new_items);

        $registrations = get_post_meta($item_id, '_art_training_registrations', true);
        $registrations = is_array($registrations) ? $registrations : [];
        $new_registrations = [];
        foreach ($registrations as $registration) {
            $matches = false;
            if (isset($registration['user_id']) && absint($registration['user_id']) === $user_id) {
                $matches = true;
            }
            if (!$matches && $cancelled_ticket && isset($registration['ticket_code']) && $registration['ticket_code'] === $cancelled_ticket) {
                $matches = true;
            }
            if (!$matches && $email && isset($registration['email']) && strtolower((string) $registration['email']) === strtolower($email)) {
                $matches = true;
            }
            if (!$matches) {
                $new_registrations[] = $registration;
            }
        }
        update_post_meta($item_id, '_art_training_registrations', $new_registrations);
        $this->notify_training_registration_cancelled($user_id, $item_id);

        $redirect = wp_get_referer() ?: get_permalink($item_id);
        wp_safe_redirect(add_query_arg('arttree_notice', 'registration_cancelled', $redirect));
        exit;
    }

    private function portal_action_url() {
        return esc_url(admin_url('admin-post.php'));
    }

    private function render_portal_auth_forms($gate_type = '', $gate_id = 0) {
        ob_start();
        if (is_user_logged_in()) {
            echo '<div class="arttree-auth-grid"><div class="arttree-auth-card"><span>تم تسجيل الدخول</span><h3>أنت داخل حسابك</h3><p>يمكنك متابعة الطلبات أو تحديث بياناتك من لوحة المتقدم.</p><a class="arttree-rt-primary" href="' . esc_url(home_url('/registration-portal/')) . '">فتح لوحة المتقدم</a></div></div>';
            return ob_get_clean();
        }
        echo '<div id="create-account" class="arttree-auth-grid">';
        echo '<form class="arttree-auth-card" method="post" action="' . $this->portal_action_url() . '">';
        echo '<input type="hidden" name="action" value="arttree_portal_register">';
        echo '<input type="hidden" name="gate_type" value="' . esc_attr($gate_type) . '">';
        echo '<input type="hidden" name="item_id" value="' . esc_attr(absint($gate_id)) . '">';
        wp_nonce_field('arttree_portal_register', 'arttree_portal_nonce');
        echo '<span>تسجيل جديد</span><h3>إنشاء حساب متقدم</h3><p>أنشئ حسابك بالبيانات الأساسية فقط ويمكنك إكمال باقي البيانات من لوحة المتقدم لاحقاً.</p>';
        echo '<label>الاسم الكامل<input required type="text" name="full_name" autocomplete="name"></label>';
        echo '<label>رقم الجوال<input required type="tel" name="phone" autocomplete="tel"></label>';
        echo '<label>البريد الإلكتروني<input required type="email" name="email" autocomplete="email"></label>';
        echo '<label>كلمة المرور<input required type="password" name="password" minlength="8" autocomplete="new-password"></label>';
        echo '<button type="submit">إنشاء حساب</button>';
        echo '</form>';

        echo '<form id="login" class="arttree-auth-card" method="post" action="' . $this->portal_action_url() . '">';
        echo '<input type="hidden" name="action" value="arttree_portal_login">';
        echo '<input type="hidden" name="gate_type" value="' . esc_attr($gate_type) . '">';
        echo '<input type="hidden" name="item_id" value="' . esc_attr(absint($gate_id)) . '">';
        wp_nonce_field('arttree_portal_login', 'arttree_portal_nonce');
        echo '<span>دخول</span><h3>لدي حساب بالفعل</h3><p>سجل الدخول لإضافة الطلب إلى حسابك ومتابعة حالته من لوحة المتقدم.</p>';
        echo '<label>رقم الجوال أو البريد الإلكتروني<input required type="text" name="user_login" autocomplete="username"></label>';
        echo '<label>كلمة المرور<input required type="password" name="password"></label>';
        echo '<button type="submit">تسجيل الدخول</button>';
        echo '<div class="arttree-demo-users"><strong>حسابات وهمية للتجربة</strong><p>applicant1@example.com<br>applicant2@example.com<br>applicant3@example.com</p><small>كلمة المرور: Demo@12345</small></div>';
        echo '</form>';
        echo '</div>';
        return ob_get_clean();
    }

    private function render_portal_dashboard() {
        $user = wp_get_current_user();
        $full_name = get_user_meta($user->ID, 'arttree_applicant_full_name', true) ?: $user->display_name;
        $phone = get_user_meta($user->ID, 'arttree_applicant_phone', true);
        $city = get_user_meta($user->ID, 'arttree_applicant_city', true);
        $qualification = get_user_meta($user->ID, 'arttree_applicant_qualification', true);
        $jobs = get_user_meta($user->ID, 'arttree_job_applications', true);
        $jobs = is_array($jobs) ? $jobs : [];
        $trainings = get_user_meta($user->ID, 'arttree_training_registrations', true);
        $trainings = is_array($trainings) ? $trainings : [];
        $section = isset($_GET['portal_section']) ? sanitize_key(wp_unslash($_GET['portal_section'])) : 'overview';
        $allowed_sections = ['overview', 'profile', 'jobs', 'experience', 'workshops', 'settings'];
        if (!in_array($section, $allowed_sections, true)) {
            $section = 'overview';
        }
        $base_url = home_url('/registration-portal/');

        ob_start();
        $sidebar_items = [
            ['overview', 'الرئيسية', 'home'],
            ['profile', 'بياناتي', 'user'],
            ['jobs', 'الوظائف المقدم عليها', 'briefcase'],
            ['experience', 'التجربة المهنية للمحاماة', 'scale'],
            ['workshops', 'اللقاءات والورش', 'calendar'],
            ['settings', 'الإعدادات', 'settings'],
            ['control', 'تحكم الثيم والأنظمة', 'settings'],
            ['control', 'تحكم الثيم والأنظمة', 'settings'],
        ];
        $avatar_url = get_avatar_url($user->ID, ['size' => 96]);
        $display_title = $full_name ?: 'المتقدم';

        echo '<div class="arttree-dashboard-shell arttree-dashboard-separated" data-dashboard-shell data-active-section="' . esc_attr($section) . '">';
        echo '<div class="arttree-dashboard-mobile-bar"><div class="arttree-dashboard-mobile-user"><img src="' . esc_url($avatar_url) . '" alt="' . esc_attr($display_title) . '"><span>' . esc_html($display_title) . '</span></div><button class="arttree-dashboard-mobile-toggle" type="button" data-dashboard-mobile-toggle aria-expanded="false" aria-controls="arttree-dashboard-sidebar"><span class="arttree-dashboard-toggle-icon" aria-hidden="true"></span><span class="screen-reader-text">فتح قائمة لوحة المتقدم</span></button></div>';
        echo '<button class="arttree-dashboard-toggle" type="button" data-dashboard-toggle aria-expanded="true" aria-controls="arttree-dashboard-sidebar"><span class="arttree-dashboard-toggle-icon" aria-hidden="true"></span><span>عرض الأيقونات فقط</span></button>';
        echo '<button class="arttree-dashboard-dim" type="button" data-dashboard-close aria-label="إغلاق قائمة لوحة المتقدم"></button>';
        echo '<aside id="arttree-dashboard-sidebar" class="arttree-dashboard-sidebar" data-dashboard-sidebar><div class="arttree-dashboard-drawer-head"><div><span>لوحة المتقدم</span><strong>' . esc_html($display_title) . '</strong></div><button type="button" data-dashboard-close aria-label="إغلاق القائمة">×</button></div>';
        foreach ($sidebar_items as $item) {
            $url = add_query_arg('portal_section', $item[0], $base_url);
            $active = $section === $item[0] ? ' is-active' : '';
            echo '<a class="' . esc_attr($active) . '" href="' . esc_url($url) . '"><span class="arttree-dash-icon arttree-dash-icon-' . esc_attr($item[2]) . '" aria-hidden="true"></span><span>' . esc_html($item[1]) . '</span></a>';
        }
        echo '<a href="' . esc_url(wp_logout_url($base_url)) . '"><span class="arttree-dash-icon arttree-dash-icon-logout" aria-hidden="true"></span><span>تسجيل الخروج</span></a>';
        echo '</aside>';
        echo '<main class="arttree-dashboard-content">';
        if ($section === 'overview') {
            echo '<section id="overview" class="arttree-dashboard-panel hero-panel"><span>مرحبا بك</span><h3>' . esc_html($full_name) . '</h3><p>من هنا يمكنك متابعة طلباتك الوظيفية وتسجيلات التدريب واللقاءات والورش من صفحات منفصلة لكل قسم.</p><div class="arttree-dashboard-stats"><b>' . count($jobs) . '<small>طلبات وظيفية</small></b><b>' . count($trainings) . '<small>تسجيلات تدريب وورش</small></b><b>نشط<small>حالة الحساب</small></b></div></section>';
        } elseif ($section === 'profile') {
            $apply_job = isset($_GET['apply_job']) ? absint($_GET['apply_job']) : 0;
            $cv_url = $this->applicant_cv_url($user->ID);
            $national_id = get_user_meta($user->ID, 'arttree_applicant_national_id', true);
            $experience = get_user_meta($user->ID, 'arttree_applicant_experience', true);
            $summary = get_user_meta($user->ID, 'arttree_applicant_summary', true);
            $linkedin = get_user_meta($user->ID, 'arttree_applicant_linkedin', true);
            echo '<section id="profile" class="arttree-dashboard-panel arttree-profile-management"><div class="arttree-profile-head"><span>إدارة البيانات</span><h3>بياناتي</h3><p class="arttree-section-note">يمكنك تعديل بياناتك الأساسية ورفع السيرة الذاتية حتى يتم استخدامها تلقائيا عند التقديم على الوظائف والبرامج.</p></div>';
            if ($apply_job) {
                echo '<div class="arttree-portal-notice">أكمل بياناتك ليتم تقديمك على وظيفة: ' . esc_html(get_the_title($apply_job)) . '</div>';
            }
            echo '<form class="arttree-profile-form" method="post" enctype="multipart/form-data" action="' . esc_url($this->portal_action_url()) . '">';
            echo '<input type="hidden" name="action" value="arttree_update_applicant_profile">';
            echo '<input type="hidden" name="apply_job" value="' . esc_attr($apply_job) . '">';
            wp_nonce_field('arttree_update_applicant_profile', 'arttree_profile_nonce');
            echo '<div class="arttree-profile-section-card"><div class="arttree-profile-section-title"><h4>البيانات الأساسية</h4><p>هذه البيانات مطلوبة للتقديم المباشر.</p></div><div class="arttree-profile-grid arttree-profile-edit-grid">';
            echo '<label><strong>الاسم الكامل</strong><input required type="text" name="full_name" value="' . esc_attr($full_name) . '" autocomplete="name"></label>';
            echo '<label><strong>البريد الإلكتروني</strong><input required type="email" name="email" value="' . esc_attr($user->user_email) . '" autocomplete="email"></label>';
            echo '<label><strong>رقم الجوال</strong><input required type="tel" name="phone" value="' . esc_attr($phone) . '" autocomplete="tel"></label>';
            echo '<label><strong>رقم الهوية أو الإقامة</strong><input type="text" name="national_id" value="' . esc_attr($national_id) . '"></label>';
            echo '<label><strong>المدينة</strong><input required type="text" name="city" value="' . esc_attr($city) . '"></label>';
            echo '<label><strong>المؤهل</strong><input required type="text" name="qualification" value="' . esc_attr($qualification) . '"></label>';
            echo '<label><strong>سنوات الخبرة</strong><input type="text" name="experience" value="' . esc_attr($experience) . '"></label>';
            echo '<label><strong>رابط لينكدإن أو الملف المهني</strong><input type="url" name="linkedin" value="' . esc_attr($linkedin) . '" placeholder="https://"></label>';
            echo '</div></div>';
            echo '<div class="arttree-profile-section-card"><div class="arttree-profile-section-title"><h4>السيرة الذاتية والنبذة</h4><p>ارفع سيرتك الذاتية وأضف نبذة مختصرة عن خبراتك.</p></div><div class="arttree-profile-grid arttree-profile-edit-grid">';
            echo '<label class="arttree-wide-field"><strong>نبذة مختصرة</strong><textarea name="summary" rows="4" placeholder="اكتب نبذة مختصرة عن خبراتك ومهاراتك">' . esc_textarea($summary) . '</textarea></label>';
            echo '<label><strong>السيرة الذاتية</strong><input type="file" name="applicant_cv" accept=".pdf,.doc,.docx"><small>الصيغ المسموحة: PDF DOC DOCX</small></label>';
            echo '</div>';
            if ($cv_url) { echo '<div class="arttree-current-cv"><strong>السيرة الذاتية الحالية</strong><a href="' . esc_url($cv_url) . '">عرض أو تنزيل السيرة الذاتية</a></div>'; }
            echo '</div>';
            echo '<div class="arttree-profile-actions"><button class="arttree-rt-primary" type="submit">' . ($apply_job ? 'حفظ البيانات والتقديم' : 'حفظ التعديلات') . '</button></div>';
            echo '</form></section>';
        } elseif ($section === 'jobs') {
            echo '<section id="jobs" class="arttree-dashboard-panel"><h3>الوظائف المقدم عليها</h3>' . $this->render_dashboard_list($jobs, 'لا توجد طلبات وظيفية حتى الآن.') . '</section>';
        } elseif ($section === 'experience') {
            echo '<section id="experience" class="arttree-dashboard-panel"><h3>التجربة المهنية للمحاماة</h3>' . $this->render_dashboard_list(array_values(array_filter($trainings, function($item){ return ($item['type'] ?? 'training') !== 'workshop'; })), 'لم يتم التسجيل في برنامج التجربة المهنية بعد.') . '</section>';
        } elseif ($section === 'workshops') {
            $workshops = array_values(array_filter($trainings, function($item){ return ($item['type'] ?? '') === 'workshop'; }));
            $selected_ticket = isset($_GET['workshop_ticket']) ? sanitize_text_field(wp_unslash($_GET['workshop_ticket'])) : '';
            if ($selected_ticket) {
                echo '<section id="workshops" class="arttree-dashboard-panel"><h3>تفاصيل اللقاء أو الورشة</h3>' . $this->render_workshop_detail_page($workshops, $selected_ticket) . '</section>';
            } else {
                echo '<section id="workshops" class="arttree-dashboard-panel"><h3>اللقاءات والورش</h3><p class="arttree-section-note">اختر لقاء أو ورشة لعرض التفاصيل والباركود والتقييم والشهادة في صفحة مستقلة.</p>' . $this->render_workshop_overview_list($workshops) . '</section>';
            }
        } elseif ($section === 'settings') {
            echo '<section id="settings" class="arttree-dashboard-panel"><h3>الإعدادات</h3><p>تحديث كلمة المرور والتنبيهات وبيانات التواصل ستكون ضمن المرحلة التالية من النظام.</p></section>';
        }
        echo '</main></div>';
        return ob_get_clean();
    }

    private function workshop_detail_url($ticket_code) {
        return add_query_arg([
            'portal_section' => 'workshops',
            'workshop_ticket' => rawurlencode((string) $ticket_code),
        ], home_url('/registration-portal/'));
    }

    private function get_workshop_item_meta($item, $key, $post_meta_key = '') {
        if (isset($item[$key]) && $item[$key] !== '') {
            return $item[$key];
        }
        $item_id = absint($item['item_id'] ?? 0);
        if ($item_id && $post_meta_key) {
            return $this->field($item_id, $post_meta_key);
        }
        return '';
    }

    private function render_workshop_overview_list($items) {
        if (!$items) {
            return '<p class="arttree-empty-state">لا توجد تسجيلات في اللقاءات والورش حتى الآن.</p>';
        }
        $html = '<div class="arttree-workshop-overview-list">';
        foreach ($items as $item) {
            $ticket = $item['ticket_code'] ?? '';
            $attended = ($item['attendance_status'] ?? '') === 'attended';
            $evaluated = !empty($item['evaluation_submitted']);
            $date = $this->get_workshop_item_meta($item, 'training_date', '_art_training_date');
            $time = $this->get_workshop_item_meta($item, 'training_time', '_art_training_time');
            $venue = $this->get_workshop_item_meta($item, 'training_venue', '_art_training_venue');
            $map_url = $this->get_workshop_item_meta($item, 'training_map_url', '_art_training_map_url');
            $status_text = $evaluated ? 'تم التقييم وإصدار الشهادة' : ($attended ? 'تم الحضور بانتظار التقييم' : 'مسجل بانتظار الحضور');
            $status_class = $evaluated ? 'done' : ($attended ? 'pending' : 'registered');
            $html .= '<article class="arttree-workshop-overview-card">';
            $html .= '<div><span class="arttree-workshop-status ' . esc_attr($status_class) . '">' . esc_html($status_text) . '</span><h4>' . esc_html($item['title'] ?? 'لقاء أو ورشة') . '</h4></div>';
            $html .= '<div class="arttree-workshop-compact-meta arttree-card-meta-icons"><span>' . $this->rt_icon('date') . '<b>التاريخ</b><em>' . esc_html($date ?: 'غير محدد') . '</em></span><span>' . $this->rt_icon('time') . '<b>الوقت</b><em>' . esc_html($time ?: 'غير محدد') . '</em></span><span>' . $this->rt_icon('location') . '<b>الموقع</b><em>' . esc_html($venue ?: 'غير محدد') . '</em></span></div>';
            if ($map_url) {
                $html .= '<a class="arttree-map-card-btn" href="' . esc_url($map_url) . '">' . $this->rt_icon('map') . '<span>فتح اللوكيشن على قوقل ماب</span></a>';
            }
            $html .= '<a class="arttree-rt-secondary arttree-details-btn" href="' . esc_url($this->workshop_detail_url($ticket)) . '">عرض التفاصيل</a>';
            $html .= '</article>';
        }
        $html .= '</div>';
        return $html;
    }

    private function render_workshop_detail_page($items, $ticket_code) {
        $selected = null;
        foreach ($items as $item) {
            if (($item['ticket_code'] ?? '') === $ticket_code) {
                $selected = $item;
                break;
            }
        }
        if (!$selected) {
            return '<div class="arttree-empty-state"><p>لم يتم العثور على هذا التسجيل.</p><a class="arttree-rt-secondary" href="' . esc_url(add_query_arg('portal_section', 'workshops', home_url('/registration-portal/'))) . '">العودة للقاءات والورش</a></div>';
        }
        $item = $selected;
        $item_id = absint($item['item_id'] ?? 0);
        $ticket = $item['ticket_code'] ?? '';
        $checkin_url = $item['checkin_url'] ?? '';
        if (!$checkin_url && $ticket) {
            $checkin_url = add_query_arg(['staff_section' => 'attendance', 'arttree_training_id' => absint($item['item_id'] ?? 0), 'arttree_checkin' => rawurlencode($ticket)], home_url('/staff-dashboard/'));
        }
        $qr_src = $ticket ? 'https://api.qrserver.com/v1/create-qr-code/?size=220x220&data=' . rawurlencode($checkin_url ?: $ticket) : '';
        $date = $this->get_workshop_item_meta($item, 'training_date', '_art_training_date');
        $time = $this->get_workshop_item_meta($item, 'training_time', '_art_training_time');
        $location = $this->get_workshop_item_meta($item, 'training_location', '_art_training_location');
        $venue = $this->get_workshop_item_meta($item, 'training_venue', '_art_training_venue');
        $map_url = $this->get_workshop_item_meta($item, 'training_map_url', '_art_training_map_url');
        $supervisor_phone = $this->get_workshop_item_meta($item, 'training_supervisor_phone', '_art_training_supervisor_phone');
        $attended = ($item['attendance_status'] ?? '') === 'attended';
        $evaluated = !empty($item['evaluation_submitted']);
        $certificate_code = $item['certificate_code'] ?? '';
        $verify_url = $certificate_code ? add_query_arg('certificate_code', rawurlencode($certificate_code), home_url('/certificate-verify/')) : '';
        $download_url = $certificate_code ? add_query_arg('certificate_code', rawurlencode($certificate_code), home_url('/certificate-verify/')) : '';
        $back_url = add_query_arg('portal_section', 'workshops', home_url('/registration-portal/'));
        $status_label = $evaluated ? 'تم إصدار الشهادة' : ($attended ? 'تم تسجيل الحضور' : 'بانتظار تسجيل الحضور');
        $status_class = $evaluated ? 'done' : ($attended ? 'attended' : 'pending');

        $html = '<div class="arttree-workshop-detail-page arttree-action-detail-page">';
        $html .= '<div class="arttree-workshop-detail-head"><a href="' . esc_url($back_url) . '">العودة للقاءات والورش</a><span class="arttree-workshop-status ' . esc_attr($status_class) . '">' . esc_html($status_label) . '</span><h4>' . esc_html($item['title'] ?? 'لقاء أو ورشة') . '</h4><p>جميع التفاصيل والباركود والتقييم والشهادة منظمة في أزرار واضحة.</p></div>';

        $html .= '<div class="arttree-workshop-action-bar">';
        $html .= '<a class="arttree-action-pill" href="#arttree-ticket-section">باركود الدخول</a>';
        $html .= '<a class="arttree-action-pill" href="#arttree-details-section">تفاصيل الورشة</a>';
        if ($map_url) {
            $html .= '<a class="arttree-action-pill" href="' . esc_url($map_url) . '">فتح اللوكيشن</a>';
        }
        if ($supervisor_phone) {
            $html .= '<a class="arttree-action-pill" href="tel:' . esc_attr(preg_replace('/[^0-9+]/', '', $supervisor_phone)) . '">اتصال بالمشرف</a>';
        }
        if ($attended && !$evaluated) {
            $html .= '<a class="arttree-action-pill primary" href="#arttree-evaluation-section">تقييم الورشة</a>';
        }
        if ($download_url) {
            $html .= '<a class="arttree-action-pill primary" href="' . esc_url($download_url) . '" data-certificate-pdf-download data-certificate-code="' . esc_attr($certificate_code) . '">تنزيل شهادة</a>';
        }
        if ($verify_url) {
            $html .= '<a class="arttree-action-pill" href="' . esc_url($verify_url) . '">التحقق من الشهادة</a>';
        }
        $html .= '</div>';

        $html .= '<div id="arttree-ticket-section" class="arttree-action-panel arttree-ticket-action-panel"><div><h5>باركود الدخول</h5><p>يستخدمه المشرف لتسجيل حضورك عند الوصول.</p></div>';
        if ($qr_src) {
            $html .= '<div class="arttree-ticket-box large"><img src="' . esc_url($qr_src) . '" alt="باركود الدخول"><code>' . esc_html($ticket) . '</code></div>';
        } else {
            $html .= '<p>لا يوجد باركود لهذا التسجيل.</p>';
        }
        $html .= '</div>';

        $html .= '<div id="arttree-details-section" class="arttree-action-panel"><div class="arttree-panel-title-row"><h5>تفاصيل الورشة الأساسية</h5></div><div class="arttree-workshop-info-list action-list">';
        $html .= '<p><strong>اليوم</strong><span>' . esc_html($date ?: 'غير محدد') . '</span></p>';
        $html .= '<p><strong>الوقت</strong><span>' . esc_html($time ?: 'غير محدد') . '</span></p>';
        $html .= '<p><strong>نوع الحضور</strong><span>' . esc_html($location ?: 'غير محدد') . '</span></p>';
        $html .= '<p><strong>الموقع</strong><span>' . esc_html($venue ?: 'غير محدد') . '</span></p>';
        $html .= '<p><strong>رقم المشرف</strong><span>' . esc_html($supervisor_phone ?: 'غير محدد') . '</span></p>';
        if ($map_url) {
            $html .= '<p><strong>رابط اللوكيشن</strong><span><a class="arttree-inline-action" href="' . esc_url($map_url) . '">فتح الموقع</a></span></p>';
        }
        $html .= '</div></div>';

        if (!$attended) {
            $html .= '<div class="arttree-workshop-gate pending"><strong>لم يتم تسجيل الحضور بعد</strong><p>بعد مسح الباركود من قبل المشرف سيظهر زر التقييم ورابط الشهادة.</p></div>';
        } elseif (!$evaluated) {
            $html .= '<form id="arttree-evaluation-section" class="arttree-workshop-evaluation arttree-action-panel" method="post" action="' . esc_url(admin_url('admin-post.php')) . '">';
            $html .= '<input type="hidden" name="action" value="arttree_submit_workshop_evaluation"><input type="hidden" name="ticket_code" value="' . esc_attr($ticket) . '">';
            $html .= wp_nonce_field('arttree_submit_workshop_evaluation', 'arttree_evaluation_nonce', true, false);
            $html .= '<h4>تقييم اللقاء أو الورشة</h4><p>بعد إكمال التقييم يتم إصدار شهادة الحضور داخل حسابك.</p><div class="arttree-evaluation-grid">';
            $html .= $this->render_evaluation_select('rating', 'التقييم العام للورشة أو اللقاء');
            $html .= $this->render_evaluation_select('trainer_rating', 'تقييم المدرب أو المتحدث');
            $html .= $this->render_evaluation_select('content_rating', 'تقييم محتوى الورشة');
            $html .= $this->render_evaluation_select('organization_rating', 'تقييم التنظيم والاستقبال');
            $html .= $this->render_evaluation_select('benefit_rating', 'مدى الاستفادة العملية');
            $html .= '</div>';
            $html .= $this->render_low_rating_followup_fields();
            $html .= $this->render_evaluation_open_text_fields();
            $html .= '<button type="submit" class="arttree-evaluation-submit" data-evaluation-submit hidden>إرسال التقييم وإصدار الشهادة</button></form>';
        } else {
            $html .= '<div id="arttree-evaluation-section" class="arttree-action-panel arttree-evaluation-summary"><div class="arttree-panel-title-row"><h5>تفاصيل تقييمك</h5></div><div class="arttree-evaluation-summary-grid">';
            $html .= $this->render_evaluation_value('التقييم العام', $item['evaluation_rating'] ?? '');
            $html .= $this->render_evaluation_value('تقييم المدرب أو المتحدث', $item['evaluation_trainer_rating'] ?? '');
            $html .= $this->render_evaluation_value('تقييم المحتوى', $item['evaluation_content_rating'] ?? '');
            $html .= $this->render_evaluation_value('التنظيم والاستقبال', $item['evaluation_organization_rating'] ?? '');
            $html .= $this->render_evaluation_value('الاستفادة العملية', $item['evaluation_benefit_rating'] ?? '');
            $html .= '</div><div class="arttree-evaluation-notes action-list">';
            $html .= '<p><strong>أكثر جزء استفدت منه</strong><span>' . esc_html($item['evaluation_best_part'] ?? 'لم يتم إدخال تفاصيل') . '</span></p>';
            $html .= '<p><strong>المقترحات</strong><span>' . esc_html($item['evaluation_suggestions'] ?? 'لا توجد مقترحات') . '</span></p>';
            $html .= '<p><strong>ملاحظات إضافية</strong><span>' . esc_html($item['evaluation_comments'] ?? 'لا توجد ملاحظات') . '</span></p>';
            if (!empty($item['evaluation_issue_reason']) || !empty($item['evaluation_issue_area']) || !empty($item['evaluation_improvement_expected'])) {
                $html .= '<p><strong>سبب التقييم المنخفض</strong><span>' . esc_html($item['evaluation_issue_reason'] ?? 'لم يتم إدخال سبب') . '</span></p>';
                $html .= '<p><strong>ما المطلوب لتحسين التجربة</strong><span>' . esc_html($item['evaluation_improvement_expected'] ?? 'لم يتم إدخال تفاصيل') . '</span></p>';
            }
            $html .= '</div></div>';
            $html .= '<div class="arttree-action-panel arttree-certificate-box"><span>شهادة الحضور</span><h4>' . esc_html($item['title'] ?? 'اللقاء أو الورشة') . '</h4><p>تم تسجيل حضورك واستلام تقييم الورشة.</p><p><strong>رقم الشهادة</strong> <code>' . esc_html($certificate_code ?: 'تم إصدار الشهادة') . '</code></p><div class="arttree-certificate-actions">';
            if ($download_url) {
                $html .= '<a href="' . esc_url($download_url) . '" data-certificate-pdf-download data-certificate-code="' . esc_attr($certificate_code) . '">تنزيل شهادة</a>';
            }
            if ($verify_url) {
                $html .= '<a href="' . esc_url($verify_url) . '">التحقق من الشهادة</a>';
            }
            $html .= '</div></div>';
        }
        if ($item_id && !$attended) {
            $html .= $this->training_cancel_form($item_id);
        } elseif ($attended) {
            $html .= '<div class="arttree-cancel-locked">لا يمكن إلغاء التسجيل بعد تسجيل الحضور بالباركود.</div>';
        }
        $html .= '</div>';
        return $html;
    }

    private function render_evaluation_value($label, $score) {
        $labels = [5 => 'ممتاز', 4 => 'جيد جدا', 3 => 'جيد', 2 => 'مقبول', 1 => 'ضعيف'];
        $score = absint($score);
        $text = $labels[$score] ?? 'غير محدد';
        return '<p><strong>' . esc_html($label) . '</strong><span>' . esc_html($text) . '</span></p>';
    }

    private function render_dashboard_list($items, $empty) {
        if (!$items) {
            return '<p class="arttree-empty-state">' . esc_html($empty) . '</p>';
        }
        $html = '<div class="arttree-request-list">';
        foreach ($items as $item) {
            $type = $item['type'] ?? '';
            $is_event = in_array($type, ['training', 'workshop'], true);
            $is_workshop = $type === 'workshop';
            $ticket = $item['ticket_code'] ?? '';
            $checkin_url = $item['checkin_url'] ?? '';
            if (!$checkin_url && $ticket) {
                $checkin_url = add_query_arg(['staff_section' => 'attendance', 'arttree_training_id' => absint($item['item_id'] ?? 0), 'arttree_checkin' => rawurlencode($ticket)], home_url('/staff-dashboard/'));
            }
            $attended = ($item['attendance_status'] ?? '') === 'attended';
            $evaluated = !empty($item['evaluation_submitted']);
            $certificate_code = $item['certificate_code'] ?? '';
            $html .= '<article class="arttree-request-item' . ($is_workshop ? ' is-workshop-item arttree-workshop-dashboard-card' : '') . '">';
            $html .= '<div class="arttree-dashboard-event-row">';
            $html .= '<div class="arttree-request-main"><strong>' . esc_html($item['title'] ?? 'طلب') . '</strong><span>' . esc_html($item['status'] ?? 'تم الاستلام') . '</span><small>' . esc_html($item['date'] ?? '') . '</small></div>';
            if ($is_event && $ticket) {
                $qr_src = 'https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=' . rawurlencode($checkin_url ?: $ticket);
                $html .= '<div class="arttree-ticket-box"><span>باركود الدخول</span><img src="' . esc_url($qr_src) . '" alt="باركود الدخول"><code>' . esc_html($ticket) . '</code></div>';
            }
            $html .= '</div>';
            if ($is_workshop) {
                if (!$attended) {
                    $html .= '<div class="arttree-workshop-gate pending"><strong>باركود الدخول مطلوب</strong><p>سيتم تفعيل تقييم الورشة وشهادة الحضور بعد مسح الباركود وتسجيل الحضور من قبل المشرف.</p></div>';
                } elseif (!$evaluated) {
                    $html .= '<form class="arttree-workshop-evaluation" method="post" action="' . esc_url(admin_url('admin-post.php')) . '">';
                    $html .= '<input type="hidden" name="action" value="arttree_submit_workshop_evaluation"><input type="hidden" name="ticket_code" value="' . esc_attr($ticket) . '">';
                    $html .= wp_nonce_field('arttree_submit_workshop_evaluation', 'arttree_evaluation_nonce', true, false);
                    $html .= '<h4>تقييم اللقاء أو الورشة</h4><p>بعد إكمال التقييم يتم إصدار شهادة الحضور داخل حسابك.</p>';
                    $html .= '<div class="arttree-evaluation-grid">';
                    $html .= $this->render_evaluation_select('rating', 'التقييم العام للورشة أو اللقاء');
                    $html .= $this->render_evaluation_select('trainer_rating', 'تقييم المدرب أو المتحدث');
                    $html .= $this->render_evaluation_select('content_rating', 'تقييم محتوى الورشة');
                    $html .= $this->render_evaluation_select('organization_rating', 'تقييم التنظيم والاستقبال');
                    $html .= $this->render_evaluation_select('benefit_rating', 'مدى الاستفادة العملية');
                    $html .= '</div>';
                    $html .= $this->render_low_rating_followup_fields();
                    $html .= $this->render_evaluation_open_text_fields();
            $html .= '<button type="submit" class="arttree-evaluation-submit" data-evaluation-submit hidden>إرسال التقييم وإصدار الشهادة</button></form>';
                } else {
                    $verify_url = $certificate_code ? add_query_arg('certificate_code', rawurlencode($certificate_code), home_url('/certificate-verify/')) : home_url('/certificate-verify/');
                    $html .= '<div class="arttree-certificate-box"><span>شهادة الحضور</span><h4>' . esc_html($item['title'] ?? 'اللقاء أو الورشة') . '</h4><p>تم تسجيل حضورك واستلام تقييم الورشة.</p><code>' . esc_html($certificate_code ?: 'تم إصدار الشهادة') . '</code><a href="' . esc_url($verify_url) . '">التحقق من الشهادة</a></div>';
                }
            }
            $html .= '</article>';
        }
        $html .= '</div>';
        return $html;
    }

    private function render_evaluation_select($name, $label) {
        $options = [
            5 => 'ممتاز',
            4 => 'جيد جدا',
            3 => 'جيد',
            2 => 'مقبول',
            1 => 'ضعيف',
        ];
        $steps = [
            'rating' => 1,
            'trainer_rating' => 2,
            'content_rating' => 3,
            'organization_rating' => 4,
            'benefit_rating' => 5,
        ];
        $step = $steps[$name] ?? 1;
        $notes = [
            'rating' => 'ابدأ بالتقييم العام ثم سيظهر السؤال التالي تلقائيا',
            'trainer_rating' => 'قيّم المدرب أو المتحدث بناء على الوضوح والتفاعل',
            'content_rating' => 'قيّم جودة المحتوى ومدى ارتباطه باحتياجك',
            'organization_rating' => 'قيّم التنظيم والاستقبال وسهولة الدخول',
            'benefit_rating' => 'قيّم مدى الاستفادة العملية من اللقاء أو الورشة',
        ];
        $html = '<label class="arttree-evaluation-stage" data-evaluation-step="' . esc_attr((string) $step) . '"' . ($step > 1 ? ' hidden' : '') . '>';
        $html .= '<span class="arttree-evaluation-step-index">المرحلة ' . esc_html((string) $step) . ' من 5</span>';
        $html .= '<strong>' . esc_html($label) . '</strong>';
        $html .= '<small>' . esc_html($notes[$name] ?? 'اختر التقييم المناسب') . '</small>';
        $html .= '<select name="' . esc_attr($name) . '" required data-evaluation-stage-select><option value="">اختر التقييم</option>';
        foreach ($options as $value => $text) {
            $html .= '<option value="' . esc_attr((string) $value) . '">' . esc_html($text) . '</option>';
        }
        $html .= '</select></label>';
        return $html;
    }

    private function render_evaluation_open_text_fields() {
        $html = '<div class="arttree-evaluation-textareas" data-evaluation-open-notes hidden>';
        $html .= '<label class="arttree-evaluation-stage arttree-evaluation-note-stage"><span class="arttree-evaluation-step-index">المرحلة الأخيرة</span><strong>ما أكثر جزء استفدت منه؟</strong><textarea name="best_part" rows="3" placeholder="اكتب أكثر نقطة مفيدة في الورشة أو اللقاء"></textarea></label>';
        $html .= '<label class="arttree-evaluation-stage arttree-evaluation-note-stage"><strong>مقترحاتك لتطوير اللقاءات القادمة</strong><textarea name="suggestions" rows="3" placeholder="اكتب اقتراحاتك وملاحظاتك"></textarea></label>';
        $html .= '<label class="arttree-evaluation-stage arttree-evaluation-note-stage"><strong>ملاحظات إضافية</strong><textarea name="comments" rows="3" placeholder="أي ملاحظات إضافية"></textarea></label>';
        $html .= '<label class="arttree-evaluation-stage arttree-evaluation-note-stage"><strong>هل تسمح لنا بالتواصل معك؟</strong><select name="allow_followup"><option value="yes">نعم</option><option value="no">لا</option></select></label>';
        $html .= '</div>';
        return $html;
    }

    private function render_low_rating_followup_fields() {
        $html = '<div class="arttree-low-rating-followup" data-low-rating-followup hidden>';
        $html .= '<div class="arttree-low-rating-head"><strong>ساعدنا نعرف سبب التقييم</strong><span>يظهر هذا القسم عند اختيار مقبول أو ضعيف حتى نقدر نعرف المشكلة ونعالجها</span></div>';
        $html .= '<label>ما سبب اختيارك لهذا التقييم؟<textarea name="issue_reason" rows="3" data-low-rating-required placeholder="اكتب السبب الرئيسي مثل ضعف التنظيم أو عدم وضوح المحتوى أو مشكلة في الوقت"></textarea></label>';
        $html .= '<label>ما الذي كان يمكن تحسينه؟<textarea name="improvement_expected" rows="3" data-low-rating-required placeholder="اكتب اقتراحا عمليا يساعدنا في تحسين اللقاءات القادمة"></textarea></label>';
        $html .= '<div class="arttree-low-rating-actions"><button type="button" class="arttree-low-rating-back" data-low-rating-back>العودة للسؤال</button><button type="button" class="arttree-low-rating-next" data-low-rating-next>التالي</button></div>';
        $html .= '</div>';
        return $html;
    }

    private function get_evaluation_issue_area_label($value) {
        $areas = [
            'content' => 'المحتوى أو المادة العلمية',
            'speaker' => 'المدرب أو المتحدث',
            'organization' => 'التنظيم والاستقبال',
            'time' => 'الوقت أو مدة اللقاء',
            'venue' => 'الموقع أو القاعة',
            'communication' => 'التواصل قبل أو بعد اللقاء',
            'other' => 'سبب آخر',
        ];
        return $areas[$value] ?? ($value ?: 'غير محدد');
    }

    private function create_or_update_workshop_certificate($user_id, $item, $ticket_code, $certificate_code) {
        $user = get_userdata($user_id);
        if (!$user || !$certificate_code) {
            return 0;
        }
        $existing = get_posts([
            'post_type' => 'art_certificate',
            'post_status' => 'any',
            'numberposts' => 1,
            'fields' => 'ids',
            'meta_key' => '_art_certificate_code',
            'meta_value' => $certificate_code,
        ]);
        $full_name = get_user_meta($user_id, 'arttree_applicant_full_name', true) ?: $user->display_name;
        $title = 'شهادة حضور - ' . ($item['title'] ?? 'لقاء أو ورشة');
        if ($existing) {
            $certificate_id = absint($existing[0]);
            wp_update_post(['ID' => $certificate_id, 'post_title' => $title]);
        } else {
            $certificate_id = wp_insert_post([
                'post_type' => 'art_certificate',
                'post_status' => 'publish',
                'post_title' => $title,
            ]);
        }
        if ($certificate_id && !is_wp_error($certificate_id)) {
            update_post_meta($certificate_id, '_art_certificate_holder', $full_name);
            update_post_meta($certificate_id, '_art_certificate_title', 'شهادة حضور');
            update_post_meta($certificate_id, '_art_certificate_training', $item['title'] ?? 'لقاء أو ورشة');
            update_post_meta($certificate_id, '_art_certificate_date', current_time('Y-m-d'));
            update_post_meta($certificate_id, '_art_certificate_code', $certificate_code);
            update_post_meta($certificate_id, '_art_certificate_ticket_code', $ticket_code);
            return $certificate_id;
        }
        return 0;
    }

    public function handle_workshop_evaluation() {
        if (!is_user_logged_in()) {
            wp_safe_redirect(home_url('/registration-portal/'));
            exit;
        }
        if (!isset($_POST['arttree_evaluation_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_evaluation_nonce'])), 'arttree_submit_workshop_evaluation')) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'workshops', 'arttree_error' => 'nonce'], home_url('/registration-portal/')));
            exit;
        }
        $user_id = get_current_user_id();
        $ticket_code = sanitize_text_field(wp_unslash($_POST['ticket_code'] ?? ''));
        $rating = absint($_POST['rating'] ?? 0);
        $trainer_rating = absint($_POST['trainer_rating'] ?? 0);
        $content_rating = absint($_POST['content_rating'] ?? 0);
        $organization_rating = absint($_POST['organization_rating'] ?? 0);
        $benefit_rating = absint($_POST['benefit_rating'] ?? 0);
        $best_part = sanitize_textarea_field(wp_unslash($_POST['best_part'] ?? ''));
        $suggestions = sanitize_textarea_field(wp_unslash($_POST['suggestions'] ?? ''));
        $comments = sanitize_textarea_field(wp_unslash($_POST['comments'] ?? ''));
        $issue_area = sanitize_key(wp_unslash($_POST['issue_area'] ?? ''));
        $issue_reason = sanitize_textarea_field(wp_unslash($_POST['issue_reason'] ?? ''));
        $improvement_expected = sanitize_textarea_field(wp_unslash($_POST['improvement_expected'] ?? ''));
        $allow_followup = sanitize_key(wp_unslash($_POST['allow_followup'] ?? 'yes'));
        $ratings = [$rating, $trainer_rating, $content_rating, $organization_rating, $benefit_rating];
        foreach ($ratings as $score) {
            if ($score < 1 || $score > 5) {
                wp_safe_redirect(add_query_arg(['portal_section' => 'workshops', 'arttree_error' => 'missing'], home_url('/registration-portal/')));
                exit;
            }
        }
        $has_low_rating = false;
        foreach ($ratings as $score) {
            if ($score < 3) {
                $has_low_rating = true;
                break;
            }
        }
        if ($has_low_rating && (!$issue_reason || !$improvement_expected)) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'workshops', 'arttree_error' => 'missing'], home_url('/registration-portal/')));
            exit;
        }
        if (!$ticket_code) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'workshops', 'arttree_error' => 'missing'], home_url('/registration-portal/')));
            exit;
        }
        $items = get_user_meta($user_id, 'arttree_training_registrations', true);
        $items = is_array($items) ? $items : [];
        foreach ($items as $index => $item) {
            if (($item['ticket_code'] ?? '') !== $ticket_code || ($item['type'] ?? '') !== 'workshop') {
                continue;
            }
            if (($item['attendance_status'] ?? '') !== 'attended') {
                wp_safe_redirect(add_query_arg(['portal_section' => 'workshops', 'arttree_notice' => 'attendance_required'], home_url('/registration-portal/')));
                exit;
            }
            $certificate_code = $item['certificate_code'] ?? ('DHL-CERT-' . strtoupper(wp_generate_password(8, false, false)));
            $items[$index]['evaluation_submitted'] = 1;
            $items[$index]['evaluation_rating'] = $rating;
            $items[$index]['evaluation_trainer_rating'] = $trainer_rating;
            $items[$index]['evaluation_content_rating'] = $content_rating;
            $items[$index]['evaluation_organization_rating'] = $organization_rating;
            $items[$index]['evaluation_benefit_rating'] = $benefit_rating;
            $items[$index]['evaluation_best_part'] = $best_part;
            $items[$index]['evaluation_suggestions'] = $suggestions;
            $items[$index]['evaluation_comments'] = $comments;
            $items[$index]['evaluation_issue_area'] = $issue_area;
            $items[$index]['evaluation_issue_reason'] = $issue_reason;
            $items[$index]['evaluation_improvement_expected'] = $improvement_expected;
            $items[$index]['evaluation_allow_followup'] = $allow_followup === 'no' ? 'no' : 'yes';
            $items[$index]['evaluation_time'] = current_time('mysql');
            $items[$index]['certificate_code'] = $certificate_code;
            $items[$index]['status'] = 'تم تقييم الورشة وإصدار شهادة الحضور';
            update_user_meta($user_id, 'arttree_training_registrations', $items);
            $this->create_or_update_workshop_certificate($user_id, $items[$index], $ticket_code, $certificate_code);
            $item_id = absint($item['item_id'] ?? 0);
            if ($item_id) {
                $registrations = get_post_meta($item_id, '_art_training_registrations', true);
                $registrations = is_array($registrations) ? $registrations : [];
                foreach ($registrations as $r_index => $registration) {
                    if (($registration['ticket_code'] ?? '') === $ticket_code) {
                        $registrations[$r_index]['evaluation_submitted'] = 1;
                        $registrations[$r_index]['evaluation_rating'] = $rating;
                        $registrations[$r_index]['evaluation_trainer_rating'] = $trainer_rating;
                        $registrations[$r_index]['evaluation_content_rating'] = $content_rating;
                        $registrations[$r_index]['evaluation_organization_rating'] = $organization_rating;
                        $registrations[$r_index]['evaluation_benefit_rating'] = $benefit_rating;
                        $registrations[$r_index]['evaluation_best_part'] = $best_part;
                        $registrations[$r_index]['evaluation_suggestions'] = $suggestions;
                        $registrations[$r_index]['evaluation_comments'] = $comments;
                        $registrations[$r_index]['evaluation_issue_area'] = $issue_area;
                        $registrations[$r_index]['evaluation_issue_reason'] = $issue_reason;
                        $registrations[$r_index]['evaluation_improvement_expected'] = $improvement_expected;
                        $registrations[$r_index]['evaluation_allow_followup'] = $allow_followup === 'no' ? 'no' : 'yes';
                        $registrations[$r_index]['evaluation_time'] = current_time('mysql');
                        $registrations[$r_index]['certificate_code'] = $certificate_code;
                    }
                }
                update_post_meta($item_id, '_art_training_registrations', $registrations);
            }
            wp_safe_redirect(add_query_arg(['portal_section' => 'workshops', 'workshop_ticket' => rawurlencode($ticket_code), 'arttree_notice' => 'evaluation_saved'], home_url('/registration-portal/')));
            exit;
        }
        wp_safe_redirect(add_query_arg(['portal_section' => 'workshops', 'arttree_error' => 'missing'], home_url('/registration-portal/')));
        exit;
    }

    public function handle_portal_register() {
        if (!isset($_POST['arttree_portal_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_portal_nonce'])), 'arttree_portal_register')) {
            wp_safe_redirect(add_query_arg('arttree_error', 'nonce', home_url('/registration-portal/')));
            exit;
        }
        $email = sanitize_email(wp_unslash($_POST['email'] ?? ''));
        $password = (string) ($_POST['password'] ?? '');
        $full_name = sanitize_text_field(wp_unslash($_POST['full_name'] ?? ''));
        $gate_type = sanitize_key(wp_unslash($_POST['gate_type'] ?? ''));
        $item_id = absint($_POST['item_id'] ?? 0);
        $phone = $this->normalize_login_phone(sanitize_text_field(wp_unslash($_POST['phone'] ?? '')));
        if (!$email || !$password || !$full_name || !$phone) {
            wp_safe_redirect(add_query_arg('arttree_error', 'missing', home_url('/registration-portal/')));
            exit;
        }
        if (strlen($password) < 8) {
            wp_safe_redirect(add_query_arg('arttree_error', 'weak_password', home_url('/registration-portal/')));
            exit;
        }
        if ($this->phone_exists($phone)) {
            wp_safe_redirect(add_query_arg('arttree_error', 'phone_exists', home_url('/registration-portal/#login')));
            exit;
        }
        if (email_exists($email)) {
            wp_safe_redirect(add_query_arg('arttree_error', 'email_exists', home_url('/registration-portal/#login')));
            exit;
        }
        $username = sanitize_user(current(explode('@', $email)), true);
        if (!$username || username_exists($username)) {
            $username = 'applicant_' . wp_generate_password(6, false, false);
        }
        $user_id = wp_create_user($username, $password, $email);
        if (is_wp_error($user_id)) {
            wp_safe_redirect(add_query_arg('arttree_error', 'missing', home_url('/registration-portal/')));
            exit;
        }
        wp_update_user(['ID' => $user_id, 'display_name' => $full_name, 'first_name' => $full_name]);
        update_user_meta($user_id, 'arttree_applicant_user', 1);
        update_user_meta($user_id, 'show_admin_bar_front', 'false');
        update_user_meta($user_id, 'arttree_applicant_full_name', $full_name);
        update_user_meta($user_id, 'arttree_applicant_phone', $phone);
        wp_set_current_user($user_id);
        wp_set_auth_cookie($user_id, true);
        if ($gate_type && $item_id) {
            $this->create_user_request($user_id, $gate_type, $item_id);
        }
        $this->notify_account_created($user_id);
        wp_safe_redirect(add_query_arg('arttree_notice', 'registered', home_url('/registration-portal/')));
        exit;
    }

    private function normalize_login_phone($value) {
        $value = (string) $value;
        $digits = preg_replace('/[^0-9]/', '', $value);
        if (!$digits) {
            return '';
        }
        if (strlen($digits) > 9 && str_starts_with($digits, '966')) {
            $digits = '0' . substr($digits, 3);
        }
        return $digits;
    }

    private function phone_exists($phone, $exclude_user_id = 0) {
        $phone = $this->normalize_login_phone($phone);
        if (!$phone) {
            return false;
        }
        $users = get_users([
            'number' => 1,
            'fields' => 'ids',
            'meta_key' => 'arttree_applicant_phone',
            'meta_value' => $phone,
        ]);
        if (empty($users)) {
            return false;
        }
        return absint($users[0]) !== absint($exclude_user_id);
    }

    private function find_user_by_email_or_phone($login_value) {
        $login_value = trim((string) $login_value);
        if (!$login_value) {
            return false;
        }
        if (is_email($login_value)) {
            $user = get_user_by('email', sanitize_email($login_value));
            if ($user) {
                return $user;
            }
        }
        $phone = $this->normalize_login_phone($login_value);
        if ($phone) {
            $users = get_users([
                'meta_key' => 'arttree_applicant_phone',
                'meta_value' => $phone,
                'number' => 1,
                'fields' => 'all',
            ]);
            if (!empty($users)) {
                return $users[0];
            }
            $users = get_users([
                'meta_query' => [[
                    'key' => 'arttree_applicant_phone',
                    'value' => substr($phone, -9),
                    'compare' => 'LIKE',
                ]],
                'number' => 1,
                'fields' => 'all',
            ]);
            if (!empty($users)) {
                return $users[0];
            }
        }
        return get_user_by('login', sanitize_user($login_value, true));
    }

    public function handle_portal_login() {
        if (!isset($_POST['arttree_portal_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_portal_nonce'])), 'arttree_portal_login')) {
            wp_safe_redirect(add_query_arg('arttree_error', 'nonce', home_url('/registration-portal/')));
            exit;
        }
        $login_value = sanitize_text_field(wp_unslash($_POST['user_login'] ?? ''));
        $password = (string) ($_POST['password'] ?? '');
        $resolved_user = $this->find_user_by_email_or_phone($login_value);
        $creds = [
            'user_login' => $resolved_user ? $resolved_user->user_login : $login_value,
            'user_password' => $password,
            'remember' => true,
        ];
        $user = wp_signon($creds, is_ssl());
        if (is_wp_error($user)) {
            wp_safe_redirect(add_query_arg('arttree_error', 'login_failed', home_url('/registration-portal/#login')));
            exit;
        }
        $gate_type = sanitize_key(wp_unslash($_POST['gate_type'] ?? ''));
        $item_id = absint($_POST['item_id'] ?? 0);
        $notice = 'logged_in';
        if ($gate_type && $item_id) {
            $created = $this->create_user_request($user->ID, $gate_type, $item_id);
            $notice = $created === 'exists' ? 'exists' : 'request_saved';
        }
        wp_safe_redirect(add_query_arg('arttree_notice', $notice, home_url('/registration-portal/')));
        exit;
    }


    private function theme_home_sections() {
        return [
            'services' => 'الخدمات',
            'reviews' => 'آراء العملاء',
            'team' => 'فريق العمل',
            'partners' => 'شركاء النجاح',
            'faq' => 'الأسئلة الشائعة',
            'contact' => 'اتصل بنا',
            'location' => 'موقعنا',
        ];
    }

    private function system_controls() {
        return [
            'jobs' => ['label' => 'التوظيف', 'page' => '/careers/'],
            'training' => ['label' => 'التدريب', 'page' => '/training-programs/'],
            'workshops' => ['label' => 'الورش واللقاءات', 'page' => '/events-workshops/'],
            'portal' => ['label' => 'لوحة المتقدم', 'page' => '/registration-portal/'],
            'certificates' => ['label' => 'الشهادات والتحقق', 'page' => '/certificate-verify/'],
            'checkin' => ['label' => 'قارئ الباركود', 'page' => '/workshop-checkin/'],
        ];
    }

    private function get_theme_controls() {
        $defaults = [
            'primary_color' => '#503d7a',
            'accent_color' => '#d7b46a',
            'hero_cta_label' => 'اطلب استشارة',
            'hero_cta_url' => '#contact',
            'site_mode' => 'live',
            'coming_title' => 'الموقع قريبا',
            'coming_message' => 'نعمل حاليا على تجهيز تجربة رقمية متكاملة وسنعود قريبا.',
            'coming_countdown_date' => date('Y-m-d', strtotime('+30 days')),
            'maintenance_title' => 'الموقع تحت الصيانة',
            'maintenance_message' => 'نقوم حاليا بتحديث الموقع وتحسين الأنظمة. يرجى العودة بعد قليل.',
            'systems' => [],
        ];
        foreach ($this->system_controls() as $key => $data) {
            $defaults['systems'][$key] = true;
        }
        $stored = get_option('arttree_theme_controls', []);
        if (!is_array($stored)) {
            $stored = [];
        }
        $stored = array_replace_recursive($defaults, $stored);
        foreach ($defaults['systems'] as $key => $value) {
            $stored['systems'][$key] = !empty($stored['systems'][$key]);
        }
        return $stored;
    }

    private function system_enabled($key) {
        $controls = $this->get_theme_controls();
        return !isset($controls['systems'][$key]) || !empty($controls['systems'][$key]);
    }

    private function disabled_system_message($title) {
        return '<section class="arttree-rt arttree-flat-system-page" dir="rtl"><div class="arttree-rt-hero"><span class="arttree-eyebrow">غير متاح حاليا</span><h2>' . esc_html($title) . '</h2><p>تم إيقاف هذا النظام مؤقتا من لوحة تحكم الثيم والأنظمة.</p></div></section>';
    }

    public function maybe_render_site_mode_page() {
        if (is_admin() || wp_doing_ajax() || (defined('REST_REQUEST') && REST_REQUEST)) {
            return;
        }
        if ($this->staff_can_access_dashboard()) {
            return;
        }
        $controls = $this->get_theme_controls();
        $mode = isset($controls['site_mode']) ? sanitize_key($controls['site_mode']) : 'live';
        if (!in_array($mode, ['coming_soon', 'maintenance'], true)) {
            return;
        }
        $is_maintenance = $mode === 'maintenance';
        $title = $is_maintenance ? ($controls['maintenance_title'] ?? 'الموقع تحت الصيانة') : ($controls['coming_title'] ?? 'الموقع قريبا');
        $message = $is_maintenance ? ($controls['maintenance_message'] ?? 'نقوم حاليا بتحديث الموقع وتحسين الأنظمة. يرجى العودة بعد قليل.') : ($controls['coming_message'] ?? 'نعمل حاليا على تجهيز تجربة رقمية متكاملة وسنعود قريبا.');
        $countdown_date = isset($controls['coming_countdown_date']) ? sanitize_text_field($controls['coming_countdown_date']) : date('Y-m-d', strtotime('+30 days'));
        if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $countdown_date)) {
            $countdown_date = date('Y-m-d', strtotime('+30 days'));
        }
        $site_name = get_bloginfo('name');
        if ($is_maintenance) {
            status_header(503);
            header('Retry-After: 3600');
        } else {
            status_header(200);
        }
        nocache_headers();
        ?><!doctype html>
<html <?php language_attributes(); ?> dir="rtl">
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo esc_html($title . ' - ' . $site_name); ?></title>
<?php wp_head(); ?>
<style>
:root{--mode-primary:#503d7a;--mode-accent:#d7b46a;--mode-ink:#251c32;--mode-muted:#6f657a;--mode-paper:#fbfaf6;--mode-line:rgba(80,61,122,.13)}
*{box-sizing:border-box}
body{margin:0;font-family:'Thmanyah Sans','ThmanyahSans','Tahoma','Arial',sans-serif;background:radial-gradient(circle at 18% 8%,rgba(80,61,122,.18),transparent 36%),linear-gradient(180deg,var(--mode-paper),#f6f1e8);color:var(--mode-ink);min-height:100vh;overflow-x:hidden}
.arttree-mode-page{position:relative;min-height:100vh;display:flex;flex-direction:column;overflow:hidden}.arttree-mode-bg{position:absolute;inset:0;pointer-events:none;z-index:0}.arttree-mode-bg:before{content:"";position:absolute;width:560px;height:560px;border-radius:50%;background:rgba(215,180,106,.20);filter:blur(18px);top:-220px;left:-150px}.arttree-mode-bg:after{content:"";position:absolute;width:680px;height:680px;border-radius:50%;background:rgba(80,61,122,.12);bottom:-270px;right:-190px}.arttree-mode-header{position:relative;z-index:2;width:min(1180px,calc(100% - 44px));margin:0 auto;padding:28px 0;display:flex;align-items:center;justify-content:center}.arttree-mode-brand{display:flex;align-items:center;justify-content:center;text-decoration:none}.arttree-mode-brand img{width:clamp(150px,18vw,260px);height:auto;object-fit:contain;filter:drop-shadow(0 22px 44px rgba(37,28,50,.12))}.arttree-mode-hero{position:relative;z-index:1;width:min(1180px,calc(100% - 44px));margin:auto;display:grid;grid-template-columns:1fr;place-items:center;flex:1;padding:28px 0 56px}.arttree-mode-copy{text-align:center;display:flex;flex-direction:column;align-items:center;max-width:900px}.arttree-mode-copy h1{font-size:clamp(46px,7vw,88px);line-height:.98;margin:0 0 24px;font-weight:900;color:var(--mode-ink);letter-spacing:0;text-wrap:balance}.arttree-mode-copy p{font-size:clamp(18px,2vw,23px);line-height:1.95;color:var(--mode-muted);max-width:780px;margin:0}.arttree-maintenance-note{margin-top:26px;display:inline-flex;align-items:center;gap:10px;background:rgba(80,61,122,.08);color:var(--mode-primary);border:1px solid rgba(80,61,122,.10);border-radius:999px;padding:12px 18px;font-weight:900}.arttree-maintenance-note:before{content:"";width:10px;height:10px;border-radius:50%;background:<?php echo $is_maintenance ? '#d88a31' : '#3ba56e'; ?>;box-shadow:0 0 0 6px <?php echo $is_maintenance ? 'rgba(216,138,49,.14)' : 'rgba(59,165,110,.14)'; ?>}.arttree-countdown{margin-top:34px;display:grid;grid-template-columns:repeat(4,minmax(110px,1fr));gap:14px;width:min(620px,100%)}.arttree-countdown-box{background:rgba(255,255,255,.82);border:1px solid rgba(80,61,122,.10);box-shadow:0 16px 46px rgba(37,28,50,.08);border-radius:24px;padding:18px 12px;text-align:center}.arttree-countdown-box strong{display:block;font-size:clamp(28px,4vw,44px);line-height:1;color:var(--mode-primary);font-weight:900}.arttree-countdown-box span{display:block;margin-top:8px;font-size:14px;color:var(--mode-muted);font-weight:800}.arttree-mode-footer{position:relative;z-index:2;width:min(1180px,calc(100% - 44px));margin:0 auto;padding:0 0 28px;color:#7c7189;text-align:center;font-size:14px;line-height:1.9}.arttree-mode-footer a{color:var(--mode-primary);font-weight:900;text-decoration:none}@media(max-width:720px){.arttree-mode-header,.arttree-mode-hero,.arttree-mode-footer{width:min(100% - 30px,1180px)}.arttree-mode-brand img{width:170px}.arttree-mode-copy h1{font-size:40px}.arttree-mode-copy p{font-size:18px}.arttree-countdown{grid-template-columns:repeat(2,1fr);gap:10px}.arttree-countdown-box{border-radius:20px;padding:16px 10px}}

/* v1.0.106 - coming soon / maintenance hero balance */
.arttree-mode-page{isolation:isolate}.arttree-mode-header{position:absolute;z-index:3;top:50%;left:clamp(26px,5vw,86px);width:auto;margin:0;padding:0;transform:translateY(-50%);justify-content:flex-start}.arttree-mode-brand img{width:clamp(300px,31vw,560px);max-width:min(44vw,560px);filter:drop-shadow(0 30px 58px rgba(37,28,50,.16))}.arttree-mode-hero{width:min(1280px,calc(100% - 76px));grid-template-columns:minmax(420px,1fr) minmax(460px,700px);justify-items:start;align-items:center;margin:auto;padding:64px 0 74px}.arttree-mode-copy{grid-column:2;text-align:right;align-items:flex-start;max-width:720px;margin:0}.arttree-mode-copy h1{font-size:clamp(52px,6vw,96px)}.arttree-mode-copy p{max-width:690px}.arttree-countdown-reversed{direction:ltr}.arttree-countdown-reversed .arttree-countdown-box{direction:rtl}.arttree-mode-footer{width:min(1280px,calc(100% - 76px))}.arttree-mode-contact{margin-top:30px;display:flex;flex-wrap:wrap;gap:12px;align-items:center;justify-content:flex-start}.arttree-mode-contact a{width:46px;height:46px;border-radius:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--mode-primary);background:rgba(255,255,255,.78);border:1px solid rgba(80,61,122,.12);box-shadow:0 14px 34px rgba(37,28,50,.08);text-decoration:none;transition:.2s ease}.arttree-mode-contact a:hover{transform:translateY(-3px);background:var(--mode-primary);color:#fff}.arttree-mode-contact svg{width:20px;height:20px;display:block;fill:none;stroke:currentColor;stroke-width:2.1;stroke-linecap:round;stroke-linejoin:round}.arttree-mode-contact a[data-social=instagram] svg,.arttree-mode-contact a[data-social=tiktok] svg,.arttree-mode-contact a[data-social=x] svg{fill:currentColor;stroke:none}.arttree-mode-contact a[data-social=youtube] svg{fill:currentColor;stroke:none}.arttree-mode-contact-title{margin-top:28px;font-weight:900;color:var(--mode-primary);font-size:15px}@media(max-width:980px){.arttree-mode-header{position:relative;top:auto;left:auto;transform:none;width:min(100% - 30px,1180px);margin:0 auto;padding:26px 0;justify-content:center}.arttree-mode-brand img{width:clamp(210px,48vw,340px);max-width:75vw}.arttree-mode-hero{width:min(100% - 30px,1180px);grid-template-columns:1fr;place-items:center;text-align:center;padding:24px 0 50px}.arttree-mode-copy{grid-column:auto;text-align:center;align-items:center}.arttree-mode-copy h1{font-size:44px}.arttree-mode-contact{justify-content:center}.arttree-mode-footer{width:min(100% - 30px,1180px)}}


/* v1.0.108 - centered coming soon layout and flat contact icons */
.arttree-mode-page .arttree-mode-hero{width:min(1180px,calc(100% - 44px));grid-template-columns:1fr;place-items:center;text-align:center;padding:64px 0 74px}
.arttree-mode-page .arttree-mode-copy{grid-column:auto;text-align:center;align-items:center;justify-content:center;max-width:820px;margin-inline:auto}
.arttree-mode-page .arttree-mode-copy h1{text-align:center}
.arttree-mode-page .arttree-mode-copy p{text-align:center;margin-inline:auto}
.arttree-mode-page .arttree-countdown{direction:ltr;grid-template-columns:repeat(4,minmax(112px,1fr));width:min(680px,100%)}
.arttree-mode-page .arttree-countdown-box{direction:rtl}
.arttree-mode-page .arttree-mode-contact-title{text-align:center;margin-inline:auto}
.arttree-mode-page .arttree-mode-contact{justify-content:center;margin-inline:auto}
.arttree-mode-page .arttree-mode-contact a{background:transparent;border:0;box-shadow:none;border-radius:0;width:34px;height:34px;padding:0;color:var(--mode-primary)}
.arttree-mode-page .arttree-mode-contact a:hover{transform:translateY(-2px);background:transparent;color:var(--mode-accent)}
.arttree-mode-page .arttree-mode-contact svg{width:21px;height:21px}
@media(max-width:980px){.arttree-mode-page .arttree-mode-hero{width:min(100% - 30px,1180px);padding:24px 0 50px}.arttree-mode-page .arttree-countdown{grid-template-columns:repeat(2,1fr)}}


/* v1.0.109 - large bottom-left Dewan logo for mode pages */
.arttree-mode-page .arttree-mode-header{
  position:absolute;
  z-index:3;
  top:auto;
  left:clamp(18px,3.5vw,64px);
  bottom:clamp(26px,5vw,78px);
  width:auto;
  margin:0;
  padding:0;
  transform:none;
  justify-content:flex-start;
  pointer-events:none;
}
.arttree-mode-page .arttree-mode-brand{pointer-events:auto}
.arttree-mode-page .arttree-mode-brand img{
  width:clamp(360px,42vw,760px);
  max-width:46vw;
  height:auto;
  filter:drop-shadow(0 34px 70px rgba(37,28,50,.16));
}
.arttree-mode-page .arttree-mode-hero{
  position:relative;
  z-index:4;
}
@media(max-width:980px){
  .arttree-mode-page .arttree-mode-header{
    position:relative;
    left:auto;
    bottom:auto;
    width:min(100% - 30px,1180px);
    margin:0 auto;
    padding:26px 0 0;
    justify-content:center;
    pointer-events:auto;
  }
  .arttree-mode-page .arttree-mode-brand img{
    width:clamp(240px,62vw,390px);
    max-width:82vw;
  }
}

</style>
</head>
<body>
<main class="arttree-mode-page" role="main">
    <div class="arttree-mode-bg" aria-hidden="true"></div>
    <header class="arttree-mode-header">
        <a class="arttree-mode-brand" href="<?php echo esc_url(home_url('/')); ?>" aria-label="<?php echo esc_attr($site_name); ?>">
            <img src="<?php echo esc_url(get_template_directory_uri() . '/assets/img/logo-purple.png'); ?>" alt="<?php echo esc_attr($site_name); ?>">
        </a>
    </header>
    <section class="arttree-mode-hero" aria-label="<?php echo esc_attr($title); ?>">
        <div class="arttree-mode-copy">
            <h1><?php echo esc_html($title); ?></h1>
            <p><?php echo esc_html($message); ?></p>
            <?php if ($is_maintenance) : ?>
                <div class="arttree-maintenance-note">نعمل على تحسين تجربتكم حاليا</div>
            <?php endif; ?>
            <?php if (!$is_maintenance) : ?>
                <div class="arttree-countdown arttree-countdown-reversed" data-countdown="<?php echo esc_attr($countdown_date); ?>T23:59:59">
                    <div class="arttree-countdown-box"><strong data-days>0</strong><span>يوم</span></div>
                    <div class="arttree-countdown-box"><strong data-hours>0</strong><span>ساعة</span></div>
                    <div class="arttree-countdown-box"><strong data-minutes>0</strong><span>دقيقة</span></div>
                    <div class="arttree-countdown-box"><strong data-seconds>0</strong><span>ثانية</span></div>
                </div>
            <?php endif; ?>
            <div class="arttree-mode-contact-title">تابعنا وتواصل معنا</div>
            <nav class="arttree-mode-contact" aria-label="روابط التواصل">
                <a href="tel:0566499929" aria-label="رقم الشركة"><svg viewBox="0 0 24 24"><path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.4 19.4 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.3 1.7.6 2.5a2 2 0 0 1-.5 2.1L8 9.5a16 16 0 0 0 6.5 6.5l1.2-1.2a2 2 0 0 1 2.1-.5c.8.3 1.6.5 2.5.6A2 2 0 0 1 22 16.9Z"/></svg></a>
                <a href="mailto:inof@dhlaw.sa" aria-label="البريد الإلكتروني"><svg viewBox="0 0 24 24"><path d="M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z"/><path d="m22 7-10 6L2 7"/></svg></a>
                <a href="https://maps.app.goo.gl/UnGXBqdJS4NjWkdg7" aria-label="الموقع على الخريطة"><svg viewBox="0 0 24 24"><path d="M20 10c0 5-8 12-8 12S4 15 4 10a8 8 0 1 1 16 0Z"/><circle cx="12" cy="10" r="3"/></svg></a>
                <a href="https://www.linkedin.com/company/%D8%AF%D9%8A%D9%88%D8%A7%D9%86-%D8%A7%D9%84%D8%AD%D9%84%D9%88%D9%84/" aria-label="LinkedIn"><svg viewBox="0 0 24 24"><path d="M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-4 0v7h-4V9h4v2a4.8 4.8 0 0 1 4-3Z"/><path d="M2 9h4v12H2z"/><circle cx="4" cy="4" r="2"/></svg></a>
                <a data-social="instagram" href="https://www.instagram.com/dhlaw.sa/" aria-label="Instagram"><svg viewBox="0 0 24 24"><path d="M7.8 2h8.4A5.8 5.8 0 0 1 22 7.8v8.4a5.8 5.8 0 0 1-5.8 5.8H7.8A5.8 5.8 0 0 1 2 16.2V7.8A5.8 5.8 0 0 1 7.8 2Zm0 2A3.8 3.8 0 0 0 4 7.8v8.4A3.8 3.8 0 0 0 7.8 20h8.4a3.8 3.8 0 0 0 3.8-3.8V7.8A3.8 3.8 0 0 0 16.2 4H7.8Zm4.2 3.3A4.7 4.7 0 1 1 12 16.7 4.7 4.7 0 0 1 12 7.3Zm0 2A2.7 2.7 0 1 0 12 14.7 2.7 2.7 0 0 0 12 9.3Zm5-2.1a1.1 1.1 0 1 1-1.1 1.1A1.1 1.1 0 0 1 17 7.2Z"/></svg></a>
                <a data-social="tiktok" href="https://www.tiktok.com/@dhlaw.sa" aria-label="TikTok"><svg viewBox="0 0 24 24"><path d="M16.8 2c.4 3 2.1 4.8 5.2 5.1v3.4a9 9 0 0 1-5.1-1.6v6.6c0 4-2.7 6.5-6.7 6.5A6.2 6.2 0 0 1 4 15.7c0-3.9 3-6.8 7.2-6.3V13c-1.8-.3-3.4.8-3.4 2.6a2.5 2.5 0 0 0 2.6 2.6c1.6 0 2.6-1 2.6-2.9V2h3.8Z"/></svg></a>
                <a data-social="youtube" href="https://www.youtube.com/@DiwanAlhulool/" aria-label="YouTube"><svg viewBox="0 0 24 24"><path d="M23 7.2a3 3 0 0 0-2.1-2.1C19 4.6 12 4.6 12 4.6s-7 0-8.9.5A3 3 0 0 0 1 7.2 31 31 0 0 0 .5 12 31 31 0 0 0 1 16.8a3 3 0 0 0 2.1 2.1c1.9.5 8.9.5 8.9.5s7 0 8.9-.5a3 3 0 0 0 2.1-2.1 31 31 0 0 0 .5-4.8 31 31 0 0 0-.5-4.8ZM9.8 15.5v-7l6 3.5-6 3.5Z"/></svg></a>
                <a data-social="x" href="#" aria-label="X"><svg viewBox="0 0 24 24"><path d="M13.9 10.5 21.3 2h-1.8l-6.4 7.4L8 2H2l7.8 11.3L2 22h1.8l6.8-7.8 5.4 7.8h6l-8.1-11.5Zm-2.4 2.8-.8-1.1L4.4 3.3h2.7l5 7.1.8 1.1 6.6 9.3h-2.7l-5.3-7.5Z"/></svg></a>
            </nav>
        </div>
    </section>
    <footer class="arttree-mode-footer">جميع الحقوق محفوظة © <?php echo esc_html(date_i18n('Y')); ?> <?php echo esc_html($site_name); ?> | التصميم والتطوير بواسطة <a href="https://arttree.sa" rel="noopener" target="_blank">شركة ارت تري</a></footer>
</main>
<script>
(function(){
    var el=document.querySelector('[data-countdown]');
    if(!el){return;}
    var target=new Date(el.getAttribute('data-countdown')).getTime();
    var d=el.querySelector('[data-days]'), h=el.querySelector('[data-hours]'), m=el.querySelector('[data-minutes]'), s=el.querySelector('[data-seconds]');
    function pad(n){return String(Math.max(0,n));}
    function tick(){
        var diff=Math.max(0,target-Date.now());
        var days=Math.floor(diff/86400000); diff-=days*86400000;
        var hours=Math.floor(diff/3600000); diff-=hours*3600000;
        var minutes=Math.floor(diff/60000); diff-=minutes*60000;
        var seconds=Math.floor(diff/1000);
        d.textContent=pad(days); h.textContent=pad(hours); m.textContent=pad(minutes); s.textContent=pad(seconds);
    }
    tick(); setInterval(tick,1000);
})();
</script>
<?php wp_footer(); ?>
</body>
</html><?php
        exit;
    }

    public function staff_dashboard_shortcode() {
        ob_start();
        echo '<section class="arttree-rt arttree-flat-system-page arttree-staff-portal" dir="rtl">';
        if (!is_user_logged_in()) {
            echo '<div class="arttree-auth-grid"><div class="arttree-auth-card"><span>لوحة الموظفين</span><h3>تسجيل دخول الموظفين</h3><p>هذه اللوحة مخصصة لصاحب الموقع والموظفين المصرح لهم لإدارة الطلبات والورش والشهادات.</p><a class="arttree-rt-primary" href="' . esc_url(wp_login_url(home_url('/staff-dashboard/'))) . '">تسجيل الدخول</a></div></div>';
            echo '</section>';
            return ob_get_clean();
        }
        if (!$this->staff_can_access_dashboard()) {
            echo '<div class="arttree-auth-grid"><div class="arttree-auth-card"><span>غير مصرح</span><h3>هذه اللوحة للموظفين فقط</h3><p>لا يملك حسابك صلاحية الدخول إلى لوحة الموظفين.</p><a class="arttree-rt-secondary" href="' . esc_url(home_url('/registration-portal/')) . '">العودة إلى لوحة المتقدم</a></div></div>';
            echo '</section>';
            return ob_get_clean();
        }
        echo $this->render_staff_dashboard();
        echo '</section>';
        return ob_get_clean();
    }

    private function render_staff_dashboard() {
        $user = wp_get_current_user();
        $display_title = $user->display_name ?: $user->user_login;
        $avatar_url = get_avatar_url($user->ID, ['size' => 96]);
        $section = isset($_GET['staff_section']) ? sanitize_key(wp_unslash($_GET['staff_section'])) : 'overview';
        $allowed_sections = ['overview', 'applications', 'applications_add', 'applications_requests', 'trainings', 'trainings_add', 'trainings_regs', 'attendance', 'evaluations', 'certificates', 'settings', 'control', 'control_home', 'control_systems', 'control_mode', 'control_ui', 'control_links', 'users'];
        if (!in_array($section, $allowed_sections, true)) {
            $section = 'overview';
        }
        $section_caps = [
            'applications' => 'arttree_manage_jobs',
            'trainings' => 'arttree_manage_trainings',
            'attendance' => 'arttree_manage_attendance',
            'evaluations' => 'arttree_manage_trainings',
            'certificates' => 'arttree_manage_certificates',
            'control' => 'arttree_manage_theme',
            'control_home' => 'arttree_manage_theme',
            'control_systems' => 'arttree_manage_theme',
            'control_mode' => 'arttree_manage_theme',
            'control_ui' => 'arttree_manage_theme',
            'control_links' => 'arttree_manage_theme',
            'applications_add' => 'arttree_manage_jobs',
            'applications_requests' => 'arttree_manage_jobs',
            'trainings_add' => 'arttree_manage_trainings',
            'trainings_regs' => 'arttree_manage_trainings',
            'users' => 'arttree_manage_users',
        ];
        if (isset($section_caps[$section]) && !$this->staff_can($section_caps[$section]) && !current_user_can('edit_posts')) {
            $section = 'overview';
        }
        $base_url = home_url('/staff-dashboard/');
        $sidebar_groups = [
            'لوحة التحكم' => [
                ['overview', 'الرئيسية', 'home', 'arttree_staff_access'],
            ],
            'التوظيف والتدريب' => [
                ['applications', 'الملخص', 'briefcase', 'arttree_manage_jobs'],
                ['applications_add', 'إضافة وظيفة أو تدريب', 'briefcase', 'arttree_manage_jobs'],
                ['applications_requests', 'متابعة الطلبات', 'users', 'arttree_manage_jobs'],
            ],
            'الورش واللقاءات' => [
                ['trainings', 'الملخص', 'calendar', 'arttree_manage_trainings'],
                ['trainings_add', 'إضافة ورشة أو لقاء', 'calendar', 'arttree_manage_trainings'],
                ['trainings_regs', 'متابعة التسجيلات', 'users', 'arttree_manage_trainings'],
                ['attendance', 'تسجيل الحضور', 'check', 'arttree_manage_attendance'],
                ['evaluations', 'التقييمات', 'star', 'arttree_manage_trainings'],
            ],
            'الشهادات' => [
                ['certificates', 'إدارة الشهادات', 'certificate', 'arttree_manage_certificates'],
            ],
            'إعدادات الثيم والأنظمة' => [
                ['control_home', 'أقسام الصفحة الرئيسية', 'settings', 'arttree_manage_theme'],
                ['control_systems', 'الأنظمة والصفحات', 'settings', 'arttree_manage_theme'],
                ['control_mode', 'وضع الموقع', 'settings', 'arttree_manage_theme'],
                ['control_ui', 'إعدادات الواجهة', 'settings', 'arttree_manage_theme'],
                ['control_links', 'روابط الإدارة', 'settings', 'arttree_manage_theme'],
            ],
            'الإدارة' => [
                ['users', 'المستخدمون والصلاحيات', 'users', 'arttree_manage_users'],
                ['settings', 'روابط سريعة', 'settings', 'arttree_staff_access'],
            ],
        ];
        $jobs_count = wp_count_posts('art_job');
        $candidates_count = wp_count_posts('art_candidate');
        $training_count = wp_count_posts('art_training');
        $cert_count = wp_count_posts('art_certificate');
        ob_start();
        echo '<div class="arttree-dashboard-shell arttree-dashboard-separated arttree-staff-dashboard-shell" data-dashboard-shell data-active-section="' . esc_attr($section) . '">';
        echo '<div class="arttree-dashboard-mobile-bar"><div class="arttree-dashboard-mobile-user"><img src="' . esc_url($avatar_url) . '" alt="' . esc_attr($display_title) . '"><span>' . esc_html($display_title) . '</span></div><button class="arttree-dashboard-mobile-toggle" type="button" data-dashboard-mobile-toggle aria-expanded="false" aria-controls="arttree-staff-dashboard-sidebar"><span class="arttree-dashboard-toggle-icon" aria-hidden="true"></span><span class="screen-reader-text">فتح قائمة لوحة الموظفين</span></button></div>';
        echo '<button class="arttree-dashboard-toggle" type="button" data-dashboard-toggle aria-expanded="true" aria-controls="arttree-staff-dashboard-sidebar"><span class="arttree-dashboard-toggle-icon" aria-hidden="true"></span><span>إخفاء القائمة</span></button>';
        echo '<button class="arttree-dashboard-dim" type="button" data-dashboard-close aria-label="إغلاق قائمة لوحة الموظفين"></button>';
        echo '<aside id="arttree-staff-dashboard-sidebar" class="arttree-dashboard-sidebar" data-dashboard-sidebar><div class="arttree-staff-brand dewan-staff-brand is-logo-only"><img src="' . esc_url(get_template_directory_uri() . '/assets/img/footer-logo.png') . '" alt="شعار ديوان الحلول"></div><div class="arttree-dashboard-drawer-head"><div><span>لوحة الموظفين</span><strong>' . esc_html($display_title) . '</strong></div><button type="button" data-dashboard-close aria-label="إغلاق القائمة">×</button></div>';
        foreach ($sidebar_groups as $group_label => $group_items) {
            $visible_items = [];
            $group_open = false;
            foreach ($group_items as $item) {
                if (isset($item[3]) && !$this->staff_can($item[3]) && !current_user_can('edit_posts')) {
                    continue;
                }
                if ($section === $item[0]) {
                    $group_open = true;
                }
                $visible_items[] = $item;
            }
            if (empty($visible_items)) {
                continue;
            }
            $group_id = 'staff-menu-' . sanitize_key($group_label);
            echo '<details class="arttree-staff-menu-group arttree-staff-menu-details" data-staff-menu-group' . ($group_open ? ' open' : '') . '><summary aria-controls="' . esc_attr($group_id) . '"><span class="arttree-dash-icon arttree-dash-icon-settings" aria-hidden="true"></span><strong>' . esc_html($group_label) . '</strong><span class="arttree-staff-menu-caret" aria-hidden="true"></span></summary><div class="arttree-staff-menu-sublist" id="' . esc_attr($group_id) . '">';
            foreach ($visible_items as $item) {
                $url = add_query_arg('staff_section', $item[0], $base_url);
                $active = $section === $item[0] ? ' is-active' : '';
                echo '<a class="' . esc_attr($active) . '" href="' . esc_url($url) . '" title="' . esc_attr($item[1]) . '"><span class="arttree-dash-icon arttree-dash-icon-' . esc_attr($item[2]) . '" aria-hidden="true"></span><span>' . esc_html($item[1]) . '</span></a>';
            }
            echo '</div></details>';
        }
        echo '<div class="arttree-staff-menu-group arttree-staff-menu-logout"><a href="' . esc_url(wp_logout_url(home_url('/'))) . '" title="تسجيل خروج"><span class="arttree-dash-icon arttree-dash-icon-logout" aria-hidden="true"></span><span>تسجيل خروج</span></a></div>';
        echo '</aside><main class="arttree-dashboard-content">';
        if ($section === 'overview') {
            echo $this->render_staff_overview($display_title, $base_url);
        } elseif (in_array($section, ['applications', 'applications_add', 'applications_requests'], true)) {
            echo $this->render_staff_jobs_manager($section);
        } elseif (in_array($section, ['trainings', 'trainings_add', 'trainings_regs'], true)) {
            echo $this->render_staff_training_manager($section);
        } elseif ($section === 'attendance') {
            echo '<section class="arttree-dashboard-panel"><h3>الحضور والباركود</h3><p class="arttree-section-note">قارئ الباركود يعمل من داخل لوحة التحكم فقط ويجب اختيار الورشة أو اللقاء قبل المسح حتى لا يعمل باركود ورشة على ورشة أخرى.</p>' . $this->render_staff_checkin_scanner() . $this->render_staff_attendance_table() . '</section>';
        } elseif ($section === 'evaluations') {
            echo $this->render_staff_evaluations_dashboard();
        } elseif ($section === 'certificates') {
            echo '<section class="arttree-dashboard-panel"><h3>الشهادات</h3>' . $this->render_staff_posts_table('art_certificate', ['الشهادة', 'رمز التحقق', 'تاريخ الإصدار', 'إجراء']) . '</section>';
        } elseif ($section === 'users') {
            echo $this->render_staff_users_permissions_panel();
        } elseif ($section === 'settings') {
            echo '<section class="arttree-dashboard-panel"><h3>الإعدادات والروابط السريعة</h3><div class="arttree-staff-quick-grid"><a href="' . esc_url(admin_url('admin.php?page=arttree-rt')) . '">لوحة Arttree HR</a><a href="' . esc_url(admin_url('edit.php?post_type=art_job')) . '">إدارة الوظائف</a><a href="' . esc_url(admin_url('edit.php?post_type=art_training')) . '">إدارة الورش</a><a href="' . esc_url(admin_url('edit.php?post_type=art_certificate')) . '">إدارة الشهادات</a></div></section>';
        } elseif (in_array($section, ['control', 'control_home', 'control_systems', 'control_mode', 'control_ui', 'control_links'], true)) {
            echo $this->render_staff_theme_control_panel($section);
        }
        echo '</main></div>';
        return ob_get_clean();
    }

    private function staff_count_training_registrations() {
        $items = get_posts([
            'post_type' => 'art_training',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => -1,
            'fields' => 'ids',
        ]);
        $total = 0;
        $attended = 0;
        $pending = 0;
        foreach ($items as $item_id) {
            $regs = get_post_meta($item_id, '_art_training_registrations', true);
            if (!is_array($regs)) {
                continue;
            }
            foreach ($regs as $reg) {
                $total++;
                if (($reg['attendance_status'] ?? '') === 'attended') {
                    $attended++;
                } else {
                    $pending++;
                }
            }
        }
        return ['total' => $total, 'attended' => $attended, 'pending' => $pending];
    }

    private function staff_count_new_candidates($days = 7) {
        $candidates = get_posts([
            'post_type' => 'art_candidate',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => -1,
            'fields' => 'ids',
            'date_query' => [[
                'after' => absint($days) . ' days ago',
                'inclusive' => true,
            ]],
        ]);
        return is_array($candidates) ? count($candidates) : 0;
    }

    private function staff_get_open_items($post_type, $status_meta_key, $limit = 5) {
        return get_posts([
            'post_type' => $post_type,
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => absint($limit),
            'orderby' => 'date',
            'order' => 'DESC',
            'meta_query' => [[
                'key' => $status_meta_key,
                'value' => 'open',
                'compare' => '=',
            ]],
        ]);
    }

    private function render_staff_notifications($base_url) {
        $notes = [];
        $candidate_counts = wp_count_posts('art_candidate');
        $received = intval($candidate_counts->publish ?? 0) + intval($candidate_counts->pending ?? 0);
        $new_candidates = $this->staff_count_new_candidates(7);
        if ($new_candidates > 0) {
            $notes[] = [
                'type' => 'info',
                'title' => 'طلبات توظيف جديدة',
                'text' => 'وصل ' . $new_candidates . ' طلب توظيف خلال آخر 7 أيام',
                'url' => add_query_arg('staff_section', 'applications_requests', $base_url),
                'action' => 'مراجعة الطلبات',
            ];
        }
        $training_regs = $this->staff_count_training_registrations();
        if ($training_regs['pending'] > 0) {
            $notes[] = [
                'type' => 'warning',
                'title' => 'حضور لم يتم تسجيله',
                'text' => 'يوجد ' . $training_regs['pending'] . ' تسجيل في الورش واللقاءات بانتظار تسجيل الحضور',
                'url' => add_query_arg('staff_section', 'attendance', $base_url),
                'action' => 'فتح الحضور',
            ];
        }
        $open_jobs = $this->staff_get_open_items('art_job', '_art_job_status', 1);
        if ($open_jobs) {
            $notes[] = [
                'type' => 'success',
                'title' => 'وظائف مفتوحة',
                'text' => 'يوجد وظائف مفتوحة لاستقبال طلبات المتقدمين',
                'url' => add_query_arg('staff_section', 'applications', $base_url),
                'action' => 'إدارة الوظائف',
            ];
        }
        $open_trainings = $this->staff_get_open_items('art_training', '_art_training_status', 1);
        if ($open_trainings) {
            $notes[] = [
                'type' => 'success',
                'title' => 'ورش ولقاءات مفتوحة',
                'text' => 'يوجد ورش أو لقاءات مفتوحة للتسجيل',
                'url' => add_query_arg('staff_section', 'trainings', $base_url),
                'action' => 'إدارة الورش',
            ];
        }
        if (empty($notes)) {
            $notes[] = [
                'type' => 'quiet',
                'title' => 'لا توجد تنبيهات عاجلة',
                'text' => 'كل الأنظمة مستقرة ولا توجد تنبيهات تحتاج متابعة الآن',
                'url' => add_query_arg('staff_section', 'overview', $base_url),
                'action' => 'تحديث الصفحة',
            ];
        }
        $html = '<section class="arttree-dashboard-panel arttree-staff-notifications-panel"><div class="arttree-panel-title-row"><div><span>التنبيهات</span><h3>تنبيهات تحتاج متابعة</h3><p>ملخص سريع لأهم الأحداث داخل التوظيف والورش والشهادات.</p></div></div><div class="arttree-staff-notifications-list">';
        foreach ($notes as $note) {
            $html .= '<article class="arttree-staff-notification is-' . esc_attr($note['type']) . '"><div><strong>' . esc_html($note['title']) . '</strong><p>' . esc_html($note['text']) . '</p></div><a href="' . esc_url($note['url']) . '">' . esc_html($note['action']) . '</a></article>';
        }
        $html .= '</div></section>';
        return $html;
    }

    private function render_staff_overview($display_title, $base_url) {
        $jobs_count = wp_count_posts('art_job');
        $candidates_count = wp_count_posts('art_candidate');
        $training_count = wp_count_posts('art_training');
        $cert_count = wp_count_posts('art_certificate');
        $pages_count = wp_count_posts('page');
        $posts_count = wp_count_posts('post');
        $users_count = count_users();
        $training_regs = $this->staff_count_training_registrations();
        $new_candidates = $this->staff_count_new_candidates(7);
        $open_jobs = count($this->staff_get_open_items('art_job', '_art_job_status', 100));
        $open_trainings = count($this->staff_get_open_items('art_training', '_art_training_status', 100));
        $candidate_total = intval($candidates_count->publish ?? 0);
        $training_total = intval($training_count->publish ?? 0);
        $cert_total = intval($cert_count->publish ?? 0);
        $registered_total = intval($training_regs['total']);
        $attended_total = intval($training_regs['attended']);
        $pending_total = intval($training_regs['pending']);
        $attendance_rate = $registered_total > 0 ? round(($attended_total / $registered_total) * 100) : 0;
        $certificate_rate = $attended_total > 0 ? round(($cert_total / $attended_total) * 100) : 0;

        $stats = [
            ['label' => 'طلبات التوظيف', 'value' => $candidate_total, 'meta' => 'طلبات منشورة من نظام التوظيف', 'url' => add_query_arg('staff_section', 'applications_requests', $base_url), 'icon' => 'briefcase', 'tone' => 'primary'],
            ['label' => 'طلبات جديدة', 'value' => $new_candidates, 'meta' => 'آخر 7 أيام من لوحة ووردبريس', 'url' => add_query_arg('staff_section', 'applications_requests', $base_url), 'icon' => 'bell', 'tone' => 'warning'],
            ['label' => 'وظائف مفتوحة', 'value' => $open_jobs, 'meta' => 'فرص تستقبل طلبات حاليا', 'url' => add_query_arg('staff_section', 'applications', $base_url), 'icon' => 'target', 'tone' => 'success'],
            ['label' => 'ورش ولقاءات', 'value' => $training_total, 'meta' => 'منشورة في نظام الورش', 'url' => add_query_arg('staff_section', 'trainings', $base_url), 'icon' => 'calendar', 'tone' => 'primary'],
            ['label' => 'مسجلون في الورش', 'value' => $registered_total, 'meta' => 'إجمالي التسجيلات الحالية', 'url' => add_query_arg('staff_section', 'trainings_regs', $base_url), 'icon' => 'users', 'tone' => 'primary'],
            ['label' => 'حضور مسجل', 'value' => $attended_total, 'meta' => 'تم التحقق بالباركود', 'url' => add_query_arg('staff_section', 'attendance', $base_url), 'icon' => 'check', 'tone' => 'success'],
            ['label' => 'بانتظار الحضور', 'value' => $pending_total, 'meta' => 'مسجل ولم يحضر بعد', 'url' => add_query_arg('staff_section', 'attendance', $base_url), 'icon' => 'clock', 'tone' => 'warning'],
            ['label' => 'الشهادات', 'value' => $cert_total, 'meta' => 'شهادات صادرة وموثقة', 'url' => add_query_arg('staff_section', 'certificates', $base_url), 'icon' => 'certificate', 'tone' => 'success'],
            ['label' => 'ورش مفتوحة', 'value' => $open_trainings, 'meta' => 'تستقبل التسجيل حاليا', 'url' => add_query_arg('staff_section', 'trainings', $base_url), 'icon' => 'door', 'tone' => 'success'],
            ['label' => 'مستخدمو الموقع', 'value' => intval($users_count['total_users'] ?? 0), 'meta' => 'إجمالي حسابات ووردبريس', 'url' => admin_url('users.php'), 'icon' => 'shield', 'tone' => 'neutral'],
            ['label' => 'صفحات الموقع', 'value' => intval($pages_count->publish ?? 0), 'meta' => 'صفحات منشورة في ووردبريس', 'url' => admin_url('edit.php?post_type=page'), 'icon' => 'page', 'tone' => 'neutral'],
            ['label' => 'مقالات الموقع', 'value' => intval($posts_count->publish ?? 0), 'meta' => 'مقالات منشورة في ووردبريس', 'url' => admin_url('edit.php'), 'icon' => 'post', 'tone' => 'neutral'],
        ];

        $kpis = [
            ['label' => 'معدل حضور الورش', 'value' => $attendance_rate . '%', 'meta' => $attended_total . ' حضور من أصل ' . $registered_total . ' تسجيل', 'url' => add_query_arg('staff_section', 'attendance', $base_url), 'icon' => 'chart', 'tone' => $attendance_rate >= 70 ? 'success' : ($attendance_rate >= 40 ? 'warning' : 'danger')],
            ['label' => 'تحويل الحضور إلى شهادات', 'value' => $certificate_rate . '%', 'meta' => $cert_total . ' شهادة من أصل ' . $attended_total . ' حضور', 'url' => add_query_arg('staff_section', 'certificates', $base_url), 'icon' => 'certificate', 'tone' => $certificate_rate >= 70 ? 'success' : ($certificate_rate >= 40 ? 'warning' : 'danger')],
            ['label' => 'طلبات التوظيف الجديدة', 'value' => $new_candidates, 'meta' => 'طلبات تحتاج متابعة خلال آخر 7 أيام', 'url' => add_query_arg('staff_section', 'applications_requests', $base_url), 'icon' => 'bell', 'tone' => $new_candidates > 0 ? 'warning' : 'success'],
            ['label' => 'جاهزية الفعاليات', 'value' => $open_trainings, 'meta' => 'ورش أو لقاءات مفتوحة للتسجيل', 'url' => add_query_arg('staff_section', 'trainings', $base_url), 'icon' => 'target', 'tone' => $open_trainings > 0 ? 'success' : 'neutral'],
        ];

        $html = '<section class="arttree-dashboard-panel hero-panel arttree-staff-hero arttree-staff-overview-hero"><span>لوحة التحكم</span><h3>مرحبا ' . esc_html($display_title) . '</h3><p>الرئيسية تعرض الإحصائيات ومؤشرات الأداء الرئيسية من بيانات ووردبريس وأنظمة التوظيف والورش والشهادات.</p></section>';
        $html .= '<section class="arttree-dashboard-panel arttree-staff-stats-panel arttree-kpi-stats-panel"><div class="arttree-panel-title-row"><div><span>الإحصائيات</span><h3>ملخص أداء الأنظمة</h3><p>بطاقات مباشرة بأيقونات واضحة مبنية على بيانات لوحة ووردبريس والأنظمة المدمجة داخل الثيم.</p></div></div><div class="arttree-staff-stat-grid arttree-staff-kpi-grid">';
        foreach ($stats as $stat) {
            $html .= '<a class="arttree-staff-stat-card is-' . esc_attr($stat['tone']) . '" href="' . esc_url($stat['url']) . '"><span class="arttree-kpi-icon is-' . esc_attr($stat['icon']) . '" aria-hidden="true"></span><div class="arttree-kpi-card-body"><strong>' . esc_html((string) $stat['value']) . '</strong><span>' . esc_html($stat['label']) . '</span><small>' . esc_html($stat['meta']) . '</small></div></a>';
        }
        $html .= '</div></section>';
        $html .= '<section class="arttree-dashboard-panel arttree-staff-kpi-panel"><div class="arttree-panel-title-row"><div><span>KPI</span><h3>مؤشرات الأداء الرئيسية</h3><p>مؤشرات مختصرة لقياس الأداء اليومي وتحديد ما يحتاج متابعة.</p></div></div><div class="arttree-staff-kpi-strip">';
        foreach ($kpis as $kpi) {
            $html .= '<a class="arttree-staff-kpi-card is-' . esc_attr($kpi['tone']) . '" href="' . esc_url($kpi['url']) . '"><span class="arttree-kpi-icon is-' . esc_attr($kpi['icon']) . '" aria-hidden="true"></span><div><strong>' . esc_html((string) $kpi['value']) . '</strong><span>' . esc_html($kpi['label']) . '</span><small>' . esc_html($kpi['meta']) . '</small></div></a>';
        }
        $html .= '</div><p class="arttree-kpi-source-note">مصدر البيانات: ووردبريس، الوظائف، طلبات التوظيف، الورش واللقاءات، الحضور، والشهادات داخل الثيم.</p></section>';
        $html .= $this->render_staff_notifications($base_url);
        $html .= '<section class="arttree-dashboard-panel arttree-staff-shortcuts-panel"><div class="arttree-panel-title-row"><div><span>اختصارات</span><h3>إجراءات سريعة</h3></div></div><div class="arttree-staff-quick-grid"><a href="' . esc_url(add_query_arg('staff_section', 'trainings_add', $base_url)) . '">إضافة ورشة أو لقاء</a><a href="' . esc_url(add_query_arg('staff_section', 'attendance', $base_url)) . '">قارئ الباركود</a><a href="' . esc_url(add_query_arg('staff_section', 'evaluations', $base_url)) . '">التقييمات</a><a href="' . esc_url(add_query_arg('staff_section', 'applications_add', $base_url)) . '">إضافة وظيفة</a><a href="' . esc_url(add_query_arg('staff_section', 'certificates', $base_url)) . '">إدارة الشهادات</a><a href="' . esc_url(add_query_arg('staff_section', 'control_home', $base_url)) . '">تحكم الثيم والأنظمة</a></div></section>';
        return $html;
    }


    private function render_staff_theme_control_panel($active_tab = 'control') {
        $controls = $this->get_theme_controls();
        $home_sections = $this->theme_home_sections();
        $system_controls = $this->system_controls();
        $tab_titles = [
            'control' => ['تحكم شامل', 'إدارة الثيم والأقسام والأنظمة'],
            'control_home' => ['أقسام الصفحة الرئيسية', 'إظهار وإخفاء أقسام الصفحة الرئيسية'],
            'control_systems' => ['الأنظمة والصفحات', 'تشغيل وإيقاف أنظمة الموقع'],
            'control_mode' => ['وضع الموقع', 'قريبا والصيانة والتحديثات'],
            'control_ui' => ['إعدادات الواجهة', 'الألوان وزر الهيدر'],
            'control_links' => ['روابط الإدارة', 'روابط سريعة لإدارة الموقع'],
        ];
        if (!isset($tab_titles[$active_tab])) {
            $active_tab = 'control';
        }
        $show_all = $active_tab === 'control';
        $base_url = home_url('/staff-dashboard/');
        ob_start();
        echo '<section class="arttree-dashboard-panel arttree-theme-control-panel"><div class="arttree-panel-title-row"><div><span>' . esc_html($tab_titles[$active_tab][0]) . '</span><h3>' . esc_html($tab_titles[$active_tab][1]) . '</h3><p>تم فصل إعدادات الثيم والأنظمة إلى صفحات مستقلة داخل لوحة الموظفين حتى تكون الإدارة أوضح وأسهل.</p></div></div>';
        echo '<div class="arttree-staff-subtabs">';
        foreach ($tab_titles as $tab_key => $tab_data) {
            $class = $active_tab === $tab_key ? ' is-active' : '';
            echo '<a class="' . esc_attr($class) . '" href="' . esc_url(add_query_arg('staff_section', $tab_key, $base_url)) . '">' . esc_html($tab_data[0]) . '</a>';
        }
        echo '</div>';
        if (isset($_GET['theme_controls_saved'])) {
            echo '<div class="arttree-portal-notice">تم حفظ إعدادات الثيم والأنظمة بنجاح.</div>';
        }
        echo '<form method="post" action="' . esc_url(admin_url('admin-post.php')) . '" class="arttree-theme-control-form">';
        echo '<input type="hidden" name="action" value="arttree_staff_update_theme_controls">';
        echo '<input type="hidden" name="return_staff_section" value="' . esc_attr($active_tab) . '">';
        wp_nonce_field('arttree_staff_update_theme_controls', 'arttree_staff_nonce');

        if ($show_all || $active_tab === 'control_home') {
            echo '<div class="arttree-control-section"><h4>أقسام الصفحة الرئيسية</h4><div class="arttree-control-grid">';
            foreach ($home_sections as $key => $label) {
                $checked = get_theme_mod('dewan_show_' . $key, true) ? ' checked' : '';
                echo '<label class="arttree-control-switch"><input type="checkbox" name="home_sections[' . esc_attr($key) . ']" value="1"' . $checked . '><span></span><strong>' . esc_html($label) . '</strong><small>إظهار أو إخفاء القسم من الصفحة الرئيسية</small></label>';
            }
            echo '</div></div>';
        } else {
            foreach ($home_sections as $key => $label) {
                if (get_theme_mod('dewan_show_' . $key, true)) {
                    echo '<input type="hidden" name="home_sections[' . esc_attr($key) . ']" value="1">';
                }
            }
        }

        if ($show_all || $active_tab === 'control_systems') {
            echo '<div class="arttree-control-section"><h4>الأنظمة والصفحات</h4><div class="arttree-control-grid">';
            foreach ($system_controls as $key => $data) {
                $checked = !empty($controls['systems'][$key]) ? ' checked' : '';
                echo '<label class="arttree-control-switch"><input type="checkbox" name="systems[' . esc_attr($key) . ']" value="1"' . $checked . '><span></span><strong>' . esc_html($data['label']) . '</strong><small>' . esc_html(home_url($data['page'])) . '</small></label>';
            }
            echo '</div></div>';
        } else {
            foreach ($system_controls as $key => $data) {
                if (!empty($controls['systems'][$key])) {
                    echo '<input type="hidden" name="systems[' . esc_attr($key) . ']" value="1">';
                }
            }
        }

        if ($show_all || $active_tab === 'control_mode') {
            echo '<div class="arttree-control-section"><h4>وضع الموقع</h4><p class="arttree-control-note">فعّل صفحة قريبا أو الموقع تحت الصيانة للزوار. صاحب الموقع والموظفون المصرح لهم يمكنهم الدخول وإدارة الموقع.</p><div class="arttree-control-fields">';
            $site_mode = isset($controls['site_mode']) ? sanitize_key($controls['site_mode']) : 'live';
            echo '<label>حالة الموقع<select name="site_mode"><option value="live"' . selected($site_mode, 'live', false) . '>الموقع يعمل</option><option value="coming_soon"' . selected($site_mode, 'coming_soon', false) . '>موقع قريبا</option><option value="maintenance"' . selected($site_mode, 'maintenance', false) . '>الموقع تحت صيانة</option></select></label>';
            echo '<label>عنوان صفحة قريبا<input type="text" name="coming_title" value="' . esc_attr($controls['coming_title']) . '"></label>';
            echo '<label class="wide">رسالة صفحة قريبا<textarea name="coming_message" rows="3">' . esc_textarea($controls['coming_message']) . '</textarea></label>';
            echo '<label>تاريخ انتهاء العد التنازلي<input type="date" name="coming_countdown_date" value="' . esc_attr($controls['coming_countdown_date']) . '"></label>';
            echo '<label>عنوان الصيانة<input type="text" name="maintenance_title" value="' . esc_attr($controls['maintenance_title']) . '"></label>';
            echo '<label class="wide">رسالة الصيانة أو التحديث<textarea name="maintenance_message" rows="3">' . esc_textarea($controls['maintenance_message']) . '</textarea></label>';
            echo '</div></div>';
        } else {
            echo '<input type="hidden" name="site_mode" value="' . esc_attr($controls['site_mode']) . '">';
            echo '<input type="hidden" name="coming_title" value="' . esc_attr($controls['coming_title']) . '">';
            echo '<input type="hidden" name="coming_message" value="' . esc_attr($controls['coming_message']) . '">';
            echo '<input type="hidden" name="coming_countdown_date" value="' . esc_attr($controls['coming_countdown_date']) . '">';
            echo '<input type="hidden" name="maintenance_title" value="' . esc_attr($controls['maintenance_title']) . '">';
            echo '<input type="hidden" name="maintenance_message" value="' . esc_attr($controls['maintenance_message']) . '">';
        }

        if ($show_all || $active_tab === 'control_ui') {
            echo '<div class="arttree-control-section"><h4>إعدادات الواجهة السريعة</h4><div class="arttree-control-fields">';
            echo '<label>لون الهوية الرئيسي<input type="text" name="primary_color" value="' . esc_attr($controls['primary_color']) . '" placeholder="#503d7a"></label>';
            echo '<label>لون التمييز<input type="text" name="accent_color" value="' . esc_attr($controls['accent_color']) . '" placeholder="#d7b46a"></label>';
            echo '<label>نص زر الهيدر<input type="text" name="hero_cta_label" value="' . esc_attr($controls['hero_cta_label']) . '"></label>';
            echo '<label>رابط زر الهيدر<input type="text" name="hero_cta_url" value="' . esc_attr($controls['hero_cta_url']) . '"></label>';
            echo '</div></div>';
        } else {
            echo '<input type="hidden" name="primary_color" value="' . esc_attr($controls['primary_color']) . '">';
            echo '<input type="hidden" name="accent_color" value="' . esc_attr($controls['accent_color']) . '">';
            echo '<input type="hidden" name="hero_cta_label" value="' . esc_attr($controls['hero_cta_label']) . '">';
            echo '<input type="hidden" name="hero_cta_url" value="' . esc_attr($controls['hero_cta_url']) . '">';
        }

        if ($show_all || $active_tab === 'control_links') {
            echo '<div class="arttree-control-section"><h4>روابط الإدارة السريعة</h4><div class="arttree-staff-quick-grid"><a href="' . esc_url(admin_url('customize.php')) . '">تخصيص الثيم</a><a href="' . esc_url(admin_url('nav-menus.php')) . '">إدارة القوائم</a><a href="' . esc_url(admin_url('widgets.php')) . '">إدارة الودجات</a><a href="' . esc_url(admin_url('edit.php?post_type=page')) . '">إدارة الصفحات</a></div></div>';
        }
        if ($active_tab !== 'control_links') {
            echo '<button class="arttree-rt-primary" type="submit">حفظ الإعدادات</button>';
        }
        echo '</form></section>';
        return ob_get_clean();
    }


    private function render_staff_users_permissions_panel() {
        if (!$this->staff_can('arttree_manage_users')) {
            return '<section class="arttree-dashboard-panel"><h3>المستخدمون والصلاحيات</h3><p class="arttree-empty-state">لا تملك صلاحية إدارة المستخدمين والأدوار.</p></section>';
        }
        $roles = $this->staff_roles_map();
        $caps = $this->staff_caps_map();
        $selected_roles = array_keys($roles);
        $users = get_users([
            'role__in' => array_merge($selected_roles, ['administrator', 'editor']),
            'number' => 80,
            'orderby' => 'registered',
            'order' => 'DESC',
        ]);
        ob_start();
        echo '<section class="arttree-dashboard-panel arttree-staff-users-panel"><div class="arttree-staff-section-title"><div><span>الصلاحيات والأدوار</span><h3>إدارة المستخدمين وصلاحيات الموظفين</h3><p>أنشئ حسابات للموظفين وحدد دور كل مستخدم حسب الصلاحيات المطلوبة داخل لوحة الموظفين.</p></div></div>';
        if (isset($_GET['staff_user_created'])) {
            echo '<div class="arttree-portal-notice">تم إنشاء المستخدم وتعيين الدور بنجاح.</div>';
        }
        if (isset($_GET['staff_role_updated'])) {
            echo '<div class="arttree-portal-notice">تم تحديث دور المستخدم بنجاح.</div>';
        }
        if (isset($_GET['staff_user_error'])) {
            echo '<div class="arttree-portal-alert">تعذر تنفيذ العملية. تأكد من البيانات والصلاحيات.</div>';
        }
        echo '<div class="arttree-staff-manager-grid">';
        echo '<div class="arttree-staff-form-card"><h4>إضافة موظف جديد</h4><form method="post" action="' . esc_url(admin_url('admin-post.php')) . '">';
        echo '<input type="hidden" name="action" value="arttree_staff_create_user">';
        wp_nonce_field('arttree_staff_create_user', 'arttree_staff_nonce');
        echo '<label><span>الاسم الكامل</span><input type="text" name="staff_full_name" required></label>';
        echo '<label><span>البريد الإلكتروني</span><input type="email" name="staff_email" required></label>';
        echo '<label><span>رقم الجوال</span><input type="text" name="staff_phone"></label>';
        echo '<label><span>كلمة المرور</span><input type="password" name="staff_password" required minlength="8"></label>';
        echo '<label><span>الدور</span><select name="staff_role" required>';
        foreach ($roles as $role_key => $role_data) {
            echo '<option value="' . esc_attr($role_key) . '">' . esc_html($role_data['label']) . '</option>';
        }
        echo '</select></label>';
        echo '<button class="arttree-rt-primary" type="submit">إنشاء المستخدم</button>';
        echo '</form></div>';
        echo '<div class="arttree-staff-list-card"><h4>الأدوار والصلاحيات</h4><div class="arttree-role-grid">';
        foreach ($roles as $role_key => $role_data) {
            echo '<article class="arttree-role-card"><h5>' . esc_html($role_data['label']) . '</h5><ul>';
            foreach ($role_data['caps'] as $cap) {
                echo '<li>' . esc_html($caps[$cap] ?? $cap) . '</li>';
            }
            echo '</ul></article>';
        }
        echo '</div></div></div>';
        echo '<div class="arttree-staff-list-card arttree-staff-users-table-card"><h4>المستخدمون الحاليون</h4><div class="arttree-staff-table-wrap"><table class="arttree-staff-table"><thead><tr><th>المستخدم</th><th>البريد</th><th>الدور الحالي</th><th>تعديل الدور</th></tr></thead><tbody>';
        foreach ($users as $staff_user) {
            $primary_role = !empty($staff_user->roles) ? reset($staff_user->roles) : '';
            $role_label = $roles[$primary_role]['label'] ?? translate_user_role(wp_roles()->roles[$primary_role]['name'] ?? $primary_role);
            echo '<tr><td><strong>' . esc_html($staff_user->display_name ?: $staff_user->user_login) . '</strong><small>' . esc_html(get_user_meta($staff_user->ID, 'arttree_applicant_phone', true) ?: get_user_meta($staff_user->ID, 'arttree_staff_phone', true)) . '</small></td><td>' . esc_html($staff_user->user_email) . '</td><td><span class="arttree-staff-badge attended">' . esc_html($role_label ?: '—') . '</span></td><td>';
            if ((int) $staff_user->ID === get_current_user_id() && !current_user_can('manage_options')) {
                echo '<span class="arttree-muted">لا يمكن تعديل دورك الحالي</span>';
            } else {
                echo '<form class="arttree-inline-role-form" method="post" action="' . esc_url(admin_url('admin-post.php')) . '">';
                echo '<input type="hidden" name="action" value="arttree_staff_update_user_role"><input type="hidden" name="user_id" value="' . intval($staff_user->ID) . '">';
                wp_nonce_field('arttree_staff_update_user_role', 'arttree_staff_nonce');
                echo '<select name="staff_role">';
                foreach ($roles as $role_key => $role_data) {
                    echo '<option value="' . esc_attr($role_key) . '"' . selected($primary_role, $role_key, false) . '>' . esc_html($role_data['label']) . '</option>';
                }
                if (current_user_can('manage_options')) {
                    echo '<option value="administrator"' . selected($primary_role, 'administrator', false) . '>مدير الموقع</option>';
                }
                echo '</select><button type="submit">حفظ</button></form>';
            }
            echo '</td></tr>';
        }
        echo '</tbody></table></div></div>';
        echo '</section>';
        return ob_get_clean();
    }

    public function handle_staff_create_user() {
        if (!$this->staff_can('arttree_manage_users')) {
            wp_die('غير مصرح.');
        }
        check_admin_referer('arttree_staff_create_user', 'arttree_staff_nonce');
        $roles = $this->staff_roles_map();
        $role = sanitize_key(wp_unslash($_POST['staff_role'] ?? ''));
        if (!isset($roles[$role])) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'users', 'staff_user_error' => 'role'], home_url('/staff-dashboard/')));
            exit;
        }
        $full_name = sanitize_text_field(wp_unslash($_POST['staff_full_name'] ?? ''));
        $email = sanitize_email(wp_unslash($_POST['staff_email'] ?? ''));
        $phone = sanitize_text_field(wp_unslash($_POST['staff_phone'] ?? ''));
        $password = (string) wp_unslash($_POST['staff_password'] ?? '');
        if (!$full_name || !$email || !is_email($email) || strlen($password) < 8 || email_exists($email)) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'users', 'staff_user_error' => 'data'], home_url('/staff-dashboard/')));
            exit;
        }
        $username_base = sanitize_user(current(explode('@', $email)), true);
        $username = $username_base ?: 'staff';
        $i = 1;
        while (username_exists($username)) {
            $username = $username_base . $i;
            $i++;
        }
        $user_id = wp_create_user($username, $password, $email);
        if (is_wp_error($user_id)) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'users', 'staff_user_error' => 'create'], home_url('/staff-dashboard/')));
            exit;
        }
        wp_update_user(['ID' => $user_id, 'display_name' => $full_name, 'first_name' => $full_name, 'role' => $role]);
        update_user_meta($user_id, 'arttree_staff_phone', $phone);
        update_user_meta($user_id, 'arttree_staff_created_by', get_current_user_id());
        wp_safe_redirect(add_query_arg(['staff_section' => 'users', 'staff_user_created' => '1'], home_url('/staff-dashboard/')));
        exit;
    }

    public function handle_staff_update_user_role() {
        if (!$this->staff_can('arttree_manage_users')) {
            wp_die('غير مصرح.');
        }
        check_admin_referer('arttree_staff_update_user_role', 'arttree_staff_nonce');
        $user_id = absint($_POST['user_id'] ?? 0);
        $role = sanitize_key(wp_unslash($_POST['staff_role'] ?? ''));
        $roles = $this->staff_roles_map();
        if (!$user_id || !get_userdata($user_id) || (!isset($roles[$role]) && $role !== 'administrator')) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'users', 'staff_user_error' => 'role'], home_url('/staff-dashboard/')));
            exit;
        }
        if ($role === 'administrator' && !current_user_can('manage_options')) {
            wp_die('غير مصرح بتعيين مدير موقع.');
        }
        if ($user_id === get_current_user_id() && !current_user_can('manage_options')) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'users', 'staff_user_error' => 'self'], home_url('/staff-dashboard/')));
            exit;
        }
        $user = new WP_User($user_id);
        $user->set_role($role);
        wp_safe_redirect(add_query_arg(['staff_section' => 'users', 'staff_role_updated' => '1'], home_url('/staff-dashboard/')));
        exit;
    }

    private function staff_can_manage_dashboard() {
        return $this->staff_can_access_dashboard();
    }

    private function count_job_candidates($job_id) {
        $title = get_the_title($job_id);
        if (!$title) {
            return 0;
        }
        $candidates = get_posts([
            'post_type' => 'art_candidate',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => -1,
            'fields' => 'ids',
            'meta_query' => [[
                'key' => '_art_candidate_job_title',
                'value' => $title,
                'compare' => '=',
            ]],
        ]);
        return is_array($candidates) ? count($candidates) : 0;
    }

    private function render_staff_jobs_manager($active_tab = 'applications') {
        $base_url = add_query_arg('staff_section', 'applications', home_url('/staff-dashboard/'));
        $selected_job = isset($_GET['job_id']) ? absint($_GET['job_id']) : 0;
        ob_start();
        echo '<section class="arttree-dashboard-panel arttree-staff-manager-panel">';
        echo '<div class="arttree-staff-section-title"><div><span>إدارة التوظيف والتدريب</span><h3>الوظائف وطلبات المتقدمين</h3><p>أضف الوظائف وتابع الطلبات لكل وظيفة تم طرحها من لوحة الموظفين مباشرة.</p></div><a class="arttree-rt-secondary" href="' . esc_url(admin_url('edit.php?post_type=art_candidate')) . '">كل الطلبات</a></div>';
        if ($selected_job) {
            echo '<div class="arttree-staff-subnav"><a href="' . esc_url($base_url) . '">عودة لقائمة الوظائف</a><a href="' . esc_url(get_edit_post_link($selected_job)) . '">تعديل الوظيفة</a></div>';
            echo $this->render_staff_job_applications($selected_job);
        }
        echo '<div class="arttree-staff-manager-grid">';
        echo '<div class="arttree-staff-form-card"><h4>إضافة وظيفة جديدة</h4><form method="post" action="' . esc_url(admin_url('admin-post.php')) . '">';
        echo '<input type="hidden" name="action" value="arttree_staff_create_job">';
        wp_nonce_field('arttree_staff_create_job', 'arttree_staff_nonce');
        echo '<label><span>المسمى الوظيفي</span><input type="text" name="job_title" required></label>';
        echo '<label><span>القسم</span><input type="text" name="job_department"></label>';
        echo '<label><span>المدينة</span><input type="text" name="job_city"></label>';
        echo '<label><span>نوع الدوام</span><input type="text" name="job_type" placeholder="دوام كامل"></label>';
        echo '<label><span>آخر موعد للتقديم</span><input type="date" name="job_deadline"></label>';
        echo '<label><span>حالة التقديم</span><select name="job_status"><option value="open">مفتوح</option><option value="closed">مغلق</option><option value="hidden">مخفي</option></select></label>';
        echo '<label class="wide"><span>وصف الوظيفة</span><textarea name="job_content" rows="5"></textarea></label>';
        echo '<button class="arttree-rt-primary" type="submit">إضافة الوظيفة</button>';
        echo '</form></div>';
        echo '<div class="arttree-staff-list-card"><h4>الوظائف المطروحة</h4>' . $this->render_staff_jobs_table($base_url) . '</div>';
        echo '</div>';
        echo '</section>';
        return ob_get_clean();
    }

    private function render_staff_jobs_table($base_url) {
        $jobs = get_posts(['post_type' => 'art_job', 'post_status' => ['publish', 'draft', 'pending'], 'numberposts' => 50, 'orderby' => 'date', 'order' => 'DESC']);
        if (!$jobs) {
            return '<p class="arttree-empty-state">لا توجد وظائف حتى الآن.</p>';
        }
        $html = '<div class="arttree-staff-table-wrap"><table class="arttree-staff-table"><thead><tr><th>الوظيفة</th><th>الحالة</th><th>المدينة</th><th>الطلبات</th><th>إجراء</th></tr></thead><tbody>';
        foreach ($jobs as $job) {
            $status_value = get_post_meta($job->ID, '_art_job_status', true) ?: 'open';
            $status_label = ['open' => 'مفتوح', 'closed' => 'مغلق', 'hidden' => 'مخفي'][$status_value] ?? $status_value;
            $count = $this->count_job_candidates($job->ID);
            $follow_url = add_query_arg(['staff_section' => 'applications', 'job_id' => $job->ID], home_url('/staff-dashboard/'));
            $html .= '<tr><td><strong>' . esc_html(get_the_title($job)) . '</strong><small>' . esc_html(get_post_meta($job->ID, '_art_job_department', true)) . '</small></td><td><span class="arttree-staff-badge ' . esc_attr($status_value === 'open' ? 'attended' : 'pending') . '">' . esc_html($status_label) . '</span></td><td>' . esc_html(get_post_meta($job->ID, '_art_job_city', true) ?: '—') . '</td><td><strong>' . intval($count) . '</strong></td><td><div class="arttree-staff-row-actions"><a href="' . esc_url($follow_url) . '">متابعة الطلبات</a><a href="' . esc_url(get_edit_post_link($job->ID)) . '">تعديل</a></div></td></tr>';
        }
        $html .= '</tbody></table></div>';
        return $html;
    }

    private function render_staff_job_applications($job_id) {
        $title = get_the_title($job_id);
        $candidates = get_posts([
            'post_type' => 'art_candidate',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => 100,
            'orderby' => 'date',
            'order' => 'DESC',
            'meta_query' => [[
                'key' => '_art_candidate_job_title',
                'value' => $title,
                'compare' => '=',
            ]],
        ]);
        $html = '<div class="arttree-staff-detail-block"><h4>طلبات وظيفة: ' . esc_html($title) . '</h4>';
        if (!$candidates) {
            return $html . '<p class="arttree-empty-state">لا توجد طلبات على هذه الوظيفة حتى الآن.</p></div>';
        }
        $html .= '<div class="arttree-staff-table-wrap"><table class="arttree-staff-table"><thead><tr><th>المتقدم</th><th>الجوال</th><th>الحالة</th><th>السيرة</th><th>إجراء</th></tr></thead><tbody>';
        foreach ($candidates as $candidate) {
            $cv = get_post_meta($candidate->ID, '_art_candidate_cv_url', true);
            $status = get_post_meta($candidate->ID, '_art_candidate_status', true) ?: 'received';
            $status_label = $status === 'received' ? 'تم استلام الطلب' : $status;
            $html .= '<tr><td><strong>' . esc_html(get_post_meta($candidate->ID, '_art_candidate_full_name', true) ?: get_the_title($candidate)) . '</strong><small>' . esc_html(get_post_meta($candidate->ID, '_art_candidate_email', true)) . '</small></td><td>' . esc_html(get_post_meta($candidate->ID, '_art_candidate_phone', true) ?: '—') . '</td><td><span class="arttree-staff-badge pending">' . esc_html($status_label) . '</span></td><td>' . ($cv ? '<a href="' . esc_url($cv) . '">السيرة الذاتية</a>' : '—') . '</td><td><a href="' . esc_url(get_edit_post_link($candidate->ID)) . '">مراجعة الطلب</a></td></tr>';
        }
        $html .= '</tbody></table></div></div>';
        return $html;
    }

    private function render_staff_training_manager($active_tab = 'trainings') {
        $selected_training = isset($_GET['training_id']) ? absint($_GET['training_id']) : 0;
        $edit_training = isset($_GET['edit_training_id']) ? absint($_GET['edit_training_id']) : 0;
        $base_url = add_query_arg('staff_section', 'trainings', home_url('/staff-dashboard/'));
        $add_url = add_query_arg('staff_section', 'trainings_add', home_url('/staff-dashboard/'));
        ob_start();
        echo '<section class="arttree-dashboard-panel arttree-staff-manager-panel">';
        echo '<div class="arttree-staff-section-title"><div><span>إدارة الورش واللقاءات</span><h3>الورش واللقاءات والتدريب</h3><p>أضف ورشة أو لقاء أو برنامج تدريبي وتابع التسجيلات والحضور من نفس اللوحة.</p></div><div class="arttree-staff-title-actions"><a class="arttree-rt-primary" href="' . esc_url($add_url) . '">إضافة ورشة أو لقاء</a><a class="arttree-rt-secondary" href="' . esc_url(add_query_arg('staff_section', 'attendance', home_url('/staff-dashboard/'))) . '">تسجيل الحضور</a></div></div>';
        if ($selected_training) {
            echo '<div class="arttree-staff-subnav"><a href="' . esc_url($base_url) . '">عودة لقائمة الورش</a><a href="' . esc_url(add_query_arg('staff_section', 'attendance', home_url('/staff-dashboard/'))) . '">قارئ الباركود</a><a href="' . esc_url(add_query_arg(['staff_section' => 'trainings_add', 'edit_training_id' => $selected_training], home_url('/staff-dashboard/'))) . '">تعديل داخل اللوحة</a></div>';
            echo $this->render_staff_training_registrations_table($selected_training);
        }
        if ($active_tab === 'trainings_add' || $edit_training) {
            echo '<div class="arttree-staff-subnav"><a href="' . esc_url($base_url) . '">عودة لقائمة الورش</a></div>';
            echo $this->render_staff_training_form($edit_training);
        } else {
            echo '<div class="arttree-staff-list-card arttree-staff-list-card-wide"><h4>الورش واللقاءات المنشورة</h4>' . $this->render_staff_training_table($base_url, 'workshop') . '<h4 class="arttree-staff-list-subtitle">برامج التدريب</h4>' . $this->render_staff_training_table($base_url, 'training') . '</div>';
        }
        echo '</section>';
        return ob_get_clean();
    }

    private function render_staff_training_form($training_id = 0) {
        $training_id = absint($training_id);
        $is_edit = $training_id && get_post_type($training_id) === 'art_training';
        $title = $is_edit ? get_the_title($training_id) : '';
        $content = $is_edit ? get_post_field('post_content', $training_id) : '';
        $type = $is_edit ? (get_post_meta($training_id, '_art_training_type', true) ?: 'workshop') : 'workshop';
        $date = $is_edit ? get_post_meta($training_id, '_art_training_date', true) : '';
        $time = $is_edit ? get_post_meta($training_id, '_art_training_time', true) : '';
        $venue = $is_edit ? (get_post_meta($training_id, '_art_training_venue', true) ?: get_post_meta($training_id, '_art_training_location', true)) : '';
        $map_url = $is_edit ? get_post_meta($training_id, '_art_training_map_url', true) : '';
        $supervisor_phone = $is_edit ? get_post_meta($training_id, '_art_training_supervisor_phone', true) : '';
        $capacity = $is_edit ? get_post_meta($training_id, '_art_training_capacity', true) : '';
        $status = $is_edit ? (get_post_meta($training_id, '_art_training_status', true) ?: 'open') : 'open';
        $action = $is_edit ? 'arttree_staff_update_training' : 'arttree_staff_create_training';
        $nonce_action = $is_edit ? 'arttree_staff_update_training' : 'arttree_staff_create_training';
        $button = $is_edit ? 'حفظ التعديلات' : 'إضافة ونشر';
        $heading = $is_edit ? 'تعديل الورشة أو اللقاء داخل لوحة التحكم' : 'إضافة ورشة أو لقاء';
        $html = '<div class="arttree-staff-form-card arttree-staff-form-card-wide"><h4>' . esc_html($heading) . '</h4><form method="post" action="' . esc_url(admin_url('admin-post.php')) . '">';
        $html .= '<input type="hidden" name="action" value="' . esc_attr($action) . '">';
        if ($is_edit) {
            $html .= '<input type="hidden" name="training_id" value="' . esc_attr($training_id) . '">';
        }
        $html .= wp_nonce_field($nonce_action, 'arttree_staff_nonce', true, false);
        $html .= '<label><span>العنوان</span><input type="text" name="training_title" value="' . esc_attr($title) . '" required></label>';
        $html .= '<label><span>نوع القسم</span><select name="training_type"><option value="workshop"' . selected($type, 'workshop', false) . '>لقاء أو ورشة</option><option value="training"' . selected($type, 'training', false) . '>تدريب</option></select></label>';
        $html .= '<label><span>التاريخ</span><input type="date" name="training_date" value="' . esc_attr($date) . '"></label>';
        $html .= '<label><span>الوقت</span><input type="text" name="training_time" value="' . esc_attr($time) . '" placeholder="07:00 مساء"></label>';
        $html .= '<label><span>مكان الورشة أو اللقاء</span><input type="text" name="training_venue" value="' . esc_attr($venue) . '"></label>';
        $html .= '<label><span>رابط اللوكيشن</span><input type="url" name="training_map_url" value="' . esc_attr($map_url) . '"></label>';
        $html .= '<label><span>رقم المشرف</span><input type="text" name="training_supervisor_phone" value="' . esc_attr($supervisor_phone) . '"></label>';
        $html .= '<label><span>المقاعد</span><input type="number" name="training_capacity" min="0" value="' . esc_attr($capacity) . '"></label>';
        $html .= '<label><span>حالة التسجيل</span><select name="training_status"><option value="open"' . selected($status, 'open', false) . '>مفتوح</option><option value="closed"' . selected($status, 'closed', false) . '>مغلق</option><option value="hidden"' . selected($status, 'hidden', false) . '>مخفي</option></select></label>';
        $html .= '<label class="wide"><span>الوصف</span><textarea name="training_content" rows="5">' . esc_textarea($content) . '</textarea></label>';
        $html .= '<div class="arttree-staff-form-actions"><button class="arttree-rt-primary" type="submit">' . esc_html($button) . '</button><a class="arttree-rt-secondary" href="' . esc_url(add_query_arg('staff_section', 'trainings', home_url('/staff-dashboard/'))) . '">إلغاء</a></div>';
        $html .= '</form></div>';
        return $html;
    }

    private function render_staff_training_table($base_url, $type) {
        $items = get_posts([
            'post_type' => 'art_training',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => 50,
            'orderby' => 'meta_value',
            'meta_key' => '_art_training_date',
            'order' => 'DESC',
            'meta_query' => [[
                'key' => '_art_training_type',
                'value' => $type,
                'compare' => '=',
            ]],
        ]);
        if (!$items) {
            return '<p class="arttree-empty-state">لا توجد عناصر حتى الآن.</p>';
        }
        $html = '<div class="arttree-staff-table-wrap"><table class="arttree-staff-table"><thead><tr><th>العنوان</th><th>التاريخ</th><th>الحالة</th><th>المسجلين</th><th>إجراء</th></tr></thead><tbody>';
        foreach ($items as $item) {
            $regs = get_post_meta($item->ID, '_art_training_registrations', true);
            $regs = is_array($regs) ? $regs : [];
            $attended = 0;
            foreach ($regs as $reg) {
                if (($reg['attendance_status'] ?? '') === 'attended') { $attended++; }
            }
            $status_value = get_post_meta($item->ID, '_art_training_status', true) ?: 'open';
            $status_label = ['open' => 'مفتوح', 'closed' => 'مغلق', 'hidden' => 'مخفي'][$status_value] ?? $status_value;
            $follow_url = add_query_arg(['staff_section' => 'trainings', 'training_id' => $item->ID], home_url('/staff-dashboard/'));
            $html .= '<tr><td><strong>' . esc_html(get_the_title($item)) . '</strong><small>' . esc_html(get_post_meta($item->ID, '_art_training_venue', true) ?: get_post_meta($item->ID, '_art_training_location', true)) . '</small></td><td>' . esc_html(get_post_meta($item->ID, '_art_training_date', true) ?: '—') . '</td><td><span class="arttree-staff-badge ' . esc_attr($status_value === 'open' ? 'attended' : 'pending') . '">' . esc_html($status_label) . '</span></td><td><strong>' . intval(count($regs)) . '</strong><small>حضور ' . intval($attended) . '</small></td><td><div class="arttree-staff-row-actions"><a href="' . esc_url($follow_url) . '">متابعة التسجيلات</a><a href="' . esc_url(add_query_arg(['staff_section' => 'trainings_add', 'edit_training_id' => $item->ID], home_url('/staff-dashboard/'))) . '">تعديل داخل اللوحة</a></div></td></tr>';
        }
        $html .= '</tbody></table></div>';
        return $html;
    }

    private function render_staff_training_registrations_table($training_id) {
        $regs = get_post_meta($training_id, '_art_training_registrations', true);
        $regs = is_array($regs) ? $regs : [];
        $html = '<div class="arttree-staff-detail-block"><h4>التسجيلات: ' . esc_html(get_the_title($training_id)) . '</h4>';
        if (!$regs) {
            return $html . '<p class="arttree-empty-state">لا توجد تسجيلات حتى الآن.</p></div>';
        }
        $html .= '<div class="arttree-staff-table-wrap"><table class="arttree-staff-table"><thead><tr><th>المسجل</th><th>الجوال</th><th>رمز الدخول</th><th>الحضور</th><th>وقت الحضور</th><th>التقييم</th></tr></thead><tbody>';
        foreach ($regs as $reg) {
            $attended = (($reg['attendance_status'] ?? '') === 'attended');
            $html .= '<tr><td><strong>' . esc_html($reg['full_name'] ?? '—') . '</strong><small>' . esc_html($reg['email'] ?? '') . '</small></td><td>' . esc_html($reg['phone'] ?? '—') . '</td><td><code>' . esc_html($reg['ticket_code'] ?? '—') . '</code></td><td><span class="arttree-staff-badge ' . ($attended ? 'attended' : 'pending') . '">' . ($attended ? 'تم الحضور' : 'لم يحضر') . '</span></td><td>' . esc_html($reg['attendance_time'] ?? '—') . '</td><td>' . (!empty($reg['evaluation_submitted']) ? '<a class="arttree-staff-inline-link" href="' . esc_url(add_query_arg(['staff_section' => 'evaluations', 'evaluation_training_id' => $training_id], home_url('/staff-dashboard/'))) . '">عرض التقييم</a>' : '<span class="arttree-staff-badge pending">لم يقيم</span>') . '</td></tr>';
        }
        $html .= '</tbody></table></div><div class="arttree-staff-actions"><a class="arttree-rt-primary" href="' . esc_url(add_query_arg('staff_section', 'attendance', home_url('/staff-dashboard/'))) . '">فتح تسجيل الحضور</a></div></div>';
        return $html;
    }



    private function render_staff_kpi_card($label, $value, $meta, $icon = 'chart', $tone = 'primary') {
        return '<article class="arttree-staff-stat-card is-' . esc_attr($tone) . '"><span class="arttree-kpi-icon is-' . esc_attr($icon) . '" aria-hidden="true"></span><div class="arttree-kpi-card-body"><strong>' . esc_html((string) $value) . '</strong><span>' . esc_html($label) . '</span><small>' . esc_html($meta) . '</small></div></article>';
    }

    private function render_staff_evaluations_dashboard() {
        if (!$this->staff_can('arttree_manage_trainings') && !current_user_can('edit_posts')) {
            return '<section class="arttree-dashboard-panel"><h3>التقييمات</h3><p class="arttree-empty-state">لا تملك صلاحية عرض التقييمات.</p></section>';
        }
        $selected_training = isset($_GET['evaluation_training_id']) ? absint($_GET['evaluation_training_id']) : 0;
        $items = get_posts([
            'post_type' => 'art_training',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => -1,
            'orderby' => 'meta_value',
            'meta_key' => '_art_training_date',
            'order' => 'DESC',
        ]);
        $rows = [];
        $total_attended = 0;
        $total_evaluated = 0;
        $low_total = 0;
        $followup_total = 0;
        $score_sum = 0;
        $score_count = 0;
        $by_issue = [];
        foreach ($items as $item) {
            if ($selected_training && intval($item->ID) !== $selected_training) {
                continue;
            }
            $regs = get_post_meta($item->ID, '_art_training_registrations', true);
            $regs = is_array($regs) ? $regs : [];
            foreach ($regs as $reg) {
                $attended = (($reg['attendance_status'] ?? '') === 'attended');
                if ($attended) {
                    $total_attended++;
                }
                if (empty($reg['evaluation_submitted'])) {
                    continue;
                }
                $total_evaluated++;
                $ratings = [
                    absint($reg['evaluation_rating'] ?? 0),
                    absint($reg['evaluation_trainer_rating'] ?? 0),
                    absint($reg['evaluation_content_rating'] ?? 0),
                    absint($reg['evaluation_organization_rating'] ?? 0),
                    absint($reg['evaluation_benefit_rating'] ?? 0),
                ];
                $valid_ratings = array_values(array_filter($ratings, function($score){ return $score > 0; }));
                $avg = $valid_ratings ? round(array_sum($valid_ratings) / count($valid_ratings), 1) : 0;
                foreach ($valid_ratings as $score) {
                    $score_sum += $score;
                    $score_count++;
                }
                $has_low = false;
                foreach ($valid_ratings as $score) {
                    if ($score < 3) { $has_low = true; break; }
                }
                if ($has_low) {
                    $low_total++;
                }
                if (($reg['evaluation_allow_followup'] ?? 'yes') !== 'no') {
                    $followup_total++;
                }
                $rows[] = [
                    'training_id' => $item->ID,
                    'training_title' => get_the_title($item),
                    'name' => $reg['full_name'] ?? '—',
                    'email' => $reg['email'] ?? '',
                    'phone' => $reg['phone'] ?? '',
                    'ticket' => $reg['ticket_code'] ?? '',
                    'avg' => $avg,
                    'ratings' => $ratings,
                    'issue_reason' => $reg['evaluation_issue_reason'] ?? '',
                    'improvement' => $reg['evaluation_improvement_expected'] ?? '',
                    'best_part' => $reg['evaluation_best_part'] ?? '',
                    'suggestions' => $reg['evaluation_suggestions'] ?? '',
                    'comments' => $reg['evaluation_comments'] ?? '',
                    'allow_followup' => $reg['evaluation_allow_followup'] ?? 'yes',
                    'time' => $reg['evaluation_time'] ?? '',
                    'low' => $has_low,
                ];
            }
        }
        $overall_avg = $score_count ? round($score_sum / $score_count, 1) : 0;
        $completion_rate = $total_attended ? round(($total_evaluated / $total_attended) * 100) : 0;
        $html = '<section class="arttree-dashboard-panel arttree-staff-evaluations-panel"><div class="arttree-panel-title-row"><div><span>التقييمات</span><h3>إدارة تقييم اللقاءات والورش</h3></div><a class="arttree-rt-secondary" href="' . esc_url(add_query_arg('staff_section', 'trainings_regs', home_url('/staff-dashboard/'))) . '">متابعة التسجيلات</a></div>';
        $html .= '<p class="arttree-section-note">هنا تظهر كل تقييمات المشاركين بعد الحضور وإرسال نموذج التقييم مع أسباب التقييم المنخفض حتى يتم معرفة المشكلة ومعالجتها.</p>';
        $html .= '<div class="arttree-staff-kpi-grid arttree-staff-evaluation-kpis">';
        $html .= $this->render_staff_kpi_card('متوسط التقييم', $overall_avg ? $overall_avg . ' / 5' : '—', 'متوسط كل محاور التقييم', 'star', $overall_avg >= 4 ? 'success' : ($overall_avg >= 3 ? 'warning' : 'danger'));
        $html .= $this->render_staff_kpi_card('التقييمات المكتملة', $total_evaluated, 'من أصل ' . $total_attended . ' حضور', 'certificate', 'success');
        $html .= $this->render_staff_kpi_card('نسبة إكمال التقييم', $completion_rate . '%', 'الحضور الذين أكملوا التقييم', 'check', $completion_rate >= 70 ? 'success' : ($completion_rate >= 40 ? 'warning' : 'danger'));
        $html .= $this->render_staff_kpi_card('تقييمات تحتاج متابعة', $low_total, 'مقبول أو ضعيف', 'alert', $low_total > 0 ? 'danger' : 'success');
        $html .= '</div>';
        $html .= '<form class="arttree-staff-filter-bar" method="get"><input type="hidden" name="staff_section" value="evaluations"><label><span>تصفية حسب الورشة أو اللقاء</span><select name="evaluation_training_id"><option value="0">كل الورش واللقاءات</option>';
        foreach ($items as $item) {
            $html .= '<option value="' . esc_attr($item->ID) . '"' . selected($selected_training, $item->ID, false) . '>' . esc_html(get_the_title($item)) . '</option>';
        }
        $html .= '</select></label><button class="arttree-rt-primary" type="submit">تطبيق</button><a class="arttree-rt-secondary" href="' . esc_url(add_query_arg('staff_section', 'evaluations', home_url('/staff-dashboard/'))) . '">عرض الكل</a></form>';
        if (empty($rows)) {
            return $html . '<p class="arttree-empty-state">لا توجد تقييمات مرسلة حتى الآن.</p></section>';
        }
        $html .= '<div class="arttree-staff-table-wrap"><table class="arttree-staff-table arttree-staff-evaluations-table"><thead><tr><th>الورشة أو اللقاء</th><th>المشارك</th><th>المتوسط</th><th>التفاصيل</th><th>سبب المشكلة</th><th>المتابعة</th><th>تاريخ التقييم</th></tr></thead><tbody>';
        foreach ($rows as $row) {
            $ratings_text = 'عام ' . intval($row['ratings'][0]) . ' | مدرب ' . intval($row['ratings'][1]) . ' | محتوى ' . intval($row['ratings'][2]) . ' | تنظيم ' . intval($row['ratings'][3]) . ' | استفادة ' . intval($row['ratings'][4]);
            $reason = $row['issue_reason'] ?: ($row['low'] ? 'لم يتم إدخال سبب مفصل' : 'لا توجد ملاحظات سلبية');
            $follow = ($row['allow_followup'] === 'no') ? 'لا يرغب بالتواصل' : 'يسمح بالتواصل';
            $html .= '<tr class="' . ($row['low'] ? 'is-low-rating' : '') . '">';
            $html .= '<td><strong>' . esc_html($row['training_title']) . '</strong><small>رمز الدخول ' . esc_html($row['ticket'] ?: '—') . '</small></td>';
            $html .= '<td><strong>' . esc_html($row['name']) . '</strong><small>' . esc_html(trim(($row['phone'] ?: '') . ' ' . ($row['email'] ?: ''))) . '</small></td>';
            $html .= '<td><span class="arttree-staff-score-badge ' . esc_attr($row['low'] ? 'danger' : 'success') . '">' . esc_html($row['avg'] ? $row['avg'] . ' / 5' : '—') . '</span></td>';
            $html .= '<td><small>' . esc_html($ratings_text) . '</small><details><summary>عرض الملاحظات</summary><p><strong>أكثر جزء استفاد منه</strong> ' . esc_html($row['best_part'] ?: '—') . '</p><p><strong>المقترحات</strong> ' . esc_html($row['suggestions'] ?: '—') . '</p><p><strong>ملاحظات إضافية</strong> ' . esc_html($row['comments'] ?: '—') . '</p></details></td>';
$html .= '<td><small>' . esc_html($reason) . '</small><small>التحسين المطلوب: ' . esc_html($row['improvement'] ?: '—') . '</small></td>';
            $html .= '<td><span class="arttree-staff-badge ' . esc_attr($row['allow_followup'] === 'no' ? 'pending' : 'attended') . '">' . esc_html($follow) . '</span></td>';
            $html .= '<td>' . esc_html($row['time'] ?: '—') . '</td>';
            $html .= '</tr>';
        }
        $html .= '</tbody></table></div></section>';
        return $html;
    }

    public function handle_staff_create_job() {
        if (!$this->staff_can('arttree_manage_jobs')) {
            wp_die('غير مصرح.');
        }
        if (!isset($_POST['arttree_staff_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_staff_nonce'])), 'arttree_staff_create_job')) {
            wp_die('رابط غير صالح.');
        }
        $title = sanitize_text_field(wp_unslash($_POST['job_title'] ?? ''));
        if (!$title) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'applications', 'arttree_error' => 'missing_title'], home_url('/staff-dashboard/')));
            exit;
        }
        $post_id = wp_insert_post([
            'post_type' => 'art_job',
            'post_status' => 'publish',
            'post_title' => $title,
            'post_content' => wp_kses_post(wp_unslash($_POST['job_content'] ?? '')),
        ]);
        if ($post_id && !is_wp_error($post_id)) {
            update_post_meta($post_id, '_art_job_department', sanitize_text_field(wp_unslash($_POST['job_department'] ?? '')));
            update_post_meta($post_id, '_art_job_city', sanitize_text_field(wp_unslash($_POST['job_city'] ?? '')));
            update_post_meta($post_id, '_art_job_type', sanitize_text_field(wp_unslash($_POST['job_type'] ?? '')));
            update_post_meta($post_id, '_art_job_deadline', sanitize_text_field(wp_unslash($_POST['job_deadline'] ?? '')));
            update_post_meta($post_id, '_art_job_status', sanitize_key(wp_unslash($_POST['job_status'] ?? 'open')));
        }
        wp_safe_redirect(add_query_arg(['staff_section' => 'applications', 'arttree_notice' => 'job_created'], home_url('/staff-dashboard/')));
        exit;
    }

    public function handle_staff_create_training() {
        if (!$this->staff_can('arttree_manage_trainings')) {
            wp_die('غير مصرح.');
        }
        if (!isset($_POST['arttree_staff_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_staff_nonce'])), 'arttree_staff_create_training')) {
            wp_die('رابط غير صالح.');
        }
        $title = sanitize_text_field(wp_unslash($_POST['training_title'] ?? ''));
        if (!$title) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'trainings', 'arttree_error' => 'missing_title'], home_url('/staff-dashboard/')));
            exit;
        }
        $post_id = wp_insert_post([
            'post_type' => 'art_training',
            'post_status' => 'publish',
            'post_title' => $title,
            'post_content' => wp_kses_post(wp_unslash($_POST['training_content'] ?? '')),
        ]);
        if ($post_id && !is_wp_error($post_id)) {
            update_post_meta($post_id, '_art_training_type', sanitize_key(wp_unslash($_POST['training_type'] ?? 'workshop')));
            update_post_meta($post_id, '_art_training_date', sanitize_text_field(wp_unslash($_POST['training_date'] ?? '')));
            update_post_meta($post_id, '_art_training_time', sanitize_text_field(wp_unslash($_POST['training_time'] ?? '')));
            update_post_meta($post_id, '_art_training_venue', sanitize_text_field(wp_unslash($_POST['training_venue'] ?? '')));
            update_post_meta($post_id, '_art_training_location', sanitize_text_field(wp_unslash($_POST['training_venue'] ?? '')));
            update_post_meta($post_id, '_art_training_map_url', esc_url_raw(wp_unslash($_POST['training_map_url'] ?? '')));
            update_post_meta($post_id, '_art_training_supervisor_phone', sanitize_text_field(wp_unslash($_POST['training_supervisor_phone'] ?? '')));
            update_post_meta($post_id, '_art_training_capacity', sanitize_text_field(wp_unslash($_POST['training_capacity'] ?? '')));
            update_post_meta($post_id, '_art_training_status', sanitize_key(wp_unslash($_POST['training_status'] ?? 'open')));
        }
        wp_safe_redirect(add_query_arg(['staff_section' => 'trainings', 'arttree_notice' => 'training_created'], home_url('/staff-dashboard/')));
        exit;
    }

    public function handle_staff_update_training() {
        if (!$this->staff_can('arttree_manage_trainings')) {
            wp_die('غير مصرح.');
        }
        if (!isset($_POST['arttree_staff_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_staff_nonce'])), 'arttree_staff_update_training')) {
            wp_die('رابط غير صالح.');
        }
        $training_id = absint($_POST['training_id'] ?? 0);
        if (!$training_id || get_post_type($training_id) !== 'art_training') {
            wp_safe_redirect(add_query_arg(['staff_section' => 'trainings', 'arttree_error' => 'missing_training'], home_url('/staff-dashboard/')));
            exit;
        }
        $title = sanitize_text_field(wp_unslash($_POST['training_title'] ?? ''));
        if (!$title) {
            wp_safe_redirect(add_query_arg(['staff_section' => 'trainings_add', 'edit_training_id' => $training_id, 'arttree_error' => 'missing_title'], home_url('/staff-dashboard/')));
            exit;
        }
        wp_update_post([
            'ID' => $training_id,
            'post_title' => $title,
            'post_content' => wp_kses_post(wp_unslash($_POST['training_content'] ?? '')),
        ]);
        update_post_meta($training_id, '_art_training_type', sanitize_key(wp_unslash($_POST['training_type'] ?? 'workshop')));
        update_post_meta($training_id, '_art_training_date', sanitize_text_field(wp_unslash($_POST['training_date'] ?? '')));
        update_post_meta($training_id, '_art_training_time', sanitize_text_field(wp_unslash($_POST['training_time'] ?? '')));
        update_post_meta($training_id, '_art_training_venue', sanitize_text_field(wp_unslash($_POST['training_venue'] ?? '')));
        update_post_meta($training_id, '_art_training_location', sanitize_text_field(wp_unslash($_POST['training_venue'] ?? '')));
        update_post_meta($training_id, '_art_training_map_url', esc_url_raw(wp_unslash($_POST['training_map_url'] ?? '')));
        update_post_meta($training_id, '_art_training_supervisor_phone', sanitize_text_field(wp_unslash($_POST['training_supervisor_phone'] ?? '')));
        update_post_meta($training_id, '_art_training_capacity', sanitize_text_field(wp_unslash($_POST['training_capacity'] ?? '')));
        update_post_meta($training_id, '_art_training_status', sanitize_key(wp_unslash($_POST['training_status'] ?? 'open')));
        wp_safe_redirect(add_query_arg(['staff_section' => 'trainings', 'training_id' => $training_id, 'arttree_notice' => 'training_updated'], home_url('/staff-dashboard/')));
        exit;
    }

    public function handle_staff_update_theme_controls() {
        if (!$this->staff_can('arttree_manage_theme')) {
            wp_die('غير مصرح.');
        }
        if (!isset($_POST['arttree_staff_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_staff_nonce'])), 'arttree_staff_update_theme_controls')) {
            wp_die('رابط غير صالح.');
        }
        $home_sections = $this->theme_home_sections();
        $posted_home = isset($_POST['home_sections']) && is_array($_POST['home_sections']) ? wp_unslash($_POST['home_sections']) : [];
        foreach ($home_sections as $key => $label) {
            set_theme_mod('dewan_show_' . $key, isset($posted_home[$key]));
        }
        $system_controls = $this->system_controls();
        $posted_systems = isset($_POST['systems']) && is_array($_POST['systems']) ? wp_unslash($_POST['systems']) : [];
        $systems = [];
        foreach ($system_controls as $key => $data) {
            $systems[$key] = isset($posted_systems[$key]);
        }
        $controls = [
            'primary_color' => sanitize_hex_color(wp_unslash($_POST['primary_color'] ?? '')) ?: '#503d7a',
            'accent_color' => sanitize_hex_color(wp_unslash($_POST['accent_color'] ?? '')) ?: '#d7b46a',
            'hero_cta_label' => sanitize_text_field(wp_unslash($_POST['hero_cta_label'] ?? 'اطلب استشارة')),
            'hero_cta_url' => esc_url_raw(wp_unslash($_POST['hero_cta_url'] ?? '#contact')),
            'site_mode' => in_array(sanitize_key(wp_unslash($_POST['site_mode'] ?? 'live')), ['live', 'coming_soon', 'maintenance'], true) ? sanitize_key(wp_unslash($_POST['site_mode'] ?? 'live')) : 'live',
            'coming_title' => sanitize_text_field(wp_unslash($_POST['coming_title'] ?? 'الموقع قريبا')),
            'coming_message' => sanitize_textarea_field(wp_unslash($_POST['coming_message'] ?? 'نعمل حاليا على تجهيز تجربة رقمية متكاملة وسنعود قريبا.')),
            'coming_countdown_date' => preg_match('/^\d{4}-\d{2}-\d{2}$/', sanitize_text_field(wp_unslash($_POST['coming_countdown_date'] ?? ''))) ? sanitize_text_field(wp_unslash($_POST['coming_countdown_date'])) : date('Y-m-d', strtotime('+30 days')),
            'maintenance_title' => sanitize_text_field(wp_unslash($_POST['maintenance_title'] ?? 'الموقع تحت الصيانة')),
            'maintenance_message' => sanitize_textarea_field(wp_unslash($_POST['maintenance_message'] ?? 'نقوم حاليا بتحديث الموقع وتحسين الأنظمة. يرجى العودة بعد قليل.')),
            'systems' => $systems,
        ];
        update_option('arttree_theme_controls', $controls, false);
        $return_section = isset($_POST['return_staff_section']) ? sanitize_key(wp_unslash($_POST['return_staff_section'])) : 'control';
        if (!in_array($return_section, ['control', 'control_home', 'control_systems', 'control_mode', 'control_ui', 'control_links'], true)) {
            $return_section = 'control';
        }
        wp_safe_redirect(add_query_arg(['staff_section' => $return_section, 'theme_controls_saved' => '1'], home_url('/staff-dashboard/')));
        exit;
    }


    private function render_staff_posts_table($post_type, $headers) {
        $posts = get_posts(['post_type' => $post_type, 'post_status' => ['publish', 'draft', 'pending'], 'numberposts' => 20, 'orderby' => 'date', 'order' => 'DESC']);
        if (!$posts) {
            return '<p class="arttree-empty-state">لا توجد بيانات حتى الآن.</p>';
        }
        $html = '<div class="arttree-staff-table-wrap"><table class="arttree-staff-table"><thead><tr>';
        foreach ($headers as $head) {
            $html .= '<th>' . esc_html($head) . '</th>';
        }
        $html .= '</tr></thead><tbody>';
        foreach ($posts as $post) {
            $status = get_post_status_object($post->post_status);
            $date_label = get_the_date('Y-m-d', $post);
            if ($post_type === 'art_training') {
                $meta_date = get_post_meta($post->ID, '_art_training_date', true);
                $date_label = $meta_date ?: $date_label;
                $status_label = get_post_meta($post->ID, '_art_training_status', true) ?: ($status ? $status->label : $post->post_status);
                $second = $status_label;
            } elseif ($post_type === 'art_certificate') {
                $second = get_post_meta($post->ID, '_art_certificate_code', true) ?: '—';
            } else {
                $second = get_post_meta($post->ID, '_art_candidate_status', true) ?: ($status ? $status->label : $post->post_status);
            }
            $html .= '<tr><td><strong>' . esc_html(get_the_title($post)) . '</strong></td><td>' . esc_html($second) . '</td><td>' . esc_html($date_label) . '</td><td><a href="' . esc_url(get_edit_post_link($post->ID)) . '">إدارة</a></td></tr>';
        }
        $html .= '</tbody></table></div>';
        return $html;
    }

    private function render_staff_checkin_scanner() {
        $base_url = add_query_arg('staff_section', 'attendance', home_url('/staff-dashboard/'));
        $items = get_posts([
            'post_type' => 'art_training',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => -1,
            'orderby' => 'date',
            'order' => 'DESC',
            'fields' => 'ids',
        ]);
        $selected_id = 0;
        if (!empty($_POST['arttree_training_id'])) {
            $selected_id = absint(wp_unslash($_POST['arttree_training_id']));
        } elseif (!empty($_GET['arttree_training_id'])) {
            $selected_id = absint(wp_unslash($_GET['arttree_training_id']));
        }
        if (!$selected_id && !empty($items)) {
            $selected_id = absint($items[0]);
        }
        $result = null;
        if (isset($_GET['arttree_checkin'])) {
            $result = $this->process_workshop_checkin(wp_unslash($_GET['arttree_checkin']), $selected_id);
        } elseif (!empty($_POST['arttree_ticket_code']) && isset($_POST['arttree_checkin_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_checkin_nonce'])), 'arttree_workshop_checkin')) {
            $result = $this->process_workshop_checkin(wp_unslash($_POST['arttree_ticket_code']), $selected_id);
        }
        $html = '<div class="arttree-dashboard-checkin-panel">';
        $html .= '<div class="arttree-panel-title-row"><div><span>قارئ مخصص لكل ورشة</span><h3>تسجيل الحضور من لوحة التحكم</h3><p>اختر الورشة أو اللقاء ثم امسح الباركود. أي باركود لا يخص الورشة المحددة سيتم رفضه.</p></div></div>';
        if ($result) {
            $class = $result['status'] === 'success' ? 'success' : ($result['status'] === 'already' ? 'already' : 'error');
            $html .= '<div class="arttree-checkin-result ' . esc_attr($class) . '"><strong>' . esc_html($result['message']) . '</strong>';
            if (!empty($result['ticket'])) {
                $html .= '<div class="arttree-checkin-details"><p><span>الورشة</span>' . esc_html($result['title'] ?? '') . '</p><p><span>المشارك</span>' . esc_html($result['name'] ?? '') . '</p><p><span>البريد</span>' . esc_html($result['email'] ?? '') . '</p><p><span>الجوال</span>' . esc_html($result['phone'] ?? '') . '</p><p><span>رمز الدخول</span><code>' . esc_html($result['ticket']) . '</code></p><p><span>وقت التسجيل</span>' . esc_html($result['time'] ?? '') . '</p></div>';
            }
            $html .= '</div>';
        }
        if (empty($items)) {
            $html .= '<div class="arttree-checkin-card"><h3>لا توجد ورش أو لقاءات</h3><p>أضف ورشة أو لقاء أولا حتى يعمل قارئ الباركود.</p></div></div>';
            return $html;
        }
        $html .= '<div class="arttree-checkin-grid arttree-dashboard-checkin-grid">';
        $html .= '<div class="arttree-checkin-card"><h3>اختيار الورشة أو اللقاء</h3><p>هذا الاختيار يربط القارئ بالورشة المحددة فقط.</p><form method="get" class="arttree-checkin-select-form"><input type="hidden" name="staff_section" value="attendance"><label>الورشة أو اللقاء<select name="arttree_training_id" onchange="this.form.submit()">';
        foreach ($items as $item_id) {
            $regs = get_post_meta($item_id, '_art_training_registrations', true);
            $regs = is_array($regs) ? $regs : [];
            $html .= '<option value="' . esc_attr($item_id) . '" ' . selected($selected_id, $item_id, false) . '>' . esc_html(get_the_title($item_id)) . ' - ' . count($regs) . ' مسجل</option>';
        }
        $html .= '</select></label></form></div>';
        $html .= '<div class="arttree-checkin-card"><h3>مسح بالكاميرا</h3><p>وجه الكاميرا إلى باركود المشارك بعد اختيار الورشة أو اللقاء.</p><div class="arttree-camera-box"><video data-arttree-scanner-video playsinline muted></video><div id="arttree-dashboard-qr-reader" data-arttree-html5-reader></div><div data-arttree-scanner-status>الكاميرا متوقفة</div></div><button class="arttree-rt-primary" type="button" data-arttree-scanner-start>تشغيل الكاميرا</button><button class="arttree-rt-secondary" type="button" data-arttree-scanner-stop>إيقاف الكاميرا</button></div>';
        $html .= '<form class="arttree-checkin-card" method="post" data-arttree-checkin-form><h3>إدخال يدوي</h3><p>يمكن لصق رابط QR أو إدخال رمز الدخول مباشرة.</p>';
        $html .= wp_nonce_field('arttree_workshop_checkin', 'arttree_checkin_nonce', true, false);
        $html .= '<input type="hidden" name="arttree_training_id" value="' . esc_attr($selected_id) . '"><label>رمز الباركود أو رابط QR<input required type="text" name="arttree_ticket_code" data-arttree-ticket-input placeholder="DHL-..."></label><button type="submit">تسجيل الحضور</button></form>';
        $html .= '</div></div>';
        return $html;
    }

    private function render_staff_attendance_table() {
        $posts = get_posts(['post_type' => 'art_training', 'post_status' => ['publish', 'draft'], 'numberposts' => 50, 'orderby' => 'date', 'order' => 'DESC']);
        $rows = [];
        foreach ($posts as $post) {
            $regs = get_post_meta($post->ID, '_art_training_registrations', true);
            if (!is_array($regs)) {
                continue;
            }
            foreach ($regs as $reg) {
                $attended = ($reg['attendance_status'] ?? '') === 'attended';
                $rows[] = [
                    'event' => get_the_title($post),
                    'name' => $reg['full_name'] ?? $reg['name'] ?? 'متقدم',
                    'phone' => $reg['phone'] ?? '—',
                    'email' => $reg['email'] ?? '—',
                    'ticket' => $reg['ticket_code'] ?? '—',
                    'status' => $attended ? 'تم الحضور' : 'مسجل',
                    'time' => $reg['attendance_time'] ?? '—',
                    'class' => $attended ? 'attended' : 'pending',
                ];
            }
        }
        if (!$rows) {
            return '<p class="arttree-empty-state">لا يوجد مسجلون حتى الآن.</p>';
        }
        $html = '<div class="arttree-staff-table-wrap"><table class="arttree-staff-table"><thead><tr><th>اللقاء أو الورشة</th><th>المشارك</th><th>التواصل</th><th>رمز الدخول</th><th>الحالة</th><th>وقت الحضور</th><th>التقييم</th></tr></thead><tbody>';
        foreach ($rows as $row) {
            $html .= '<tr><td><strong>' . esc_html($row['event']) . '</strong></td><td>' . esc_html($row['name']) . '</td><td><small>' . esc_html($row['phone']) . '<br>' . esc_html($row['email']) . '</small></td><td><code>' . esc_html($row['ticket']) . '</code></td><td><span class="arttree-staff-badge ' . esc_attr($row['class']) . '">' . esc_html($row['status']) . '</span></td><td>' . esc_html($row['time']) . '</td></tr>';
        }
        $html .= '</tbody></table></div>';
        return $html;
    }

    public function portal_shortcode() {
        if (!$this->system_enabled('portal')) { return $this->disabled_system_message('بوابة المتقدم'); }
        ob_start();
        $gate_type = isset($_GET['arttree_gate']) ? sanitize_key(wp_unslash($_GET['arttree_gate'])) : '';
        $gate_id = isset($_GET['item_id']) ? absint($_GET['item_id']) : 0;
        $has_gate = in_array($gate_type, ['job', 'training', 'workshop'], true) && $gate_id;
        $item_title = $has_gate ? get_the_title($gate_id) : '';
        $portal_title = $has_gate ? $this->gate_label($gate_type) : 'بوابة التسجيل';
        $portal_desc = $has_gate && $item_title
            ? 'للمتابعة على ' . $item_title . ' اختر إنشاء حساب جديد أو سجل الدخول إذا كان لديك حساب مسبقاً.'
            : 'بوابة موحدة للتقديم على الوظائف وبرنامج التجربة المهنية للمحاماة والتسجيل في اللقاءات والورش.';

        echo '<section class="arttree-rt arttree-portal arttree-applicant-portal arttree-portal-page" dir="rtl">';
        echo $this->portal_notice();
        echo $this->portal_error();

        if (is_user_logged_in()) {
            if ($has_gate) {
                $gate_result = $this->create_user_request(get_current_user_id(), $gate_type, $gate_id);
                if ($gate_result === 'created') {
                    echo '<div class="arttree-portal-notice">تم تفعيل الاشتراك وربطه بحسابك، ويمكنك الآن عرض باركود الدخول من لوحة المتقدم.</div>';
                } elseif ($gate_result === 'exists') {
                    echo '<div class="arttree-portal-notice">هذا التسجيل موجود مسبقاً في حسابك ويمكنك عرض باركود الدخول من لوحة المتقدم.</div>';
                }
            }
            echo '<div class="arttree-rt-hero arttree-portal-hero"><span class="arttree-eyebrow">لوحة المتقدم</span><h2>متابعة الطلبات من مكان واحد</h2><p>تعرض اللوحة حالة الطلبات والمواعيد والمتطلبات والرسائل الخاصة بالمتقدم.</p><div class="arttree-rt-actions"><a class="arttree-rt-primary" href="' . esc_url(home_url('/careers/')) . '">استعراض الفرص</a><a class="arttree-rt-secondary" href="' . esc_url(home_url('/events-workshops/')) . '">اللقاءات والورش</a></div></div>';
            echo $this->render_portal_dashboard();
        } else {
            echo '<div class="arttree-rt-hero arttree-portal-hero"><span class="arttree-eyebrow">' . esc_html($portal_title) . '</span><h2>حساب واحد للتوظيف والتدريب والورش</h2><p>' . esc_html($portal_desc) . '</p><div class="arttree-rt-actions"><a class="arttree-rt-primary" href="#create-account">إنشاء حساب جديد</a><a class="arttree-rt-secondary" href="#login">لدي حساب بالفعل</a></div></div>';
            echo $this->render_portal_auth_forms($gate_type, $gate_id);

            echo '<div class="arttree-portal-grid arttree-portal-public-grid">';
            $cards = [
                [home_url('/careers/'), 'التوظيف والتدريب', 'استعراض الوظائف المتاحة وبرنامج التجربة المهنية للمحاماة.'],
                [home_url('/events-workshops/'), 'اللقاءات والورش', 'التسجيل في اللقاءات والورش القانونية المتاحة.'],
                [home_url('/certificate-verify/'), 'التحقق من الشهادات', 'التحقق من شهادة حضور أو مشاركة باستخدام رمز التحقق.'],
            ];
            foreach ($cards as $card) {
                echo '<a class="arttree-portal-card" href="' . esc_url($card[0]) . '"><span aria-hidden="true"></span><h3>' . esc_html($card[1]) . '</h3><p>' . esc_html($card[2]) . '</p></a>';
            }
            echo '</div>';
            echo '<div class="arttree-rt-faq"><h3>الأسئلة الشائعة</h3><details><summary>هل أحتاج إلى حساب للتسجيل؟</summary><p>نعم، يتم إنشاء حساب أو تسجيل الدخول قبل إكمال طلب وظيفة أو تدريب أو ورشة.</p></details><details><summary>هل يمكنني متابعة الطلب بعد التسجيل؟</summary><p>نعم، ستظهر الطلبات داخل لوحة المتقدم بعد تسجيل الدخول.</p></details><details><summary>هل يوجد حسابات تجريبية؟</summary><p>نعم، تم إضافة حسابات وهمية للتجربة داخل صندوق تسجيل الدخول.</p></details></div>';
        }
        echo '</section>';
        return ob_get_clean();
    }

    public function jobs_shortcode() {
        if (!$this->system_enabled('jobs') && !$this->system_enabled('training')) { return $this->disabled_system_message('التوظيف والتدريب'); }
        $jobs = new WP_Query([
            'post_type' => 'art_job',
            'posts_per_page' => -1,
            'post_status' => 'publish',
            'orderby' => 'date',
            'order' => 'DESC',
        ]);
        $experience_programs = new WP_Query([
            'post_type' => 'art_training',
            'posts_per_page' => -1,
            'post_status' => 'publish',
            'orderby' => 'meta_value',
            'meta_key' => '_art_training_date',
            'order' => 'ASC',
            'meta_query' => [[
                'key' => '_art_training_type',
                'value' => 'training',
                'compare' => '=',
            ]],
        ]);
        ob_start();
        echo '<section class="arttree-rt arttree-jobs-page arttree-combined-page" dir="rtl">';
        if (is_user_logged_in()) {
            echo '<div class="arttree-rt-hero"><span class="arttree-eyebrow">التوظيف والتدريب</span><h2>فرص مهنية وبرنامج التجربة المهنية للمحاماة</h2><p>صفحة واحدة للتقديم على الوظائف الشاغرة والتسجيل في برنامج التجربة المهنية للمحاماة مع عرض الفرص المفتوحة والمنتهية بشكل واضح.</p><div class="arttree-rt-actions"><a class="arttree-rt-primary" href="#arttree-jobs-list">استعراض الفرص</a><a class="arttree-rt-secondary" href="' . esc_url(add_query_arg('portal_section', 'jobs', home_url('/registration-portal/'))) . '">لوحة المتقدم</a></div></div>';
        } else {
            echo '<div class="arttree-rt-hero"><span class="arttree-eyebrow">التوظيف والتدريب</span><h2>فرص مهنية وبرنامج التجربة المهنية للمحاماة</h2><p>صفحة واحدة للتقديم على الوظائف الشاغرة والتسجيل في برنامج التجربة المهنية للمحاماة مع عرض الفرص المفتوحة والمنتهية بشكل واضح.</p><div class="arttree-rt-actions"><a class="arttree-rt-primary" href="#arttree-jobs-list">استعراض الفرص</a><a class="arttree-rt-secondary" href="' . esc_url($this->login_url()) . '">الدخول للبوابة</a></div></div>';
        }
        if ($this->system_enabled('jobs')) {
        echo '<div class="arttree-rt-section-head"><span>المسار الأول</span><h3>الوظائف الشاغرة</h3><p>اختر الوظيفة المناسبة وقدم بياناتك ليتم تحويل الطلب للموارد البشرية.</p></div>';
        echo '<div id="arttree-jobs-list" class="arttree-rt-grid">';
        if ($jobs->have_posts()) {
            while ($jobs->have_posts()) {
                $jobs->the_post();
                $job_id = get_the_ID();
                if ($this->field($job_id, '_art_job_status', 'open') === 'hidden') { continue; }
                $closed = $this->is_job_closed($job_id);
                echo '<article class="arttree-rt-card ' . ($closed ? 'is-closed' : 'is-open') . '">';
                echo '<div class="arttree-card-top"><span class="arttree-status ' . ($closed ? 'closed' : 'open') . '">' . ($closed ? 'انتهى التقديم' : 'متاح للتقديم') . '</span></div>';
                echo '<h3>' . esc_html(get_the_title()) . '</h3>';
                echo '<div class="arttree-rt-meta"><span>' . esc_html($this->field($job_id, '_art_job_department')) . '</span><span>' . esc_html($this->field($job_id, '_art_job_city')) . '</span><span>' . esc_html($this->field($job_id, '_art_job_type')) . '</span></div>';
                echo '<p>' . esc_html(wp_trim_words(get_the_excerpt() ?: wp_strip_all_tags(get_the_content()), 32)) . '</p>';
                if ($this->field($job_id, '_art_job_deadline')) {
                    echo '<div class="arttree-deadline">آخر موعد للتقديم: ' . esc_html($this->field($job_id, '_art_job_deadline')) . '</div>';
                }
                if ($closed) {
                    echo '<button class="arttree-rt-disabled" type="button" disabled>التقديم مغلق</button>';
                } else {
                    echo '<a class="arttree-rt-primary" href="' . esc_url(get_permalink($job_id)) . '">تقديم على الوظيفة</a>';
                }
                echo '</article>';
            }
            wp_reset_postdata();
        } else {
            echo '<p class="arttree-rt-empty">لا توجد وظائف حالياً.</p>';
        }
        echo '</div>';
        }
        if ($this->system_enabled('training')) {
        echo '<div class="arttree-rt-section-head"><span>المسار الثاني</span><h3>برنامج التجربة المهنية للمحاماة</h3><p>برنامج تدريبي عملي للمهتمين بالمجال القانوني للتعرف على بيئة العمل داخل المنشآت القانونية.</p></div>';
        echo '<div id="arttree-experience-list" class="arttree-rt-grid">';
        if ($experience_programs->have_posts()) {
            while ($experience_programs->have_posts()) {
                $experience_programs->the_post();
                $id = get_the_ID();
                if ($this->field($id, '_art_training_status', 'open') === 'hidden') { continue; }
                $closed = $this->is_training_closed($id);
                echo '<article class="arttree-rt-card ' . ($closed ? 'is-closed' : 'is-open') . '">';
                echo '<div class="arttree-card-top"><span class="arttree-status ' . ($closed ? 'closed' : 'open') . '">' . ($closed ? 'انتهى التسجيل' : 'التسجيل متاح') . '</span></div>';
                echo '<h3>' . esc_html(get_the_title()) . '</h3>';
                $card_date = $this->field($id, '_art_training_date');
                $card_time = $this->field($id, '_art_training_time');
                $card_location = $this->field($id, '_art_training_venue') ?: $this->field($id, '_art_training_location');
                $card_map_url = $this->field($id, '_art_training_map_url');
                echo '<div class="arttree-rt-meta arttree-card-meta-icons">';
                echo '<span>' . $this->rt_icon('date') . '<b>التاريخ</b><em>' . esc_html($card_date ?: 'يحدد لاحقاً') . '</em></span>';
                echo '<span>' . $this->rt_icon('time') . '<b>الوقت</b><em>' . esc_html($card_time ?: 'يحدد لاحقاً') . '</em></span>';
                echo '<span>' . $this->rt_icon('location') . '<b>الموقع</b><em>' . esc_html($card_location ?: 'يحدد لاحقاً') . '</em></span>';
                echo '</div>';
                if ($card_map_url) {
                    echo '<a class="arttree-map-card-btn" href="' . esc_url($card_map_url) . '">' . $this->rt_icon('map') . '<span>فتح اللوكيشن على قوقل ماب</span></a>';
                }
                echo '<p>' . esc_html(wp_trim_words(get_the_excerpt() ?: wp_strip_all_tags(get_the_content()), 32)) . '</p>';
                if ($this->user_is_registered_for_training($id)) {
                    echo '<button class="arttree-rt-disabled arttree-registered-btn" type="button" disabled>تم تسجيلك</button>';
                    echo '<a class="arttree-rt-secondary arttree-details-btn" href="' . esc_url(get_permalink($id)) . '">تفاصيل البرنامج</a>';
                } elseif ($closed) {
                    echo '<button class="arttree-rt-disabled" type="button" disabled>انتهى التسجيل</button>';
                    echo '<a class="arttree-rt-secondary arttree-details-btn" href="' . esc_url(get_permalink($id)) . '">مشاهدة التفاصيل</a>';
                } else {
                    echo '<a class="arttree-rt-primary" href="' . esc_url(get_permalink($id)) . '">التسجيل في البرنامج</a>';
                }
                echo '</article>';
            }
            wp_reset_postdata();
        } else {
            echo '<p class="arttree-rt-empty">لا توجد برامج تدريبية حالياً.</p>';
        }
        echo '</div>';
        }
        echo '<div class="arttree-rt-faq"><h3>أسئلة التوظيف والتدريب</h3><details><summary>هل التوظيف والتدريب في صفحة واحدة؟</summary><p>نعم، تم دمج التوظيف وبرنامج التجربة المهنية للمحاماة في صفحة واحدة لتسهيل الوصول.</p></details><details><summary>هل تظهر الفرص المنتهية؟</summary><p>نعم، تظهر الوظائف والبرامج المنتهية بحالة واضحة حتى يعرف الزائر أن التقديم أو التسجيل لم يعد متاحاً.</p></details><details><summary>كيف أتابع طلبي؟</summary><p>يمكن الدخول إلى بوابة المتقدمين لمتابعة الطلبات بعد تفعيل نظام الحسابات وربط الطلب بحساب المستخدم.</p></details></div>';
        echo '</section>';
        return ob_get_clean();
    }

    private function render_candidate_fields() {
        $fields = [
            'full_name' => ['الاسم الكامل', 'text'],
            'email' => ['البريد الإلكتروني', 'email'],
            'phone' => ['رقم الجوال', 'text'],
            'national_id' => ['رقم الهوية أو الإقامة', 'text'],
            'city' => ['المدينة', 'text'],
            'qualification' => ['المؤهل العلمي', 'text'],
            'experience' => ['سنوات الخبرة', 'text'],
        ];
        foreach ($fields as $name => [$label, $type]) {
            printf('<label><span>%s</span><input required type="%s" name="%s"></label>', esc_html($label), esc_attr($type), esc_attr($name));
        }
        echo '<label class="wide"><span>نبذة مختصرة</span><textarea name="summary" rows="4"></textarea></label>';
    }

    public function handle_update_applicant_profile() {
        if (!is_user_logged_in()) {
            wp_safe_redirect(add_query_arg('arttree_error', 'login_failed', home_url('/registration-portal/#login')));
            exit;
        }
        if (!isset($_POST['arttree_profile_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_profile_nonce'])), 'arttree_update_applicant_profile')) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'profile', 'arttree_error' => 'nonce'], home_url('/registration-portal/')));
            exit;
        }
        $user_id = get_current_user_id();
        $full_name = sanitize_text_field(wp_unslash($_POST['full_name'] ?? ''));
        $email = sanitize_email(wp_unslash($_POST['email'] ?? ''));
        $phone = $this->normalize_login_phone(sanitize_text_field(wp_unslash($_POST['phone'] ?? '')));
        $city = sanitize_text_field(wp_unslash($_POST['city'] ?? ''));
        $qualification = sanitize_text_field(wp_unslash($_POST['qualification'] ?? ''));
        $national_id = sanitize_text_field(wp_unslash($_POST['national_id'] ?? ''));
        $experience = sanitize_text_field(wp_unslash($_POST['experience'] ?? ''));
        $summary = sanitize_textarea_field(wp_unslash($_POST['summary'] ?? ''));
        $linkedin = esc_url_raw(wp_unslash($_POST['linkedin'] ?? ''));

        if (!$full_name || !$email || !$phone || !$city || !$qualification) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'profile', 'arttree_error' => 'missing'], home_url('/registration-portal/')));
            exit;
        }
        $existing_email_user = email_exists($email);
        if ($existing_email_user && absint($existing_email_user) !== absint($user_id)) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'profile', 'arttree_error' => 'email_exists'], home_url('/registration-portal/')));
            exit;
        }
        if ($this->phone_exists($phone, $user_id)) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'profile', 'arttree_error' => 'phone_exists'], home_url('/registration-portal/')));
            exit;
        }

        wp_update_user([
            'ID' => $user_id,
            'display_name' => $full_name,
            'first_name' => $full_name,
            'user_email' => $email,
        ]);
        update_user_meta($user_id, 'arttree_applicant_full_name', $full_name);
        update_user_meta($user_id, 'arttree_applicant_phone', $phone);
        update_user_meta($user_id, 'arttree_applicant_city', $city);
        update_user_meta($user_id, 'arttree_applicant_qualification', $qualification);
        update_user_meta($user_id, 'arttree_applicant_national_id', $national_id);
        update_user_meta($user_id, 'arttree_applicant_experience', $experience);
        update_user_meta($user_id, 'arttree_applicant_summary', $summary);
        update_user_meta($user_id, 'arttree_applicant_linkedin', $linkedin);

        if (!empty($_FILES['applicant_cv']['name'])) {
            require_once ABSPATH . 'wp-admin/includes/file.php';
            $allowed = ['pdf' => 'application/pdf', 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
            $file = $_FILES['applicant_cv'];
            $max_size = 5 * 1024 * 1024;
            $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
            $file_size = isset($file['size']) ? absint($file['size']) : 0;
            $checked = !empty($file['tmp_name']) ? wp_check_filetype_and_ext($file['tmp_name'], $file['name'], $allowed) : ['ext' => '', 'type' => ''];
            if ($file_size > 0 && $file_size <= $max_size && isset($allowed[$ext]) && !empty($checked['ext']) && !empty($checked['type'])) {
                $upload = wp_handle_upload($file, ['test_form' => false, 'mimes' => $allowed]);
                if (!isset($upload['error']) && !empty($upload['url'])) {
                    update_user_meta($user_id, 'arttree_applicant_cv_url', esc_url_raw($upload['url']));
                    update_user_meta($user_id, 'arttree_applicant_cv_file', sanitize_text_field($upload['file'] ?? ''));
                }
            }
        }

        $this->notify_profile_updated($user_id);

        $apply_job = absint($_POST['apply_job'] ?? 0);
        if ($apply_job && $this->applicant_profile_complete($user_id) && !$this->is_job_closed($apply_job)) {
            $result = $this->create_user_request($user_id, 'job', $apply_job);
            wp_safe_redirect($this->quick_apply_redirect($apply_job, $result === 'created' ? 'created' : 'exists'));
            exit;
        }
        wp_safe_redirect(add_query_arg(['portal_section' => 'profile', 'arttree_notice' => 'profile_saved'], home_url('/registration-portal/')));
        exit;
    }

    public function handle_quick_apply_job() {
        if (!is_user_logged_in()) {
            wp_safe_redirect(add_query_arg('arttree_error', 'login_failed', home_url('/registration-portal/#login')));
            exit;
        }
        $job_id = absint($_POST['job_id'] ?? 0);
        if (!$job_id || !isset($_POST['arttree_quick_apply_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_quick_apply_nonce'])), 'arttree_quick_apply_job_' . $job_id)) {
            wp_safe_redirect(add_query_arg('arttree_error', 'nonce', wp_get_referer() ?: home_url('/careers/')));
            exit;
        }
        $user_id = get_current_user_id();
        if ($this->is_job_closed($job_id)) {
            wp_safe_redirect(get_permalink($job_id));
            exit;
        }
        if (!$this->applicant_profile_complete($user_id)) {
            wp_safe_redirect(add_query_arg(['portal_section' => 'profile', 'apply_job' => $job_id], home_url('/registration-portal/')));
            exit;
        }
        $result = $this->create_user_request($user_id, 'job', $job_id);
        wp_safe_redirect($this->quick_apply_redirect($job_id, $result === 'created' ? 'created' : 'exists'));
        exit;
    }

    public function handle_job_application() {
        if (!isset($_POST['arttree_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_nonce'])), 'arttree_apply_job')) {
            wp_die('رابط غير صالح.');
        }
        $job_id = absint($_POST['job_id'] ?? 0);
        $full_name = sanitize_text_field(wp_unslash($_POST['full_name'] ?? ''));
        $email = sanitize_email(wp_unslash($_POST['email'] ?? ''));
        if (!$job_id || !$full_name || !$email) {
            wp_die('يرجى تعبئة البيانات المطلوبة.');
        }
        $candidate_id = wp_insert_post([
            'post_type' => 'art_candidate',
            'post_status' => 'publish',
            'post_title' => $full_name . ' - ' . get_the_title($job_id),
        ]);
        if ($candidate_id) {
            update_post_meta($candidate_id, '_art_candidate_full_name', $full_name);
            update_post_meta($candidate_id, '_art_candidate_email', $email);
            update_post_meta($candidate_id, '_art_candidate_phone', sanitize_text_field(wp_unslash($_POST['phone'] ?? '')));
            update_post_meta($candidate_id, '_art_candidate_id', sanitize_text_field(wp_unslash($_POST['national_id'] ?? '')));
            update_post_meta($candidate_id, '_art_candidate_city', sanitize_text_field(wp_unslash($_POST['city'] ?? '')));
            update_post_meta($candidate_id, '_art_candidate_qualification', sanitize_text_field(wp_unslash($_POST['qualification'] ?? '')));
            update_post_meta($candidate_id, '_art_candidate_job_title', get_the_title($job_id));
            update_post_meta($candidate_id, '_art_candidate_status', 'received');
            update_post_meta($candidate_id, '_art_candidate_notes', sanitize_textarea_field(wp_unslash($_POST['summary'] ?? '')));
            $settings = $this->get_settings();
            wp_mail($settings['hr_email'], 'طلب توظيف جديد - ' . get_the_title($job_id), 'تم استقبال طلب جديد من: ' . $full_name . "\nالبريد: " . $email);
            wp_mail($email, 'تم استلام طلبك الوظيفي', 'مرحباً ' . $full_name . "\nتم استلام طلبك الوظيفي وسيتم مراجعته من الموارد البشرية.");
        }
        wp_safe_redirect(add_query_arg('arttree_apply', 'success', wp_get_referer() ?: home_url('/')));
        exit;
    }


    public function training_programs_shortcode($atts = []) {
        if (!$this->system_enabled('training')) { return $this->disabled_system_message('برامج التدريب'); }
        return $this->trainings_shortcode(['type' => 'training']);
    }

    public function events_workshops_shortcode($atts = []) {
        if (!$this->system_enabled('workshops')) { return $this->disabled_system_message('الورش واللقاءات'); }
        return $this->trainings_shortcode(['type' => 'workshop']);
    }

    private function rt_icon($name) {
        $icons = [
            'date' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 2a1 1 0 0 1 1 1v1h8V3a1 1 0 1 1 2 0v1h1.5A2.5 2.5 0 0 1 22 6.5v12A2.5 2.5 0 0 1 19.5 21h-15A2.5 2.5 0 0 1 2 18.5v-12A2.5 2.5 0 0 1 4.5 4H6V3a1 1 0 0 1 1-1Zm12.5 8h-15v8.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V10ZM5 6a.5.5 0 0 0-.5.5V8h15V6.5A.5.5 0 0 0 19 6H5Z"/></svg>',
            'time' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm0 3a1 1 0 0 1 1 1v3.4l2.4 1.4a1 1 0 1 1-1 1.7l-2.9-1.7A1 1 0 0 1 11 12V8a1 1 0 0 1 1-1Z"/></svg>',
            'location' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2a7 7 0 0 1 7 7c0 5.25-6.2 11.77-6.47 12.05a.75.75 0 0 1-1.06 0C11.2 20.77 5 14.25 5 9a7 7 0 0 1 7-7Zm0 2a5 5 0 0 0-5 5c0 3.35 3.45 7.8 5 9.62C13.55 16.8 17 12.35 17 9a5 5 0 0 0-5-5Zm0 2.75A2.25 2.25 0 1 1 12 11.25 2.25 2.25 0 0 1 12 6.75Z"/></svg>',
            'map' => '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.5 4 9.5 2 3.8 4.28A2 2 0 0 0 2.5 6.14v13.5a1 1 0 0 0 1.37.93L9.5 18.5l5 2 5.7-2.28a2 2 0 0 0 1.3-1.86V2.86a1 1 0 0 0-1.37-.93L14.5 4Zm-1 14.1-3-1.2V4.9l3 1.2v12Zm2 .05V6l4-1.6v11.96l-4 1.6ZM4.5 6.14l4-1.6V16.5l-4 1.6V6.14Z"/></svg>',
        ];
        return $icons[$name] ?? '';
    }

    public function trainings_shortcode($atts = []) {
        $atts = shortcode_atts(['type' => 'all'], (array) $atts, 'arttree_trainings');
        $type = in_array($atts['type'], ['training', 'workshop'], true) ? $atts['type'] : 'all';
        $query_args = [
            'post_type' => 'art_training',
            'posts_per_page' => -1,
            'post_status' => 'publish',
            'orderby' => 'meta_value',
            'meta_key' => '_art_training_date',
            'order' => 'ASC',
        ];
        if ($type !== 'all') {
            $query_args['meta_query'] = [[
                'key' => '_art_training_type',
                'value' => $type,
                'compare' => '=',
            ]];
        }
        $items = new WP_Query($query_args);
        $is_workshop = $type === 'workshop';
        $eyebrow = $is_workshop ? 'اللقاءات والورش' : ($type === 'training' ? 'التدريب' : 'التدريب واللقاءات والورش');
        $title = $is_workshop ? 'لقاءات وورش قانونية عملية' : ($type === 'training' ? 'برامج تدريبية قانونية' : 'برامج تدريبية ولقاءات وورش عملية');
        $desc = $is_workshop ? 'سجل في اللقاءات والورش القانونية واطلع على الفعاليات المتاحة والمنتهية مع إمكانية التحقق من الشهادات.' : ($type === 'training' ? 'سجل في البرامج التدريبية القانونية واطلع على الدورات المتاحة والمنتهية مع إمكانية التحقق من الشهادات.' : 'سجل في البرامج التدريبية واللقاءات والورش القانونية واطلع على البرامج المتاحة والمنتهية مع إمكانية التحقق من الشهادات.');
        $list_id = $is_workshop ? 'arttree-workshops-list' : 'arttree-training-list';
        ob_start();
        echo '<section class="arttree-rt arttree-training-page" dir="rtl">';
        if (is_user_logged_in()) {
            echo '<div class="arttree-rt-hero"><span class="arttree-eyebrow">' . esc_html($eyebrow) . '</span><h2>' . esc_html($title) . '</h2><p>' . esc_html($desc) . '</p><div class="arttree-rt-actions"><a class="arttree-rt-primary" href="#' . esc_attr($list_id) . '">استعراض المتاح</a><a class="arttree-rt-secondary" href="' . esc_url(add_query_arg('portal_section', 'workshops', home_url('/registration-portal/'))) . '">لوحة المتقدم</a></div></div>';
        } else {
            echo '<div class="arttree-rt-hero"><span class="arttree-eyebrow">' . esc_html($eyebrow) . '</span><h2>' . esc_html($title) . '</h2><p>' . esc_html($desc) . '</p><div class="arttree-rt-actions"><a class="arttree-rt-primary" href="#' . esc_attr($list_id) . '">تسجيل جديد</a><a class="arttree-rt-secondary" href="' . esc_url($this->login_url()) . '">الدخول</a></div></div>';
        }
        echo '<div id="' . esc_attr($list_id) . '" class="arttree-rt-grid">';
        if ($items->have_posts()) {
            while ($items->have_posts()) {
                $items->the_post();
                $id = get_the_ID();
                if ($this->field($id, '_art_training_status', 'open') === 'hidden') { continue; }
                $closed = $this->is_training_closed($id);
                echo '<article class="arttree-rt-card ' . ($closed ? 'is-closed' : 'is-open') . '">';
                echo '<div class="arttree-card-top"><span class="arttree-status ' . ($closed ? 'closed' : 'open') . '">' . ($closed ? ($is_workshop ? 'انتهت الورشة' : 'انتهى البرنامج') : 'التسجيل متاح') . '</span></div>';
                echo '<h3>' . esc_html(get_the_title()) . '</h3>';
                $card_date = $this->field($id, '_art_training_date');
                $card_time = $this->field($id, '_art_training_time');
                $card_location = $this->field($id, '_art_training_venue') ?: $this->field($id, '_art_training_location');
                $card_map_url = $this->field($id, '_art_training_map_url');
                echo '<div class="arttree-rt-meta arttree-card-meta-icons">';
                echo '<span>' . $this->rt_icon('date') . '<b>التاريخ</b><em>' . esc_html($card_date ?: 'يحدد لاحقاً') . '</em></span>';
                echo '<span>' . $this->rt_icon('time') . '<b>الوقت</b><em>' . esc_html($card_time ?: 'يحدد لاحقاً') . '</em></span>';
                echo '<span>' . $this->rt_icon('location') . '<b>الموقع</b><em>' . esc_html($card_location ?: 'يحدد لاحقاً') . '</em></span>';
                echo '</div>';
                if ($card_map_url) {
                    echo '<a class="arttree-map-card-btn" href="' . esc_url($card_map_url) . '">' . $this->rt_icon('map') . '<span>فتح اللوكيشن على قوقل ماب</span></a>';
                }
                echo '<p>' . esc_html(wp_trim_words(get_the_excerpt() ?: wp_strip_all_tags(get_the_content()), 32)) . '</p>';
                if ($this->user_is_registered_for_training($id)) {
                    $has_attended = $this->user_training_registration_attended($id);
                    echo '<button class="arttree-rt-disabled arttree-registered-btn ' . ($has_attended ? 'is-attended' : 'is-registered') . '" type="button" disabled>' . ($has_attended ? 'تم حضورك' : 'تم تسجيلك') . '</button>';
                    echo '<a class="arttree-rt-secondary arttree-details-btn" href="' . esc_url(get_permalink($id)) . '">' . ($is_workshop ? 'تفاصيل الورشة' : 'تفاصيل التدريب') . '</a>';
                } elseif ($closed) {
                    echo '<button class="arttree-rt-disabled" type="button" disabled>انتهى التسجيل</button>';
                    echo '<a class="arttree-rt-secondary arttree-details-btn" href="' . esc_url(get_permalink($id)) . '">' . ($is_workshop ? 'مشاهدة التفاصيل' : 'مشاهدة التفاصيل') . '</a>';
                } else {
                    echo '<a class="arttree-rt-primary" href="' . esc_url(get_permalink($id)) . '">' . ($is_workshop ? 'التسجيل في الورشة' : 'التسجيل في التدريب') . '</a>';
                }
                echo '</article>';
            }
            wp_reset_postdata();
        } else {
            echo '<p class="arttree-rt-empty">' . ($is_workshop ? 'لا توجد لقاءات أو ورش حالياً.' : 'لا توجد برامج تدريبية حالياً.') . '</p>';
        }
        echo '</div>';
        echo '<div class="arttree-rt-faq"><h3>' . ($is_workshop ? 'أسئلة اللقاءات والورش' : 'أسئلة التدريب') . '</h3><details><summary>هل يتم إصدار شهادة؟</summary><p>يمكن إصدار شهادة حضور أو مشاركة من لوحة الإدارة وإتاحة التحقق منها برمز خاص.</p></details><details><summary>هل تظهر البرامج المنتهية؟</summary><p>نعم، تظهر بحالة منتهية حتى تكون الصفحة واضحة للزوار.</p></details><details><summary>هل التسجيل مؤكد مباشرة؟</summary><p>يتم استقبال التسجيل وإرسال إشعار، ويمكن للإدارة اعتماد الحضور وإصدار الشهادة لاحقاً.</p></details></div>';
        echo '</section>';
        return ob_get_clean();
    }

    public function handle_training_registration() {
        if (!isset($_POST['arttree_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['arttree_nonce'])), 'arttree_register_training')) {
            wp_die('رابط غير صالح.');
        }
        $training_id = absint($_POST['training_id'] ?? 0);
        $full_name = sanitize_text_field(wp_unslash($_POST['full_name'] ?? ''));
        $email = sanitize_email(wp_unslash($_POST['email'] ?? ''));
        if (!$training_id || !$full_name || !$email) {
            wp_die('يرجى تعبئة البيانات المطلوبة.');
        }
        $registrations = get_post_meta($training_id, '_art_training_registrations', true);
        $registrations = is_array($registrations) ? $registrations : [];
        $registrations[] = [
            'name' => $full_name,
            'email' => $email,
            'phone' => sanitize_text_field(wp_unslash($_POST['phone'] ?? '')),
            'date' => current_time('mysql'),
        ];
        update_post_meta($training_id, '_art_training_registrations', $registrations);
        $settings = $this->get_settings();
        wp_mail($settings['training_email'], 'تسجيل جديد - ' . get_the_title($training_id), 'تم تسجيل: ' . $full_name . "\nالبريد: " . $email);
        wp_mail($email, 'تم استلام تسجيلك', 'مرحباً ' . $full_name . "\nتم استلام تسجيلك في: " . get_the_title($training_id));
        wp_safe_redirect(add_query_arg('arttree_training', 'success', wp_get_referer() ?: home_url('/')));
        exit;
    }


    private function user_can_checkin() {
        if (!is_user_logged_in()) {
            return false;
        }
        return current_user_can('edit_posts') || current_user_can('manage_options') || current_user_can('arttree_manage_attendance');
    }

    private function normalize_ticket_code($code) {
        $code = trim((string) $code);
        if (filter_var($code, FILTER_VALIDATE_URL)) {
            $parts = wp_parse_url($code);
            if (!empty($parts['query'])) {
                parse_str($parts['query'], $query);
                if (!empty($query['arttree_checkin'])) {
                    $code = (string) $query['arttree_checkin'];
                }
            }
        }
        $code = rawurldecode($code);
        return sanitize_text_field($code);
    }

    private function process_workshop_checkin($raw_code, $expected_item_id = 0) {
        $ticket_code = $this->normalize_ticket_code($raw_code);
        $expected_item_id = absint($expected_item_id);
        if (!$ticket_code) {
            return ['status' => 'error', 'message' => 'لم يتم إدخال رمز الباركود.'];
        }
        if ($expected_item_id) {
            $post = get_post($expected_item_id);
            if (!$post || $post->post_type !== 'art_training') {
                return ['status' => 'error', 'message' => 'يرجى اختيار ورشة أو لقاء صحيح قبل قراءة الباركود.'];
            }
            $items = [$expected_item_id];
        } else {
            return ['status' => 'error', 'message' => 'يرجى اختيار الورشة أو اللقاء من لوحة التحكم قبل قراءة الباركود.'];
        }
        foreach ($items as $item_id) {
            $registrations = get_post_meta($item_id, '_art_training_registrations', true);
            $registrations = is_array($registrations) ? $registrations : [];
            foreach ($registrations as $index => $registration) {
                if (($registration['ticket_code'] ?? '') !== $ticket_code) {
                    continue;
                }
                if (($registration['attendance_status'] ?? '') === 'attended') {
                    return [
                        'status' => 'already',
                        'message' => 'تم تسجيل حضور هذا المشارك مسبقاً.',
                        'title' => get_the_title($item_id),
                        'name' => $registration['name'] ?? '',
                        'email' => $registration['email'] ?? '',
                        'phone' => $registration['phone'] ?? '',
                        'ticket' => $ticket_code,
                        'time' => $registration['attendance_time'] ?? '',
                    ];
                }
                $now = current_time('mysql');
                $registrations[$index]['attendance_status'] = 'attended';
                $registrations[$index]['attendance_time'] = $now;
                $registrations[$index]['checked_in_by'] = get_current_user_id();
                update_post_meta($item_id, '_art_training_registrations', $registrations);

                $user_id = absint($registration['user_id'] ?? 0);
                if ($user_id) {
                    $user_items = get_user_meta($user_id, 'arttree_training_registrations', true);
                    $user_items = is_array($user_items) ? $user_items : [];
                    foreach ($user_items as $user_index => $user_item) {
                        if (($user_item['ticket_code'] ?? '') === $ticket_code) {
                            $user_items[$user_index]['status'] = 'تم تسجيل الحضور';
                            $user_items[$user_index]['attendance_status'] = 'attended';
                            $user_items[$user_index]['attendance_time'] = $now;
                        }
                    }
                    update_user_meta($user_id, 'arttree_training_registrations', $user_items);
                }

                return [
                    'status' => 'success',
                    'message' => 'تم تسجيل حضور المشارك بنجاح.',
                    'title' => get_the_title($item_id),
                    'name' => $registration['name'] ?? '',
                    'email' => $registration['email'] ?? '',
                    'phone' => $registration['phone'] ?? '',
                    'ticket' => $ticket_code,
                    'time' => $now,
                ];
            }
        }
        return ['status' => 'error', 'message' => 'هذا الباركود لا يخص الورشة أو اللقاء المحدد أو لا يوجد تسجيل مطابق له.'];
    }


    private function render_workshop_registrations_table() {
        $items = get_posts([
            'post_type' => 'art_training',
            'post_status' => 'any',
            'numberposts' => -1,
            'orderby' => 'date',
            'order' => 'DESC',
            'fields' => 'ids',
            'meta_query' => [[
                'key' => '_art_training_type',
                'value' => 'workshop',
                'compare' => '=',
            ]],
        ]);
        $rows = [];
        foreach ($items as $item_id) {
            $registrations = get_post_meta($item_id, '_art_training_registrations', true);
            $registrations = is_array($registrations) ? $registrations : [];
            foreach ($registrations as $registration) {
                $ticket = $registration['ticket_code'] ?? '';
                $attendance_status = $registration['attendance_status'] ?? '';
                $status_label = $attendance_status === 'attended' ? 'تم الحضور' : 'مسجل ولم يحضر';
                $status_class = $attendance_status === 'attended' ? 'attended' : 'pending';
                $rows[] = [
                    'workshop' => get_the_title($item_id),
                    'name' => $registration['name'] ?? '',
                    'email' => $registration['email'] ?? '',
                    'phone' => $registration['phone'] ?? '',
                    'ticket' => $ticket,
                    'date' => $registration['date'] ?? '',
                    'attendance_time' => $registration['attendance_time'] ?? '',
                    'status_label' => $status_label,
                    'status_class' => $status_class,
                ];
            }
        }
        if (!$rows) {
            return '<div class="arttree-checkin-table-wrap"><div class="arttree-checkin-table-head"><h3>المسجلون في اللقاءات والورش</h3><p>لا توجد تسجيلات حتى الآن.</p></div></div>';
        }
        $html = '<div class="arttree-checkin-table-wrap"><div class="arttree-checkin-table-head"><div><span>سجل الحضور</span><h3>المسجلون في اللقاءات والورش</h3></div><strong>' . count($rows) . ' مسجل</strong></div>';
        $html .= '<div class="arttree-checkin-table-scroll"><table class="arttree-checkin-table"><thead><tr><th>المشارك</th><th>البريد</th><th>الجوال</th><th>اللقاء أو الورشة</th><th>رمز الدخول</th><th>الحالة</th><th>وقت الحضور</th><th>التقييم</th></tr></thead><tbody>';
        foreach ($rows as $row) {
            $html .= '<tr class="is-' . esc_attr($row['status_class']) . '">';
            $html .= '<td>' . esc_html($row['name'] ?: 'غير محدد') . '</td>';
            $html .= '<td>' . esc_html($row['email'] ?: '-') . '</td>';
            $html .= '<td>' . esc_html($row['phone'] ?: '-') . '</td>';
            $html .= '<td>' . esc_html($row['workshop'] ?: '-') . '</td>';
            $html .= '<td><code>' . esc_html($row['ticket'] ?: '-') . '</code></td>';
            $html .= '<td><span class="arttree-checkin-status-pill ' . esc_attr($row['status_class']) . '">' . esc_html($row['status_label']) . '</span></td>';
            $html .= '<td>' . esc_html($row['attendance_time'] ?: '-') . '</td>';
            $html .= '</tr>';
        }
        $html .= '</tbody></table></div></div>';
        return $html;
    }

    public function workshop_checkin_shortcode() {
        if (!$this->system_enabled('checkin')) { return $this->disabled_system_message('قارئ الباركود'); }
        $dashboard_url = add_query_arg('staff_section', 'attendance', home_url('/staff-dashboard/'));
        if (is_user_logged_in() && $this->user_can_checkin()) {
            wp_safe_redirect($dashboard_url);
            exit;
        }
        ob_start();
        echo '<section class="arttree-rt arttree-checkin-page arttree-flat-system-page" dir="rtl">';
        echo '<div class="arttree-checkin-card"><h3>قارئ الباركود داخل لوحة التحكم</h3><p>تم نقل قارئ الباركود إلى لوحة التحكم حتى يتم اختيار الورشة أو اللقاء أولا ثم قراءة الباركود الخاص بها فقط.</p><a class="arttree-rt-primary" href="' . esc_url(wp_login_url($dashboard_url)) . '">دخول لوحة التحكم</a></div>';
        echo '</section>';
        return ob_get_clean();
    }


    private function get_certificate_by_code($code) {
        $code = sanitize_text_field((string) $code);
        if (!$code) {
            return 0;
        }
        $certs = get_posts([
            'post_type' => 'art_certificate',
            'post_status' => 'any',
            'meta_key' => '_art_certificate_code',
            'meta_value' => $code,
            'numberposts' => 1,
            'fields' => 'ids',
        ]);
        return $certs ? absint($certs[0]) : 0;
    }

    private function get_training_by_certificate($certificate_id) {
        $ticket_code = $this->field($certificate_id, '_art_certificate_ticket_code');
        $training_title = $this->field($certificate_id, '_art_certificate_training');
        $items = get_posts([
            'post_type' => 'art_training',
            'post_status' => ['publish', 'draft', 'pending'],
            'numberposts' => -1,
        ]);
        foreach ($items as $item) {
            $registrations = get_post_meta($item->ID, '_art_training_registrations', true);
            $registrations = is_array($registrations) ? $registrations : [];
            if ($ticket_code) {
                foreach ($registrations as $registration) {
                    if (($registration['ticket_code'] ?? '') === $ticket_code) {
                        return $item;
                    }
                }
            }
            if ($training_title && get_the_title($item) === $training_title) {
                return $item;
            }
        }
        return null;
    }

    private function format_certificate_event_date($date) {
        $date = trim((string) $date);
        if (!$date) {
            return 'غير محدد';
        }
        return str_replace('-', '/', $date) . 'م';
    }

    private function format_certificate_duration($duration) {
        $duration = trim(wp_strip_all_tags((string) $duration));
        if (!$duration) {
            return 'حسب المدة المعتمدة';
        }
        if (is_numeric($duration)) {
            return $duration . ' ساعات';
        }
        return $duration;
    }

    private function certificate_styles() {
        return '.arttree-certificate-document{margin:0;display:flex;justify-content:center;align-items:center;width:100%;page-break-inside:avoid;break-inside:avoid}.arttree-certificate-frame{width:min(1120px,100%);aspect-ratio:297/210;background:radial-gradient(circle at 8% 18%,rgba(80,61,122,.15),transparent 28%),radial-gradient(circle at 88% 86%,rgba(80,61,122,.12),transparent 30%),linear-gradient(135deg,#fff 0%,#fbf8ff 52%,#f1ebfa 100%);border:0!important;border-radius:0!important;box-shadow:none!important;position:relative;overflow:hidden;direction:rtl;box-sizing:border-box;padding:58px 172px 122px}.arttree-certificate-frame:before{content:"";position:absolute;left:-130px;top:-130px;width:360px;height:360px;border-radius:50%;background:rgba(80,61,122,.08);pointer-events:none}.arttree-certificate-frame:after{content:"";position:absolute;right:-120px;bottom:-150px;width:390px;height:390px;border-radius:50%;background:rgba(80,61,122,.07);pointer-events:none}.arttree-certificate-brand{position:absolute;top:34px;right:42px;width:92px;height:92px;display:flex;align-items:center;justify-content:center;z-index:3}.arttree-certificate-brand img{max-width:100%;max-height:100%;object-fit:contain}.arttree-certificate-body{position:relative;z-index:2;text-align:center;max-width:650px;margin:0 auto;padding:0}.arttree-certificate-ar-title{margin:0;color:#503d7a;font-size:44px;line-height:1.05;font-weight:950}.arttree-certificate-en-title{margin:8px 0 0;color:#7a6b91;font-size:18px;font-weight:900;letter-spacing:.14em}.arttree-certificate-company{margin:32px 0 6px;color:#221637;font-size:22px;font-weight:850;line-height:1.65}.arttree-certificate-line{margin:6px 0;color:#4d3a74;font-size:20px;line-height:1.65;font-weight:650}.arttree-certificate-line strong{color:#251a3d;font-weight:950}.arttree-certificate-subject{margin-top:10px}.arttree-certificate-training-name{display:inline-block;margin:8px auto 4px;padding:7px 18px;border-radius:999px;background:rgba(255,255,255,.74);color:#503d7a;font-weight:950;font-size:20px;line-height:1.5;box-shadow:0 10px 30px rgba(80,61,122,.07);max-width:100%}.arttree-certificate-wish{margin:20px 0 0;color:#6d607d;font-size:19px;font-weight:850}.arttree-certificate-signature{position:absolute;z-index:3;left:54px;bottom:42px;max-width:255px;text-align:left;display:grid;gap:5px;justify-items:start}.arttree-certificate-signature strong{font-size:22px;line-height:1.35;color:#251a3d;font-weight:950}.arttree-certificate-signature span{font-size:14px;color:#7a6b91;font-weight:850}.arttree-certificate-side-meta{position:absolute;z-index:3;right:46px;bottom:36px;width:170px;text-align:right;background:rgba(255,255,255,.40);border:0!important;border-radius:18px;padding:12px 12px 10px;box-shadow:none!important;backdrop-filter:blur(5px)}.arttree-certificate-side-meta-item{display:grid;gap:2px;margin-bottom:8px}.arttree-certificate-side-meta strong{font-size:10px;color:#7a6b91;font-weight:850}.arttree-certificate-side-meta span,.arttree-certificate-side-meta code{font-size:11px;line-height:1.35;color:#251a3d;font-weight:950;word-break:break-word}.arttree-certificate-side-meta code{font-family:inherit;background:rgba(80,61,122,.07);border-radius:9px;padding:4px 6px}.arttree-certificate-qr{display:flex;align-items:center;gap:7px;margin:7px 0 6px}.arttree-certificate-qr img{width:44px;height:44px;border-radius:8px;background:#fff;padding:3px;border:0}.arttree-certificate-qr-badge{display:inline-flex;align-items:center;justify-content:center;min-width:36px;border-radius:999px;background:#503d7a;color:#fff;padding:5px 8px;font-weight:900;font-size:10px;letter-spacing:.08em}.arttree-certificate-verify-note{margin:0;color:#6d607d;font-size:10px;line-height:1.45}.arttree-certificate-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px;justify-content:center}.arttree-certificate-actions a,.arttree-certificate-actions button{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:#503d7a;color:#fff;text-decoration:none;padding:10px 18px;border:0;font-size:15px;cursor:pointer}.arttree-certificate-actions a + a,.arttree-certificate-actions button + a{background:#f1edf8;color:#503d7a}@media print{@page{size:A4 landscape;margin:0}html,body{width:297mm;height:210mm;margin:0!important;padding:0!important;overflow:hidden!important;background:#fff!important}.arttree-certificate-print-page{width:297mm!important;height:210mm!important;margin:0!important;padding:0!important;overflow:hidden!important;page-break-after:avoid!important;page-break-inside:avoid!important}.arttree-certificate-document{width:297mm!important;height:210mm!important;margin:0!important;overflow:hidden!important}.arttree-certificate-frame{width:297mm!important;height:210mm!important;min-height:0!important;aspect-ratio:auto!important;margin:0!important;padding:18mm 45mm 32mm!important;overflow:hidden!important;page-break-inside:avoid!important;break-inside:avoid!important}.arttree-certificate-brand{top:12mm!important;right:14mm!important;width:24mm!important;height:24mm!important}.arttree-certificate-body{max-width:172mm!important}.arttree-certificate-ar-title{font-size:33pt!important}.arttree-certificate-en-title{font-size:13pt!important}.arttree-certificate-company{margin-top:20mm!important;font-size:16pt!important}.arttree-certificate-line{font-size:14pt!important;line-height:1.48!important}.arttree-certificate-training-name{font-size:14pt!important}.arttree-certificate-wish{font-size:13pt!important;margin-top:7mm!important}.arttree-certificate-signature{left:18mm!important;bottom:14mm!important;max-width:60mm!important}.arttree-certificate-signature strong{font-size:14pt!important}.arttree-certificate-signature span{font-size:10pt!important}.arttree-certificate-side-meta{right:15mm!important;bottom:12mm!important;width:42mm!important;padding:3.8mm!important}.arttree-certificate-qr img{width:12mm!important;height:12mm!important}.no-print,.arttree-pdf-export-hint{display:none!important}}@media(max-width:900px){.arttree-certificate-frame{aspect-ratio:auto;min-height:auto;padding:34px 20px 38px;display:block}.arttree-certificate-brand{position:relative;top:auto;right:auto;width:88px;height:88px;margin:0 auto 16px}.arttree-certificate-ar-title{font-size:36px}.arttree-certificate-en-title{font-size:15px;letter-spacing:.08em}.arttree-certificate-company,.arttree-certificate-line{font-size:17px;line-height:1.8}.arttree-certificate-training-name{font-size:17px}.arttree-certificate-wish{font-size:17px}.arttree-certificate-signature,.arttree-certificate-side-meta{position:relative;left:auto;right:auto;bottom:auto;width:auto;max-width:none;text-align:center;justify-items:center;margin:24px auto 0}.arttree-certificate-qr{justify-content:center}}


/* v1.0.125 - Applicant portal dashboard redesign */
.arttree-applicant-portal .arttree-portal-hero{margin-bottom:28px}
.arttree-applicant-portal .arttree-applicant-dashboard-shell{--applicant-purple:#503d7a;--applicant-soft:#f8f4ef;--applicant-ink:#251a32;--applicant-muted:#7b7186;max-width:1240px;margin:0 auto 48px;min-height:720px;display:grid;grid-template-columns:300px minmax(0,1fr);gap:0;background:linear-gradient(135deg,#fbf8f3 0%,#fff 52%,#f5efff 100%);border:1px solid rgba(80,61,122,.10);border-radius:34px;box-shadow:0 22px 60px rgba(80,61,122,.10);overflow:hidden;position:relative}
.arttree-applicant-portal .arttree-applicant-dashboard-shell .arttree-dashboard-sidebar{position:relative;inset:auto;width:auto;height:auto;background:rgba(255,255,255,.84);border-left:1px solid rgba(80,61,122,.10);box-shadow:none;padding:18px 16px;display:flex;flex-direction:column;gap:8px;z-index:2;order:1}
.arttree-applicant-portal .arttree-applicant-dashboard-shell .arttree-dashboard-content{order:2;min-width:0;padding:34px;background:transparent}
.arttree-applicant-sidebar-brand{display:flex;align-items:center;justify-content:center;padding:12px 8px 18px;margin-bottom:4px}
.arttree-applicant-sidebar-brand img{width:150px;max-width:82%;height:auto;object-fit:contain}
.arttree-applicant-portal .arttree-dashboard-drawer-head{display:flex;align-items:center;justify-content:space-between;gap:10px;background:#fff;border:1px solid rgba(80,61,122,.10);border-radius:22px;padding:14px;margin-bottom:8px}
.arttree-applicant-portal .arttree-dashboard-drawer-head span{display:block;color:#8a7f98;font-size:12px;font-weight:800}
.arttree-applicant-portal .arttree-dashboard-drawer-head strong{display:block;color:#251a32;font-size:14px;line-height:1.35}
.arttree-applicant-portal .arttree-dashboard-drawer-head button{display:none;background:#f4eefc;border:0;border-radius:12px;color:#503d7a;width:34px;height:34px;font-size:22px;line-height:1;cursor:pointer}
.arttree-applicant-portal .arttree-dashboard-sidebar a{display:flex;align-items:center;gap:12px;padding:13px 14px;border-radius:18px;color:#342744;text-decoration:none;font-weight:850;transition:.2s ease;background:transparent}
.arttree-applicant-portal .arttree-dashboard-sidebar a:hover,.arttree-applicant-portal .arttree-dashboard-sidebar a.is-active{background:#503d7a;color:#fff;box-shadow:0 12px 24px rgba(80,61,122,.18)}
.arttree-applicant-portal .arttree-dashboard-sidebar .arttree-dash-icon{width:22px;height:22px;display:inline-flex;flex:0 0 22px;background:currentColor;opacity:.95;mask-size:contain;mask-position:center;mask-repeat:no-repeat;-webkit-mask-size:contain;-webkit-mask-position:center;-webkit-mask-repeat:no-repeat}
.arttree-applicant-dashboard-title{margin:0 0 22px;padding:24px;border-radius:28px;background:rgba(255,255,255,.74);border:1px solid rgba(80,61,122,.08)}
.arttree-applicant-dashboard-title span{display:inline-flex;margin-bottom:10px;border-radius:999px;background:#f1edf8;color:#503d7a;padding:7px 13px;font-size:12px;font-weight:900}
.arttree-applicant-dashboard-title h2{margin:0;color:#251a32;font-size:clamp(28px,4vw,46px);line-height:1.2;font-weight:950}
.arttree-applicant-dashboard-title p{margin:10px 0 0;color:#7b7186;font-size:17px;line-height:1.8;max-width:680px}
.arttree-applicant-portal .arttree-dashboard-panel{background:rgba(255,255,255,.86);border:1px solid rgba(80,61,122,.10);border-radius:28px;box-shadow:0 16px 34px rgba(80,61,122,.07);padding:24px}
.arttree-applicant-portal .arttree-applicant-overview-panel{background:linear-gradient(135deg,#503d7a,#7450a8);color:#fff;border:0;overflow:hidden;position:relative}
.arttree-applicant-portal .arttree-applicant-overview-panel:after{content:"";position:absolute;left:-60px;bottom:-80px;width:260px;height:260px;border-radius:50%;background:rgba(255,255,255,.10);pointer-events:none}
.arttree-applicant-portal .arttree-applicant-overview-panel span,.arttree-applicant-portal .arttree-applicant-overview-panel h3,.arttree-applicant-portal .arttree-applicant-overview-panel p{position:relative;z-index:1;color:#fff}
.arttree-applicant-portal .arttree-dashboard-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:22px;position:relative;z-index:1}
.arttree-applicant-portal .arttree-dashboard-stats b{display:grid;gap:5px;background:rgba(255,255,255,.13);border:1px solid rgba(255,255,255,.18);border-radius:22px;padding:16px;color:#fff;font-size:30px;line-height:1}
.arttree-applicant-portal .arttree-dashboard-stats small{font-size:13px;font-weight:800;color:rgba(255,255,255,.78)}
.arttree-applicant-portal .arttree-dashboard-toggle{position:absolute;top:18px;left:18px;z-index:4;border:0;background:#fff;color:#503d7a;border-radius:999px;padding:10px 14px;font-weight:900;box-shadow:0 10px 25px rgba(80,61,122,.12);cursor:pointer}
.arttree-applicant-portal .arttree-dashboard-mobile-bar{display:none}
.arttree-applicant-portal .arttree-dashboard-dim{display:none}
.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-sidebar-hidden{grid-template-columns:96px minmax(0,1fr)}
.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-sidebar-hidden .arttree-dashboard-sidebar{padding-inline:12px}
.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-sidebar-hidden .arttree-applicant-sidebar-brand img{width:54px}
.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-sidebar-hidden .arttree-dashboard-drawer-head{display:none}
.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-sidebar-hidden .arttree-dashboard-sidebar a{justify-content:center;padding:14px 10px}
.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-sidebar-hidden .arttree-dashboard-sidebar a span:not(.arttree-dash-icon){display:none}
@media(max-width:1024px){.arttree-applicant-portal .arttree-applicant-dashboard-shell{display:block;min-height:auto;border-radius:26px;overflow:visible;background:transparent;border:0;box-shadow:none}.arttree-applicant-portal .arttree-applicant-dashboard-shell .arttree-dashboard-content{padding:18px 0}.arttree-applicant-portal .arttree-dashboard-mobile-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 16px;background:#fff;border:1px solid rgba(80,61,122,.10);border-radius:22px;padding:12px 14px;box-shadow:0 12px 30px rgba(80,61,122,.08)}.arttree-applicant-portal .arttree-dashboard-mobile-user{display:flex;align-items:center;gap:10px;font-weight:900;color:#251a32}.arttree-applicant-portal .arttree-dashboard-mobile-user img{width:42px;height:42px;border-radius:50%;object-fit:cover}.arttree-applicant-portal .arttree-dashboard-mobile-toggle{width:44px;height:44px;border:0;border-radius:15px;background:#503d7a;color:#fff;cursor:pointer}.arttree-applicant-portal .arttree-dashboard-toggle{display:none}.arttree-applicant-portal .arttree-applicant-dashboard-shell .arttree-dashboard-sidebar{position:fixed;top:0;right:0;width:min(86vw,340px);height:100vh;overflow:auto;transform:translateX(110%);transition:.25s ease;border-radius:0;box-shadow:-24px 0 50px rgba(20,13,34,.22);z-index:9999}.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-mobile-menu-open .arttree-dashboard-sidebar{transform:translateX(0)}.arttree-applicant-portal .arttree-applicant-dashboard-shell .arttree-dashboard-drawer-head button{display:inline-flex;align-items:center;justify-content:center}.arttree-applicant-portal .arttree-dashboard-dim{display:none;position:fixed;inset:0;background:rgba(20,13,34,.45);z-index:9998;border:0}.arttree-applicant-portal .arttree-applicant-dashboard-shell.is-mobile-menu-open .arttree-dashboard-dim{display:block}.arttree-applicant-portal .arttree-applicant-dashboard-title{padding:20px}.arttree-applicant-portal .arttree-dashboard-stats{grid-template-columns:1fr}}

/* v1.0.128 - HTML email template controls */
.arttree-email-template-admin-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-top:18px}
.arttree-email-template-admin-card{background:#fff;border:1px solid rgba(80,61,122,.12);border-radius:22px;padding:18px;display:grid;gap:12px;box-shadow:0 12px 28px rgba(80,61,122,.06)}
.arttree-email-template-admin-card h5{margin:0 0 4px;color:#503d7a;font-size:17px}
.arttree-email-template-admin-card label{display:grid;gap:7px;color:#4d3a74;font-weight:800;font-size:13px}
.arttree-email-template-admin-card input,.arttree-email-template-admin-card textarea{width:100%;border:1px solid rgba(80,61,122,.18);border-radius:14px;padding:11px 12px;background:#fbf8ff;color:#251a3d;font-family:inherit}
@media(max-width:900px){.arttree-email-template-admin-grid{grid-template-columns:1fr}}

/* v1.0.129 - homepage sections and registered users controls */
.arttree-home-section-editor-list{display:grid;gap:16px}
.arttree-home-section-editor-card{background:#fff;border:1px solid rgba(80,61,122,.12);border-radius:22px;padding:18px;box-shadow:0 10px 24px rgba(80,61,122,.06)}
.arttree-home-section-editor-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}
.arttree-home-section-editor-head small{color:#7b7186;font-weight:800}
.arttree-control-switch.compact{margin:0;min-height:auto;padding:0;border:0;background:transparent;box-shadow:none}
.arttree-staff-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.arttree-staff-form-grid label{display:grid;gap:7px;font-weight:800;color:#332447}
.arttree-staff-form-grid label.wide{grid-column:1/-1}
.arttree-staff-form-grid input,.arttree-staff-form-grid textarea,.arttree-staff-search-form input,.arttree-registered-control-form input{width:100%;border:1px solid rgba(80,61,122,.16);border-radius:14px;padding:11px 13px;background:#fff;color:#251a3d}
.dewan-dynamic-section-content{max-width:860px;margin:0 auto 24px;color:#5f536e;font-size:17px;line-height:1.9;text-align:center}
.dewan-dynamic-section-content p{margin:0 0 10px}
.dewan-custom-home-section{background:linear-gradient(180deg,#fff,#fbf8ff)}
.arttree-staff-search-form{display:flex;align-items:end;gap:12px;flex-wrap:wrap;margin:0 0 18px;background:#faf8fd;border:1px solid rgba(80,61,122,.1);border-radius:18px;padding:14px}
.arttree-staff-search-form label{display:grid;gap:6px;min-width:260px;font-weight:800;color:#332447}
.arttree-registered-users-table small{display:block;margin-top:5px;color:#7b7186}
.arttree-registered-control-form{display:flex!important;flex-wrap:wrap;gap:8px;align-items:center}
.arttree-registered-control-form input{max-width:150px;padding:8px 10px!important;border-radius:11px!important}
.arttree-registered-control-form select{max-width:120px;padding:8px 10px!important;border-radius:11px!important}
.arttree-registered-control-form a{display:inline-flex;align-items:center;background:#f2edf8;color:#503d7a;text-decoration:none;border-radius:999px;padding:8px 12px;font-size:12px;font-weight:900}
.arttree-delete-user-form{margin-top:8px}.arttree-delete-user-form button{border:0;border-radius:999px;background:#fff1f1;color:#b42318;padding:8px 12px;font-weight:900;cursor:pointer}
@media(max-width:760px){.arttree-staff-form-grid{grid-template-columns:1fr}.arttree-home-section-editor-head{align-items:flex-start;flex-direction:column}.arttree-registered-control-form input,.arttree-registered-control-form select{max-width:100%}.arttree-staff-search-form label{min-width:100%}}


/* v1.0.130 - candidate status update notification controls */
.arttree-candidate-status-form{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:10px}
.arttree-candidate-status-form select{min-width:180px;border:1px solid rgba(80,61,122,.18);border-radius:14px;padding:9px 12px;background:#fff;color:#251a3d;font-weight:800}
.arttree-candidate-status-form button{border:0;border-radius:999px;background:#503d7a;color:#fff;padding:9px 14px;font-weight:900;cursor:pointer}
@media(max-width:720px){.arttree-candidate-status-form select,.arttree-candidate-status-form button{width:100%}}

/* v1.0.132 - service requests admin form */
.dewan-service-admin-form{display:grid;gap:8px;min-width:260px}.dewan-service-admin-form label{display:grid;gap:4px;font-weight:800;color:#503d7a}.dewan-service-admin-form input,.dewan-service-admin-form select,.dewan-service-admin-form textarea{border:1px solid rgba(80,61,122,.14);border-radius:12px;padding:8px;background:#fff}.dewan-service-admin-form button{border:0;border-radius:999px;background:#503d7a;color:#fff;padding:9px 14px;font-weight:900}
