/* ==========================================================================
   APRIONEX CRM theme layer (release R1, 15 Nov 2026).
   One stylesheet for the application chrome:
     - admin pages: linked by admin/header.php and admin/menu.php (body.crm-ui)
     - customer portal: linked by users/portal_nav.php (body.crm-portal)
     - sign-in pages: login.php, register.php, resend_verification.php (body.aprx-auth)
   Palette: navy #072247, blue #083f85, green #2b7a0d, emblem green #275421.
   Works with Bootstrap 4.0/4.5.2 and 5.x: only class selectors and colours are
   overridden, never layout or the grid. Everything is scoped to one of the three
   body classes above, so a page that loads nothing of the shared layout is unaffected.
   ========================================================================== */
:root {
  --aprx-navy: #072247;
  --aprx-blue: #083f85;
  --aprx-blue-dark: #06326a;
  --aprx-green: #2b7a0d;
  --aprx-green-dark: #22620a;
  --aprx-emblem: #275421;
  --aprx-wash: #f3f6fa;
  --aprx-line: #dde4ee;
  --aprx-ink: #1d2b3d;
  --aprx-muted: #607089;
  --aprx-focus: rgba(8, 63, 133, .22);
}

/* ---------- Shared tokens: the existing crm_common.css layers read these ---------- */
body.crm-ui, body.crm-portal {
  --crm-green: #2b7a0d;
  --crm-blue: #083f85;
  --crm-ink: #1d2b3d;
  --crm-line: #dde4ee;
  --crm-wash: #f3f6fa;
  /* Bootstrap 5 reads these for links and focus rings */
  --bs-primary: #083f85;
  --bs-primary-rgb: 8, 63, 133;
  --bs-success: #2b7a0d;
  --bs-success-rgb: 43, 122, 13;
  --bs-link-color: #083f85;
  --bs-link-color-rgb: 8, 63, 133;
  --bs-link-hover-color: #072247;
  --bs-link-hover-color-rgb: 7, 34, 71;
}

/* ---------- Buttons (BS4 and BS5) ---------- */
body.crm-ui .btn-primary, body.crm-portal .btn-primary, body.aprx-auth .btn-primary {
  --bs-btn-bg: #083f85; --bs-btn-border-color: #083f85;
  --bs-btn-hover-bg: #072247; --bs-btn-hover-border-color: #072247;
  --bs-btn-active-bg: #06193a; --bs-btn-active-border-color: #06193a;
  --bs-btn-disabled-bg: #083f85; --bs-btn-disabled-border-color: #083f85;
  background-color: #083f85; border-color: #083f85; color: #fff;
}
body.crm-ui .btn-primary:hover, body.crm-ui .btn-primary:focus,
body.crm-portal .btn-primary:hover, body.crm-portal .btn-primary:focus,
body.aprx-auth .btn-primary:hover, body.aprx-auth .btn-primary:focus {
  background-color: #072247; border-color: #072247; color: #fff;
}
body.crm-ui .btn-success, body.crm-portal .btn-success, body.aprx-auth .btn-success {
  --bs-btn-bg: #2b7a0d; --bs-btn-border-color: #2b7a0d;
  --bs-btn-hover-bg: #22620a; --bs-btn-hover-border-color: #22620a;
  --bs-btn-active-bg: #1b4f08; --bs-btn-active-border-color: #1b4f08;
  --bs-btn-disabled-bg: #2b7a0d; --bs-btn-disabled-border-color: #2b7a0d;
  background-color: #2b7a0d; border-color: #2b7a0d; color: #fff;
}
body.crm-ui .btn-success:hover, body.crm-ui .btn-success:focus,
body.crm-portal .btn-success:hover, body.crm-portal .btn-success:focus,
body.aprx-auth .btn-success:hover, body.aprx-auth .btn-success:focus {
  background-color: #22620a; border-color: #22620a; color: #fff;
}
body.crm-ui .btn-outline-primary, body.crm-portal .btn-outline-primary, body.aprx-auth .btn-outline-primary {
  --bs-btn-color: #083f85; --bs-btn-border-color: #083f85; --bs-btn-hover-bg: #083f85; --bs-btn-hover-border-color: #083f85;
  --bs-btn-active-bg: #072247; --bs-btn-active-border-color: #072247;
  color: #083f85; border-color: #083f85;
}
body.crm-ui .btn-outline-primary:hover, body.crm-portal .btn-outline-primary:hover, body.aprx-auth .btn-outline-primary:hover {
  background-color: #083f85; border-color: #083f85; color: #fff;
}
body.crm-ui .btn-outline-success, body.crm-portal .btn-outline-success, body.aprx-auth .btn-outline-success {
  --bs-btn-color: #2b7a0d; --bs-btn-border-color: #2b7a0d; --bs-btn-hover-bg: #2b7a0d; --bs-btn-hover-border-color: #2b7a0d;
  color: #2b7a0d; border-color: #2b7a0d;
}
body.crm-ui .btn-outline-success:hover, body.crm-portal .btn-outline-success:hover, body.aprx-auth .btn-outline-success:hover {
  background-color: #2b7a0d; border-color: #2b7a0d; color: #fff;
}
body.crm-ui .btn:focus-visible, body.crm-portal .btn:focus-visible, body.aprx-auth .btn:focus-visible {
  outline: 2px solid #083f85; outline-offset: 2px;
}

