/* Yourcloudweb Portal 1.2.1 RC12: user-selectable Wide / Boxed layout + right context drawer.
 * Loads AFTER the existing portal files. No WHMCS cart or sidebar actions are replaced.
 */
:root {
  --ycw-box-max: 1560px;
  --ycw-box-gutter: 24px;
  --ycw-box-left: max(24px, calc((100vw - var(--ycw-box-max)) / 2));
}
body.ycw-portal .ycw-modern-header .ycw-layout-toggle,
body.ycw-portal .ycw-modern-header .ycw-context-toggle {
  flex: 0 0 auto;
  width: auto !important;
  min-width: 38px !important;
  max-width: 125px;
  gap: 8px;
  padding: 0 11px !important;
  white-space: nowrap;
}
body.ycw-portal .ycw-modern-header .ycw-layout-toggle {
  border-color: #ffdbc8 !important;
  background: #fff8f3 !important;
  color: #dd510a !important;
}
body.ycw-portal .ycw-modern-header .ycw-layout-toggle[aria-pressed="true"] {
  background: #fff0e5 !important;
  border-color: #ffbc97 !important;
  color: #dd4c00 !important;
}
body.ycw-portal .ycw-modern-header .ycw-layout-toggle-label,
body.ycw-portal .ycw-modern-header .ycw-context-toggle-label {
  font: 600 11px/1.3 "Poppins", "Open Sans", Arial, sans-serif;
}
body.ycw-portal .ycw-modern-header .ycw-context-toggle[aria-expanded="true"] {
  border-color: #dfe6f2 !important;
  background: #f1f5fb !important;
}
body.ycw-portal .ycw-context-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
body.ycw-portal .ycw-context-head .ycw-context-label {
  margin-bottom: 4px !important;
}
body.ycw-portal .ycw-context-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  color: #65738a;
  background: #fff;
  border: 1px solid #e4eaf2;
  border-radius: 8px;
  cursor: pointer;
}
body.ycw-portal .ycw-context-close:hover,
body.ycw-portal .ycw-context-close:focus-visible {
  background: #fff4ed;
  color: #ff5900;
  border-color: #ffc9a9;
}
/* Wide is the RC11 default. Boxed is a centered complete portal, not a boxed content-only area. */
@media (min-width: 1051px) {
  html[data-ycw-layout="boxed"] body.ycw-portal:not(.template-login):not(.template-clientregister) {
    background: #edf2f8 !important;
  }
  html[data-ycw-layout="boxed"] body.ycw-portal:not(.template-login):not(.template-clientregister) > .wdes-wrapper {
    position: relative;
    width: min(calc(100% - 48px), var(--ycw-box-max)) !important;
    max-width: var(--ycw-box-max) !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    overflow: visible !important;
    background: #f5f8fc !important;
    border: 1px solid #e4eaf2 !important;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 20px 65px rgba(31, 55, 96, .075);
  }
  html[data-ycw-layout="boxed"] body.ycw-portal:not(.template-login):not(.template-clientregister) > .wdes-wrapper > .wdes-sidebar {
    flex-basis: var(--ycw-sidebar) !important;
    width: var(--ycw-sidebar) !important;
    min-width: var(--ycw-sidebar) !important;
    border-radius: 17px 0 0 0;
  }
  /* The existing fixed navigation must move WITH the centered portal. */
  html[data-ycw-layout="boxed"] body.ycw-portal .wdes-sidebar > #main-menu {
    left: var(--ycw-box-left) !important;
    right: auto !important;
    border-radius: 17px 0 0 0;
  }
  html[data-ycw-layout="boxed"] body.ycw-portal > #footer {
    width: min(calc(100% - 48px), var(--ycw-box-max)) !important;
    max-width: var(--ycw-box-max) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}
/* A narrower laptop has no room to benefit from gutters; preserve the selected
 * preference but render an almost-wide layout to keep the product grid usable. */
