/* =========================================================
   WHMCS-style shell — layout chrome layered on billing.css
   New classes are prefixed whm-* to avoid colliding with
   existing bill-* component styles.
   ========================================================= */

/* ---------- Admin shell ---------- */
.whm-admin {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-body);
  overflow-x: clip;
}

/* Top navigation bar (WHMCS-style) */
.whm-topnav {
  background: var(--bg-header);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.whm-topnav-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem;
  height: var(--header-height, 56px);
  max-width: 1600px;
  margin: 0 auto;
}
.whm-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 700;
  font-size: 1.02rem;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.whm-brand svg { width: 28px; height: 28px; display: block; }
.whm-brand:hover { color: #fff; }

.whm-nav-toggle {
  display: none;
  background: none;
  border: 0;
  color: #fff;
  cursor: pointer;
  padding: .45rem;
  border-radius: 6px;
  line-height: 0;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.whm-nav-toggle svg { width: 22px; height: 22px; flex-shrink: 0; }
.whm-nav-toggle:hover { background: rgba(255, 255, 255, .1); }

.whm-topnav-right { display: flex; align-items: center; gap: .3rem; margin-left: auto; }
.whm-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: rgba(255, 255, 255, .85);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  line-height: 0;
}
.whm-icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.whm-icon-btn svg { width: 18px; height: 18px; }
.whm-client-divider { width: 1px; height: 22px; background: rgba(255, 255, 255, .25); margin: 0 .3rem; }

/* Admin body: contextual sidebar + main */
.whm-body {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  align-items: flex-start;
}

.whm-sidebar {
  display: none;
  width: 250px;
  flex-shrink: 0;
  padding: 1.1rem .9rem;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--header-height, 56px);
  bottom: 0;
  left: max(0px, calc(50% - 800px));
  z-index: auto;
  overflow-y: auto;
}
@media (min-width: 1024px) { .whm-sidebar { display: block; } }

.whm-side-head {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
  padding: 0 .5rem .5rem;
}

.whm-side-nav { display: flex; flex-direction: column; gap: .15rem; }

.whm-side-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .5rem;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  position: relative;
  transition: background var(--transition-fast, .12s), color var(--transition-fast, .12s);
}
.whm-side-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.whm-side-link:hover { background: var(--bg-card-alt); color: var(--primary); }
.whm-side-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.whm-side-link.active::before {
  content: "";
  position: absolute;
  left: -0.9rem;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--primary);
}

.whm-side-group.active > .whm-side-group-label { color: var(--primary); }
.whm-side-group-label {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .5rem .4rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: .25rem;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
}
.whm-side-group-label:hover { color: var(--primary); }
.whm-side-group-label svg:not(.whm-side-caret) { width: 17px; height: 17px; flex-shrink: 0; }
.whm-side-caret { width: 14px !important; height: 14px !important; margin-left: auto; transition: transform var(--transition-fast, .12s); }
.whm-side-group.open > .whm-side-group-label .whm-side-caret { transform: rotate(180deg); }

.whm-side-sub {
  display: none;
  flex-direction: column;
  gap: .1rem;
  margin: 0 0 .25rem;
  padding-left: 1.05rem;
  margin-left: .95rem;
  border-left: 1px solid var(--border);
}
.whm-side-group.open > .whm-side-sub { display: flex; }
.whm-side-sub .whm-side-link { padding: .4rem .6rem; font-size: .82rem; font-weight: 500; }
.whm-side-sub .whm-side-link::before { display: none; }
.whm-side-sub .whm-side-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.whm-main { flex: 1; min-width: 0; margin-left: 250px; padding: 1.4rem 1.5rem; }
.whm-main > * { min-width: 0; }

.whm-admin .bill-footer,
.whm-client .bill-footer { margin-left: max(250px, calc(50% - 800px + 250px)); }

.whm-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.whm-crumbs a { color: var(--text-secondary); text-decoration: none; }
.whm-crumbs a:hover { color: var(--primary); }
.whm-crumbs .sep { margin: 0 .45rem; color: var(--text-muted); }
.whm-crumbs .current { color: var(--text-primary); font-weight: 600; }

.whm-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.whm-page-title { font-size: 1.28rem; font-weight: 700; letter-spacing: -.01em; color: var(--text-primary); margin: 0; }

/* Dashboard widgets */
.whm-widgets,
.whm-widget-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 1.4rem;
}
@media (min-width: 640px) {
  .whm-widgets,
  .whm-widget-row { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1240px) {
  .whm-widgets,
  .whm-widget-row { grid-template-columns: repeat(4, 1fr); }
}
.whm-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow-sm, none);
  transition: box-shadow var(--transition, .2s), transform var(--transition, .2s), border-color var(--transition, .2s);
}
.whm-widget:hover {
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, .1));
  transform: translateY(-2px);
}
.whm-widget-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: .55rem;
}
.whm-widget-label svg {
  width: 26px;
  height: 26px;
  padding: 5px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  flex-shrink: 0;
}
.whm-widget-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  margin-top: .45rem;
}
.whm-widget-foot { font-size: .75rem; color: var(--text-muted); margin-top: .4rem; }

/* ---------- Client shell ---------- */
.whm-client {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-body);
  overflow-x: clip;
}

.whm-side-user {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .55rem .75rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.whm-side-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}
.whm-side-user-name { font-size: .85rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.whm-side-user-role { font-size: .72rem; color: var(--text-tertiary); }

.whm-side-head--sep {
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.whm-client-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: .9rem 1.25rem;
}
.whm-client-footer-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .78rem; color: var(--text-secondary); }
.whm-client-footer a { color: var(--primary); text-decoration: none; }