/* ---------- Colour utilities ---------- */
body.crm-ui .bg-primary, body.crm-portal .bg-primary { background-color: #083f85 !important; }
body.crm-ui .bg-success, body.crm-portal .bg-success { background-color: #2b7a0d !important; }
body.crm-ui .bg-dark, body.crm-portal .bg-dark { background-color: #072247 !important; }
body.crm-ui .text-primary, body.crm-portal .text-primary { color: #083f85 !important; }
body.crm-ui .text-success, body.crm-portal .text-success { color: #2b7a0d !important; }
body.crm-ui .border-primary, body.crm-portal .border-primary { border-color: #083f85 !important; }
body.crm-ui .border-success, body.crm-portal .border-success { border-color: #2b7a0d !important; }
body.crm-ui .badge-primary, body.crm-portal .badge-primary { background-color: #083f85; color: #fff; }
body.crm-ui .badge-success, body.crm-portal .badge-success { background-color: #2b7a0d; color: #fff; }
body.crm-ui .table-dark, body.crm-ui .thead-dark th { --bs-table-bg: #072247; background-color: #072247; border-color: #0d3366; }

/* ---------- Forms ---------- */
body.crm-ui .form-control:focus, body.crm-ui .form-select:focus, body.crm-ui .custom-select:focus,
body.crm-portal .form-control:focus, body.crm-portal .form-select:focus, body.crm-portal .custom-select:focus,
body.aprx-auth .form-control:focus, body.aprx-auth .form-select:focus {
  border-color: #3d6fb0; box-shadow: 0 0 0 .2rem var(--aprx-focus); outline: 0;
}
body.crm-ui .form-check-input:checked, body.crm-portal .form-check-input:checked,
body.crm-ui .custom-control-input:checked ~ .custom-control-label::before {
  background-color: #083f85; border-color: #083f85;
}

/* ---------- Navigation components ---------- */
body.crm-ui .page-item.active .page-link, body.crm-portal .page-item.active .page-link {
  background-color: #083f85; border-color: #083f85; color: #fff;
}
body.crm-ui .page-link, body.crm-portal .page-link { color: #083f85; }
body.crm-ui .nav-pills .nav-link.active, body.crm-portal .nav-pills .nav-link.active { background-color: #083f85; color: #fff; }
body.crm-ui .nav-tabs .nav-link.active, body.crm-portal .nav-tabs .nav-link.active { color: #072247; border-top: 3px solid #2b7a0d; font-weight: 600; }
body.crm-ui .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.crm-ui .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover,
body.crm-portal .dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: #083f85 !important; border-color: #083f85 !important; color: #fff !important;
}
body.crm-ui .progress-bar, body.crm-portal .progress-bar { background-color: #083f85; }
body.crm-ui .progress-bar.bg-success, body.crm-portal .progress-bar.bg-success { background-color: #2b7a0d !important; }

/* ---------- Admin content ---------- */
body.crm-ui .main-content h1, body.crm-ui .main-content h2 { color: #072247; }
body.crm-ui .main-content a:not([class]) { color: #083f85; }
body.crm-ui .main-content a:not([class]):hover { color: #072247; }
body.crm-ui .main-content .card-header.bg-primary, body.crm-ui .main-content .card-header.bg-dark { color: #fff; }
body.crm-ui .modal-header.bg-primary, body.crm-ui .modal-header.bg-dark { color: #fff; }
body.crm-ui .crm-eyebrow, body.crm-portal .crm-eyebrow { color: #2b7a0d; }
body.crm-ui .crm-page-heading h1 { color: #072247; }
body.crm-ui .crm-common-shell .r10-chip.active { background: #072247; border-color: #072247; }

/* Admin footer (admin/footer.php) */
body.crm-ui .crm-app-footer, .crm-app-footer {
  background: #072247; color: #c9d5e6; border-top: 3px solid #2b7a0d;
}
.crm-app-footer a { color: #fff; }

/* ---------- Customer portal (users/portal_nav.php) ---------- */
body.crm-portal { background: var(--aprx-wash) !important; color: var(--aprx-ink); }
body.crm-portal .portal-topbar { background: #072247; border-top: 0; box-shadow: 0 2px 10px rgba(7, 34, 71, .25); }
body.crm-portal .portal-topbar-inner { background: #fff; max-width: none; padding: 8px max(14px, calc((100% - 1200px) / 2 + 14px)); border-bottom: 3px solid #2b7a0d; }
body.crm-portal .portal-brand { color: #072247; }
body.crm-portal .portal-brand:hover { color: #072247; text-decoration: none; }
body.crm-portal .portal-brand-logo { height: 38px; width: auto; max-width: 52vw; display: block; }
body.crm-portal .portal-brand-text { display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--aprx-line); padding-left: 10px; }
body.crm-portal .portal-brand strong { color: #072247; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
body.crm-portal .portal-brand small { color: var(--aprx-muted); max-width: 40vw; }
body.crm-portal .portal-logout { color: #072247; border-color: #c9d3e1; }
body.crm-portal .portal-logout:hover { background: #072247; color: #fff; border-color: #072247; }
body.crm-portal .portal-nav { padding: 8px 14px; max-width: 1200px; }
body.crm-portal .portal-nav a { color: #d6e1f0; }
body.crm-portal .portal-nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
body.crm-portal .portal-nav a.active { background: #2b7a0d; color: #fff; }
body.crm-portal h1, body.crm-portal h2, body.crm-portal h3 { color: #072247; }
body.crm-portal .portal-footer { text-align: center; color: var(--aprx-muted); font-size: .75rem; padding: 14px 10px 22px; }
body.crm-portal .portal-footer strong { color: #072247; }
@media (max-width: 575.98px) {
  body.crm-portal .portal-brand-text { display: none; }
  body.crm-portal .portal-brand-logo { height: 32px; }
}

/* ---------- Sign-in pages (login / register / resend verification) ---------- */
body.aprx-auth {
  min-height: 100vh; margin: 0; color: var(--aprx-ink);
  background: radial-gradient(1200px 600px at 10% -10%, #0d3a78 0%, rgba(13, 58, 120, 0) 60%),
              linear-gradient(150deg, #072247 0%, #06193a 55%, #0a2d1a 100%);
  font-family: 'Poppins', 'Segoe UI', Arial, sans-serif; line-height: 1.5;
}
body.aprx-auth a { color: #083f85; }
body.aprx-auth a:hover { color: #072247; }
.aprx-auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 16px; }
.aprx-auth-card {
  width: 100%; max-width: 980px; display: grid; grid-template-columns: 1fr 1fr; background: #fff;
  border-radius: 16px; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.aprx-auth-card.aprx-auth-narrow { max-width: 560px; grid-template-columns: 1fr; }
.aprx-auth-card.aprx-auth-wide { max-width: 1080px; grid-template-columns: 1fr; }
.aprx-auth-aside {
  position: relative; padding: 40px 36px; color: #e6edf7; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, #083f85 0%, #072247 70%);
}
.aprx-auth-aside::after {
  content: ""; position: absolute; right: -60px; bottom: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(43, 122, 13, .55) 0%, rgba(43, 122, 13, 0) 70%);
}
.aprx-auth-aside h2 { color: #fff; font-size: 1.55rem; font-weight: 700; margin: 22px 0 10px; line-height: 1.25; }
.aprx-auth-aside p { color: #c9d6ea; font-size: .92rem; margin: 0 0 18px; }
.aprx-auth-aside ul { list-style: none; padding: 0; margin: 0 0 18px; }
.aprx-auth-aside li { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: .9rem; color: #e6edf7; }
.aprx-auth-aside li i { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #9fdc7f; font-size: .8rem; }
.aprx-auth-plate { display: inline-block; background: #fff; border-radius: 10px; padding: 10px 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.aprx-auth-plate img { display: block; width: 100%; max-width: 280px; height: auto; }
.aprx-auth-aside small { position: relative; z-index: 1; color: #9fb0c8; font-size: .75rem; }
.aprx-auth-main { padding: 40px 38px; display: flex; flex-direction: column; justify-content: center; }
.aprx-auth-brand-top { display: none; margin-bottom: 18px; }
.aprx-auth-brand-top img { max-width: 230px; width: 100%; height: auto; }
.aprx-auth-main h1 { font-size: 1.5rem; font-weight: 700; color: #072247; margin: 0 0 4px; }
.aprx-auth-main .aprx-auth-sub { color: var(--aprx-muted); font-size: .92rem; margin: 0 0 22px; }
.aprx-auth-main label { font-weight: 600; font-size: .84rem; color: #33445b; margin-bottom: 5px; display: block; }
.aprx-auth-main .form-control { min-height: 46px; border-radius: 9px; border: 1px solid #cdd7e4; background: #f9fbfd; font-size: .95rem; }
.aprx-auth-main .form-control:focus { background: #fff; }
.aprx-auth-field { margin-bottom: 16px; position: relative; transition: transform .15s ease; }
.aprx-auth-field.password-toggle .form-control { padding-right: 46px; }
.aprx-auth-field .toggle-password { position: absolute; right: 12px; bottom: 12px; color: #6b7c93; cursor: pointer; line-height: 1; }
.aprx-auth-field .toggle-password:hover { color: #083f85; }
.aprx-auth-row { display: flex; justify-content: flex-end; margin: -6px 0 18px; font-size: .84rem; }
.aprx-auth-row a { color: var(--aprx-muted); }
.aprx-auth-submit {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; border: 0; border-radius: 10px;
  background: linear-gradient(135deg, #083f85 0%, #072247 100%); color: #fff; font-weight: 600; font-size: 1rem; cursor: pointer;
  box-shadow: 0 8px 18px rgba(8, 63, 133, .3); transition: transform .15s ease, box-shadow .15s ease;
}
.aprx-auth-submit:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(8, 63, 133, .38); color: #fff; }
.aprx-auth-submit.aprx-auth-green { background: linear-gradient(135deg, #2b7a0d 0%, #275421 100%); box-shadow: 0 8px 18px rgba(43, 122, 13, .3); }
.aprx-auth-submit:disabled, .aprx-auth-submit.btn-loading { opacity: .8; cursor: wait; }
.aprx-auth-submit .spinner { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: aprx-spin .8s linear infinite; display: inline-block; }
@keyframes aprx-spin { to { transform: rotate(360deg); } }
.aprx-auth-alt { margin: 20px 0 0; text-align: center; font-size: .9rem; color: var(--aprx-muted); }
.aprx-auth-alt a { font-weight: 600; }
.aprx-auth-links { margin-top: 22px; padding-top: 16px; border-top: 1px solid #e7ecf3; text-align: center; font-size: .8rem; color: var(--aprx-muted); }
.aprx-auth-links a { color: var(--aprx-muted); margin: 0 6px; }
.aprx-auth-links a:hover { color: #083f85; }
.aprx-auth-foot { margin-top: 18px; text-align: center; color: #9fb0c8; font-size: .76rem; }
.aprx-auth-foot strong { color: #dbe5f3; font-weight: 600; }
.aprx-auth .alert { border-radius: 9px; font-size: .9rem; }
/* Registration form inside the auth card */
.aprx-auth-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 30px; background: linear-gradient(135deg, #083f85 0%, #072247 100%); color: #fff; border-bottom: 4px solid #2b7a0d; }
.aprx-auth-head .aprx-auth-plate { padding: 7px 10px; }
.aprx-auth-head .aprx-auth-plate img { max-width: 210px; }
.aprx-auth-head h1 { color: #fff; font-size: 1.45rem; margin: 0 0 4px; font-weight: 700; }
.aprx-auth-head p { margin: 0; color: #c9d6ea; font-size: .9rem; }
.aprx-auth-body { padding: 28px 30px; }
.aprx-auth .section-title { font-size: 1rem; color: #072247; font-weight: 700; border-bottom: 1px solid var(--aprx-line); padding-bottom: 8px; margin: 24px 0 16px; }
.aprx-auth .section-title i { color: #2b7a0d; }
.aprx-auth .section-title:first-child { margin-top: 0; }
.aprx-auth .form-group label { font-weight: 600; font-size: .84rem; color: #33445b; }
.aprx-auth .required { color: #b42318; }
.aprx-auth .aprx-auth-body .form-control { border-radius: 8px; min-height: 43px; border: 1px solid #cdd7e4; }
.aprx-auth .account-choice { display: flex; gap: 12px; flex-wrap: wrap; }
.aprx-auth .account-choice label { border: 1px solid #cdd7e4; border-radius: 9px; padding: 12px 18px; cursor: pointer; flex: 1; min-width: 190px; font-weight: 600; }
.aprx-auth .account-choice label:has(input:checked) { border-color: #083f85; background: #eef4fc; color: #072247; }
.aprx-auth .privacy-note { font-size: .76rem; color: var(--aprx-muted); }
.aprx-auth .registration-links { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.aprx-auth .registration-links .btn { min-width: 210px; border-radius: 9px; }
.aprx-auth .btn-register { padding: 12px 24px; font-weight: 700; border-radius: 10px; }
@media (max-width: 860px) {
  .aprx-auth-card { grid-template-columns: 1fr; max-width: 520px; }
  .aprx-auth-aside { display: none; }
  .aprx-auth-brand-top { display: block; }
  .aprx-auth-main { padding: 30px 22px; }
}
@media (max-width: 576px) {
  .aprx-auth-shell { padding: 14px 10px; justify-content: flex-start; }
  .aprx-auth-head, .aprx-auth-body { padding: 20px 16px; }
  .aprx-auth-head h1 { font-size: 1.2rem; }
  .aprx-auth .registration-links .btn { width: 100%; }
  .aprx-auth-main .form-control { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .aprx-auth-submit, .aprx-auth-field { transition: none; }
  .aprx-auth-submit .spinner { animation: none; }
}