@media (min-width: 1051px) and (max-width: 1299px) {
  html[data-ycw-layout="boxed"] body.ycw-portal:not(.template-login):not(.template-clientregister) > .wdes-wrapper {
    width: 100% !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  html[data-ycw-layout="boxed"] body.ycw-portal .wdes-sidebar > #main-menu {
    left: 0 !important;
    border-radius: 0 !important;
  }
  html[data-ycw-layout="boxed"] body.ycw-portal > #footer {
    width: 100% !important;
  }
}
/* Desktop right-rail visibility, independent of the portal width. */
@media (min-width: 1231px) {
  html[data-ycw-context="hidden"] body.ycw-portal .wdes-content > .ycw-content-layout > aside.whm-sidebar {
    display: none !important;
  }
}
/* Smaller layouts show the context menu as a drawer instead of stealing grid width.
 * It is rendered only when the matching WHMCS sidebar actually exists. */
body.ycw-portal > .ycw-context-overlay {
  position: fixed;
  inset: 0;
  z-index: 1075;
  display: none;
  background: rgba(16, 30, 52, .36);
  cursor: pointer;
}
@media (max-width: 1230px) {
  body.ycw-portal.ycw-context-open .wdes-content > .ycw-content-layout > aside.whm-sidebar {
    position: fixed !important;
    z-index: 1080 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    display: block !important;
    width: min(328px, calc(100vw - 20px)) !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 24px 16px 32px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    background: #f6f8fc !important;
    border-left: 1px solid #e2e8f2 !important;
    box-shadow: -18px 0 48px rgba(13, 27, 47, .14) !important;
    border-radius: 17px 0 0 17px;
  }
  body.ycw-portal.ycw-context-open > .ycw-context-overlay {
    display: block;
  }
  body.ycw-portal.ycw-context-open {
    overflow: hidden !important;
  }
  body.ycw-portal .ycw-context-head .ycw-context-close {
    width: 34px;
    height: 34px;
  }
}
@media (max-width: 1480px) {
  body.ycw-portal .ycw-modern-header .ycw-context-toggle-label,
  body.ycw-portal .ycw-modern-header .ycw-layout-toggle-label {
    display: none;
  }
  body.ycw-portal .ycw-modern-header .ycw-layout-toggle,
  body.ycw-portal .ycw-modern-header .ycw-context-toggle {
    width: 38px !important;
    padding: 0 !important;
  }
}
@media (max-width: 750px) {
  body.ycw-portal .ycw-modern-header .ycw-layout-toggle,
  body.ycw-portal .ycw-modern-header .ycw-context-toggle {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
  }
  body.ycw-portal .ycw-modern-header .ycw-header-search {
    flex-shrink: 1;
    min-width: 70px;
  }
}
@media (max-width: 470px) {
  body.ycw-portal section#header.ycw-modern-header > .ycw-topbar-shell {
    gap: 6px !important;
  }
  body.ycw-portal .ycw-modern-header .ycw-topbar-right {
    gap: 4px !important;
  }
  body.ycw-portal .ycw-modern-header .ycw-header-search {
    width: clamp(72px, 23vw, 130px) !important;
    margin-right: 0 !important;
  }
  body.ycw-portal .ycw-modern-header .ycw-layout-toggle,
  body.ycw-portal .ycw-modern-header .ycw-context-toggle {
    width: 32px !important;
    min-width: 32px !important;
    height: 36px !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.ycw-portal .ycw-layout-toggle,
  body.ycw-portal .ycw-context-toggle { transition: none !important; }
}

/* The client dashboard deliberately uses a full-width canvas. Its context rail
 * opens as a drawer even on desktop, rather than compressing the dashboard. */
body.ycw-portal.template-clientareahome.ycw-context-open .wdes-content > .ycw-content-layout > aside.whm-sidebar {
  position: fixed !important;
  z-index: 1080 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  display: block !important;
  width: min(328px, calc(100vw - 20px)) !important;
  min-width: 0 !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 24px 16px 32px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  background: #f6f8fc !important;
  border-left: 1px solid #e2e8f2 !important;
  box-shadow: -18px 0 48px rgba(13, 27, 47, .14) !important;
  border-radius: 17px 0 0 17px;
}
body.ycw-portal.template-clientareahome.ycw-context-open > .ycw-context-overlay {
  display: block !important;
}
body.ycw-portal.template-clientareahome.ycw-context-open {
  overflow: hidden !important;
}