@keyframes whmDropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Login (WHMCS-style card) ---------- */
.whm-login-page { background: var(--bg-body); }
.whm-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.whm-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl, 18px);
  box-shadow: var(--shadow-xl, 0 16px 48px rgba(0, 0, 0, .16));
  padding: 2.2rem 2.4rem;
  animation: whmDropIn .3s var(--ease-out, ease-out);
}
.whm-login-head { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-bottom: .6rem; }
.whm-login-head svg {
  width: 40px;
  height: 40px;
  padding: 9px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-sizing: border-box;
}
.whm-login-title { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); text-align: center; margin: 0; }
.whm-login-sub { text-align: center; color: var(--text-secondary); font-size: .84rem; margin: .25rem 0 1.5rem; }
.whm-login-error {
  background: rgba(229, 62, 62, .1);
  color: var(--red);
  border: 1px solid rgba(229, 62, 62, .3);
  border-radius: 6px;
  padding: .6rem .8rem;
  font-size: .83rem;
  margin-bottom: 1rem;
}
.whm-login-success {
  background: rgba(34, 197, 94, .1);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, .3);
  border-radius: 6px;
  padding: .6rem .8rem;
  font-size: .83rem;
  margin-bottom: 1rem;
}
.whm-login-field { margin-bottom: 1rem; }
.whm-login-field label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-primary); margin-bottom: .35rem; }
.whm-login-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .8rem;
  font-size: .9rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color var(--transition, .2s), box-shadow var(--transition, .2s);
}
.whm-login-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .8rem;
  font-size: .9rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color var(--transition, .2s), box-shadow var(--transition, .2s);
}
.whm-login-field input:focus, .whm-login-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.whm-login-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .92rem;
  padding: .7rem;
  cursor: pointer;
  transition: background var(--transition, .2s);
}
.whm-login-btn:hover { background: var(--primary-hover); }
.whm-login-foot { margin-top: 1.25rem; text-align: center; font-size: .8rem; color: var(--text-secondary); }
.whm-login-foot a { color: var(--primary); text-decoration: none; }
.whm-login-foot a:hover { text-decoration: underline; }

/* ── Checkout (order.php) ─────────────────────────────── */
.whm-checkout-product {
  display: flex;
  gap: .9rem;
  align-items: center;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: .9rem 1rem;
  margin-bottom: 1.15rem;
}
.whm-checkout-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.whm-checkout-icon svg { width: 22px; height: 22px; }
.whm-checkout-name { font-size: .95rem; font-weight: 700; color: var(--text-primary); }
.whm-checkout-desc { font-size: .78rem; color: var(--text-secondary); margin-top: .15rem; line-height: 1.4; }
.whm-checkout-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 11px;
  padding: .75rem .95rem;
  margin: 1rem 0 1.1rem;
}
.whm-checkout-total span { font-size: .8rem; color: var(--text-secondary); }
.whm-checkout-total strong { font-size: 1.05rem; color: var(--text-primary); }
.whm-checkout-note {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: rgba(26, 115, 232, .08);
  border: 1px solid rgba(26, 115, 232, .28);
  color: var(--text-primary);
  border-radius: 10px;
  padding: .7rem .85rem;
  font-size: .8rem;
  margin-bottom: 1rem;
}
.whm-checkout-note svg { width: 17px; height: 17px; flex: 0 0 auto; }
.whm-checkout-actions { display: flex; flex-direction: column; gap: .6rem; }
.whm-checkout-actions .btn-row { display: flex; gap: .6rem; }
.whm-checkout-actions .btn-row .whm-login-btn { flex: 1; }
.whm-login-btn--ghost {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: none;
}
.whm-login-btn--ghost:hover { border-color: var(--primary); background: var(--bg-card); }
.whm-checkout-list { display: flex; flex-direction: column; gap: .5rem; }
.whm-checkout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem .9rem;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-light);
  border-radius: 11px;
  text-decoration: none;
  transition: border-color var(--transition, .2s);
}
.whm-checkout-item:hover { border-color: var(--primary); }
.whm-checkout-item .n { font-size: .88rem; font-weight: 600; color: var(--text-primary); }
.whm-checkout-item .p { font-size: .8rem; color: var(--text-secondary); }
.whm-login-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  display: inline-block;
  vertical-align: -2px;
  animation: whmSpin .7s linear infinite;
}
@keyframes whmSpin { to { transform: rotate(360deg); } }

/* ---------- Topnav auth buttons (guest shell) ---------- */
.whm-btn-link {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: .82rem;
  font-weight: 600;
  padding: .4rem .85rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition, .2s), border-color var(--transition, .2s), color var(--transition, .2s);
}
.whm-btn-link:hover { border-color: var(--primary); color: var(--primary); }
.whm-btn-link-solid {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.whm-btn-link-solid:hover { background: var(--primary-hover); color: #fff; }

/* ---------- Mobile ---------- */
.whm-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 250;
}

@media (max-width: 1023px) {
  .whm-nav-toggle { display: inline-flex; }
  .whm-sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-height: none;
    transform: translateX(-100%);
    transition: transform .25s var(--ease-out, ease-out);
    z-index: 300;
    padding-top: calc(var(--header-height, 56px) + .75rem);
  }
  .whm-sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0, 0, 0, .35);
  }
  .whm-sidebar.open + .whm-backdrop,
  .whm-backdrop.show { display: block; }
  .whm-main { padding: 1.1rem 1rem; margin-left: 0; }
  .whm-admin .bill-footer,
  .whm-client .bill-footer { margin-left: 0; }
  .whm-client-navbar { padding: .5rem 1rem; }
  .whm-login-card { padding: 1.8rem 1.6rem; }
}

@media (max-width: 640px) {
  .whm-brand { min-width: 0; overflow: hidden; }
  .whm-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .whm-hide-mobile { display: none !important; }
  .whm-topnav-right { gap: 0; }
}
