/* ALDEEB V135.07 — Unified UI Core
   One visual contract for navigation, contrast, responsive layout, and modal controls.
   Scope intentionally avoids Smart Control internals, which keeps its own isolated surface. */
:root{
  --aldeeb-primary:#d71920;
  --aldeeb-primary-dark:#a90f15;
  --aldeeb-ink:#17212b;
  --aldeeb-muted:#5f6d7a;
  --aldeeb-border:#cbd5df;
  --aldeeb-surface:#ffffff;
  --aldeeb-surface-2:#f4f7fa;
  --aldeeb-focus:#7c3aed;
  --aldeeb-success:#127a4b;
  --aldeeb-danger:#b42318;
}

/* Consistent page geometry */
#project .page,
#adminPage,
#publicAboutPage{
  box-sizing:border-box;
  width:100%;
  min-width:0;
}
#project .page > :where(.page-head,.box,.card,.panel,.tool-card,.result,.stat,.ref-note),
#adminPage > :where(.box,.card,.panel){
  box-sizing:border-box;
}
#project :where(.page-head,h1,h2,h3,h4,h5,h6){
  overflow-wrap:anywhere;
}
#project :where(.box,.card,.panel,.tool-card,.stat,.result,.ref-note){
  max-width:100%;
}

/* Deterministic contrast for common light UI surfaces */
#adminPage,
#adminPage .v13506-feature-manager{
  color:var(--aldeeb-ink)!important;
  background:#fff!important;
}
#adminPage :where(h1,h2,h3,h4,h5,h6,strong,b,label,th){color:#17212b!important;}
#adminPage :where(p,small,.admin-muted,.muted,.subtle){color:#4b5b68!important;}
#adminPage :where(input,select,textarea){
  background:#fff!important;color:#17212b!important;border-color:#92a4b3!important;
}
#adminPage :where(input,select,textarea)::placeholder{color:#5d6b78!important;opacity:1!important;}
#adminPage :where(button.primary,.primary){background:var(--aldeeb-primary)!important;color:#fff!important;}
#adminPage :where(button.secondary,.secondary){background:#edf1f5!important;color:#17212b!important;border-color:#bac7d2!important;}
#adminPage :where(button.danger,.danger){background:#fff1f0!important;color:#9f1c14!important;border-color:#e5aaa5!important;}

/* Common form and table contrast */
#project :where(input,select,textarea){
  border-width:1px;
  border-style:solid;
  border-color:#9aaab8;
  color:#17212b;
  background:#fff;
  box-sizing:border-box;
}
#project :where(input,select,textarea)::placeholder{color:#5d6b78;opacity:1;}
#project :where(table) :where(th,td){
  border-color:#aebbc6;
}
#project :where(.ok,.success){
  color:#0f6840;
}
#project :where(.err,.error){
  color:#9f1c14;
}

/* One canonical return control for every navigable non-entry surface */
#v13410SystemReturn.v13507-system-return{
  position:fixed!important;
  left:16px!important;
  bottom:16px!important;
  z-index:2147483646!important;
  display:none!important;
  align-items:center!important;
  justify-content:center!important;
  gap:8px!important;
  min-width:168px!important;
  height:46px!important;
  padding:0 16px!important;
  border:1px solid rgba(255,255,255,.30)!important;
  border-radius:13px!important;
  background:#d71920!important;
  color:#fff!important;
  font:900 14px/1 Tahoma,Arial,sans-serif!important;
  box-sizing:border-box!important;
  cursor:pointer!important;
  box-shadow:0 12px 30px rgba(0,0,0,.28)!important;
  direction:rtl!important;
  text-align:center!important;
}
#v13410SystemReturn.v13507-system-return.is-visible{display:inline-flex!important;}
#v13410SystemReturn.v13507-system-return:focus-visible{
  outline:3px solid var(--aldeeb-focus)!important;
  outline-offset:3px!important;
}

/* Canonical close button geometry for popups/modals */
:where(
  #v13410ExamModal .v13410-exam-close,
  #v13462Modal .v13462-close,
  .aldeeb-auth-close,
  .aldeeb-admin-login-close,
  .certificate-viewer-close,
  .computer-lightbox .close,
  #v13425ToolPortal .v13427-tool-page-close,
  .v132-public-standalone .v132-public-info-head button
){
  display:grid!important;
  place-items:center!important;
  align-items:center!important;
  justify-content:center!important;
  width:44px!important;
  height:44px!important;
  min-width:44px!important;
  min-height:44px!important;
  padding:0!important;
  box-sizing:border-box!important;
  line-height:1!important;
  text-align:center!important;
  flex:0 0 44px!important;
}

/* Keep modal surfaces above page chrome */
:where(
  #v13410ExamModal,
  #v13462Modal,
  #aldeebAuthLayer,
  #aldeebAdminLoginLayer,
  #certificateViewer,
  #qrModal,
  #v13425ToolPortal,
  #v132PublicStandalone,
  #publicAboutPage
){isolation:isolate;}

/* Responsive rules applied consistently to desktop + phone */
@media(max-width:900px){
  #project .page,
  #adminPage,
  #publicAboutPage{padding-left:12px;padding-right:12px;}
  #project :where(.grid,.form-grid,.admin-form,.two-col,.three-col){
    grid-template-columns:1fr!important;
  }
  #project :where(.table-wrap,.admin-table-wrap){
    max-width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
  }
}
@media(max-width:640px){
  #project .page,
  #adminPage,
  #publicAboutPage{padding-left:8px;padding-right:8px;}
  #project :where(input,select,textarea),
  #adminPage :where(input,select,textarea){
    min-height:44px;
    font-size:16px;
  }
  #project :where(button),
  #adminPage :where(button){
    min-height:44px;
  }
  #v13410SystemReturn.v13507-system-return{
    left:max(10px,env(safe-area-inset-left))!important;
    bottom:max(10px,env(safe-area-inset-bottom))!important;
    min-width:150px!important;
    height:44px!important;
    font-size:13px!important;
  }
}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.01ms!important;
    animation-iteration-count:1!important;
    scroll-behavior:auto!important;
    transition-duration:.01ms!important;
  }
}
