/* ==========================================================================
   Application sidebar
   --------------------------------------------------------------------------
   Scoped to `.side-bar`, the aside in layouts/partials/sidebar.blade.php.
   Shares the counter's tokens so the whole product reads as one system.

   The menu is built by AdminlteCustomPresenter and driven by common.js:
   #side-bar, .drop_down, .chiled, .theme-sidebar-active, #sidebar-search and
   .small-view-side-active all keep their meaning here.

   Accent colour comes from --theme-700/800/900, which css.blade.php sets from
   the business theme colour.
   ========================================================================== */

.side-bar {
  /* Dark chrome, so the sidebar and the top bar read as one frame. */
  --rs-surface:    #0B1220;
  --rs-surface-2:  #131C2E;
  --rs-line:       rgba(255, 255, 255, .09);
  --rs-line-soft:  rgba(255, 255, 255, .06);
  --rs-text:       #F2F5FA;
  --rs-text-2:     #AEB9CC;
  --rs-text-3:     #7C899F;
  --rs-brand:      var(--theme-700, #004EEB);
  /* The theme colour is picked for white backgrounds, so on this ground the
     label and icon use a lightened mix of it, and the fill stays low. */
  --rs-accent:     color-mix(in srgb, var(--theme-700, #004EEB) 45%, #FFFFFF);
  --rs-accent-bg:  color-mix(in srgb, var(--theme-700, #004EEB) 30%, transparent);
  --rs-hover:      rgba(255, 255, 255, .06);
  --rs-radius:     10px;
  --rs-ease:       cubic-bezier(.4, 0, .2, 1);

  /* The parent flex row has no height of its own, so a percentage height
     collapsed to the length of the menu. The rail spans the viewport and
     stays put while the page scrolls in its own container. */
  position: sticky;
  top: 0;
  height: 100vh !important;
  align-self: flex-start;

  width: 268px !important;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(255, 255, 255, .06), transparent 60%),
    var(--rs-surface) !important;
  border-right: 1px solid var(--rs-line);
  color: var(--rs-text-2);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ==========================================================================
   1. Brand
   ========================================================================== */

.side-bar .rs-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  height: 76px;
  padding: 0 16px;
  border-bottom: 1px solid var(--rs-line);
  background: transparent;
  text-decoration: none !important;
  transition: background .2s var(--rs-ease);
}
.side-bar .rs-brand:hover { background: var(--rs-hover); }

.side-bar .rs-brand-mark {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--rs-accent), var(--rs-brand));
  box-shadow: 0 8px 20px -8px var(--rs-brand), inset 0 1px 0 rgba(255, 255, 255, .25);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: transform .25s var(--rs-ease), box-shadow .25s var(--rs-ease);
}
.side-bar .rs-brand:hover .rs-brand-mark {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 12px 26px -8px var(--rs-brand), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.side-bar .rs-brand-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.side-bar .rs-brand-name {
  display: block;
  color: var(--rs-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-bar .rs-brand-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--rs-text-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .04em;
  line-height: 1.2;
  text-transform: uppercase;
}
.side-bar .rs-brand-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: #12B76A;
  box-shadow: 0 0 0 0 rgba(18, 183, 106, .5);
  animation: rs-pulse 2.4s var(--rs-ease) infinite;
}
@keyframes rs-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(18, 183, 106, .45); }
  70%  { box-shadow: 0 0 0 6px rgba(18, 183, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0); }
}

/* ==========================================================================
   2. Search
   ========================================================================== */

.side-bar .rs-search-wrap { flex: none; padding: 12px 12px 8px; background: transparent; }
.side-bar .rs-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--rs-line);
  border-radius: var(--rs-radius);
  background: var(--rs-hover);
  transition: border-color .15s var(--rs-ease), box-shadow .15s var(--rs-ease), background .15s var(--rs-ease);
}
.side-bar .rs-search:focus-within {
  border-color: var(--rs-accent);
  background: var(--rs-surface-2);
  box-shadow: 0 0 0 3px var(--rs-accent-bg);
}
.side-bar .rs-search svg { width: 16px; height: 16px; flex: none; color: var(--rs-text-3); }
.side-bar .rs-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--rs-text);
  font-size: 13px;
  outline: none;
}
.side-bar .rs-search input::placeholder { color: var(--rs-text-3); }
.side-bar .rs-search button {
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rs-text-3);
  cursor: pointer;
}
.side-bar .rs-search button:hover { color: #F27A6E; }
/* common.js toggles tw-hidden on this button; it must still win over display:grid. */
.side-bar .rs-search button.tw-hidden { display: none !important; }

/* ==========================================================================
   3. Menu
   ========================================================================== */

.side-bar #side-bar {
  flex: 1 1 auto;
  min-height: 0;
  padding: 4px 10px 16px !important;
  border-right: 0 !important;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.side-bar #side-bar::-webkit-scrollbar { width: 10px; }
.side-bar #side-bar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .14);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
.side-bar #side-bar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .26); background-clip: padding-box; }

/* Section heading between groups of items. */
.side-bar #side-bar > div[class*="tw-px-3"]:not(:has(a)) {
  padding: 16px 12px 6px !important;
  color: var(--rs-text-3) !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: .1em !important;
  text-transform: uppercase;
}

/* ---------- item ---------- */
.side-bar #side-bar > a,
.side-bar #side-bar > div > a.drop_down {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  margin: 1px 0;
  padding: 8px 11px !important;
  border-radius: var(--rs-radius);
  color: var(--rs-text-2) !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  line-height: 1.3;
  text-decoration: none !important;
  transition: background .16s var(--rs-ease), color .16s var(--rs-ease), transform .16s var(--rs-ease);
}

/* The accent bar grows from the middle, so hover reads as a nudge and the
   active item as a settled state. */
.side-bar #side-bar > a::before,
.side-bar #side-bar > div > a.drop_down::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: var(--rs-accent);
  transform: translateY(-50%);
  transition: height .2s var(--rs-ease);
}

.side-bar #side-bar > a:hover,
.side-bar #side-bar > div > a.drop_down:hover {
  background: var(--rs-hover);
  color: var(--rs-text) !important;
  transform: translateX(3px);
}
/* Hover shows a short preview of the accent bar the active row carries. */
.side-bar #side-bar > a:hover::before,
.side-bar #side-bar > div > a.drop_down:hover::before {
  height: 14px;
  background: var(--rs-text-3);
}
.side-bar #side-bar > div > a.drop_down:hover .rs-caret { color: var(--rs-text-2); transform: rotate(-90deg) translateY(2px); }
.side-bar #side-bar > div > a.drop_down.is-open:hover .rs-caret { transform: rotate(0deg) translateY(2px); }

.side-bar #side-bar a.theme-sidebar-active {
  background: var(--rs-accent-bg) !important;
  color: #fff !important;
  font-weight: 600 !important;
}

/* A group is marked active when one of its children is the page. Filling both
   rows competes; the group only brightens, the child carries the fill. */
.side-bar #side-bar > div > a.drop_down.theme-sidebar-active {
  background: transparent !important;
  color: var(--rs-text) !important;
  font-weight: 600 !important;
}
.side-bar #side-bar > div > a.drop_down.theme-sidebar-active:hover { background: var(--rs-hover) !important; }
.side-bar #side-bar > a.theme-sidebar-active::before,
.side-bar #side-bar > div > a.drop_down.theme-sidebar-active::before {
  height: 22px;
  background: var(--rs-accent);
  animation: rs-bar-in .42s cubic-bezier(.34, 1.56, .64, 1) both;
}

/* The active row settles in on load, so the page you landed on announces
   itself instead of simply being there. */
.side-bar #side-bar a.theme-sidebar-active { animation: rs-active-in .34s var(--rs-ease) both; }
.side-bar #side-bar a.theme-sidebar-active > svg,
.side-bar #side-bar a.theme-sidebar-active > i { animation: rs-icon-in .45s cubic-bezier(.34, 1.56, .64, 1) both .06s; }

@keyframes rs-active-in {
  from { opacity: .35; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes rs-bar-in {
  from { height: 0; }
  to   { height: 22px; }
}
@keyframes rs-icon-in {
  0%   { transform: scale(.7); }
  60%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* ---------- icons ---------- */
.side-bar #side-bar > a > svg,
.side-bar #side-bar > a > i,
.side-bar #side-bar > div > a.drop_down > svg:first-of-type,
.side-bar #side-bar > div > a.drop_down > i {
  width: 19px !important;
  height: 19px !important;
  flex: none;
  font-size: 17px;
  stroke-width: 1.7;
  color: var(--rs-text-3);
  transition: color .16s var(--rs-ease), transform .16s var(--rs-ease);
}
.side-bar #side-bar > a:hover > svg,
.side-bar #side-bar > a:hover > i,
.side-bar #side-bar > div > a.drop_down:hover > svg:first-of-type,
.side-bar #side-bar > div > a.drop_down:hover > i { color: var(--rs-text); transform: scale(1.06); }

.side-bar #side-bar a.theme-sidebar-active > svg,
.side-bar #side-bar a.theme-sidebar-active > i { color: var(--rs-accent); }

.side-bar #side-bar > a > span,
.side-bar #side-bar > div > a.drop_down > span:not(.rs-caret) {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- group chevron ---------- */
/* common.js swaps the paths inside its own svg; this one is ours to animate. */
.side-bar #side-bar a.drop_down > svg.svg { display: none !important; }
.side-bar .rs-caret {
  width: 16px;
  height: 16px;
  flex: none;
  margin-left: auto;
  background: currentColor;
  color: var(--rs-text-3);
  opacity: .85;
  transform: rotate(-90deg);
  transition: transform .22s var(--rs-ease), color .16s var(--rs-ease);
  -webkit-mask: var(--rs-caret-mask) center / 16px 16px no-repeat;
  mask: var(--rs-caret-mask) center / 16px 16px no-repeat;
}
.side-bar {
  --rs-caret-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.side-bar a.drop_down.is-open .rs-caret { transform: rotate(0deg); }
.side-bar a.drop_down.theme-sidebar-active .rs-caret { color: #fff; }

/* ---------- children ---------- */
.side-bar .chiled {
  position: relative;
  margin: 2px 0 6px !important;
  padding-left: 30px !important;
}
.side-bar .chiled > div:first-child {
  left: 21px !important;
  width: 1.5px !important;
  border-radius: 2px;
  background: rgba(255, 255, 255, .12) !important;
}
.side-bar .chiled a {
  position: relative;
  display: flex !important;
  align-items: center;
  min-height: 32px;
  margin: 1px 0;
  padding: 5px 10px !important;
  border-radius: 8px;
  color: var(--rs-text-2) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition: background .16s var(--rs-ease), color .16s var(--rs-ease), transform .16s var(--rs-ease);
}
.side-bar .chiled a::before {
  content: "";
  position: absolute;
  left: -13.5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  transform: scale(.8);
  transition: background .16s var(--rs-ease), transform .16s var(--rs-ease);
}
.side-bar .chiled a:hover {
  background: var(--rs-hover);
  color: var(--rs-text) !important;
  transform: translateX(2px);
}
.side-bar .chiled a:hover::before { background: var(--rs-text-2); }
.side-bar .chiled a.theme-sidebar-child-active {
  background: var(--rs-accent-bg) !important;
  color: #fff !important;
  font-weight: 600 !important;
}
.side-bar .chiled a.theme-sidebar-child-active::before {
  background: var(--rs-accent);
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--rs-accent-bg);
  animation: rs-dot-in .45s cubic-bezier(.34, 1.56, .64, 1) both .08s;
}
@keyframes rs-dot-in {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.45); }
  100% { transform: scale(1.15); }
}

/* Children fade in as the slide opens. */
.side-bar .chiled a { animation: rs-fade-in .22s var(--rs-ease) both; }
@keyframes rs-fade-in {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------- empty search state ---------- */
.side-bar #sidebar-no-results {
  border-right: 0 !important;
  color: var(--rs-text-3) !important;
  font-size: 12.5px !important;
}

/* ==========================================================================
   4. Off-canvas on small screens
   ========================================================================== */

@media (max-width: 991px) {
  .side-bar,
  .side-bar.tw-hidden {
    position: fixed;
    align-self: auto;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex !important;
    transform: translateX(-100%);
    box-shadow: none;
    transition: transform .26s var(--rs-ease), box-shadow .26s var(--rs-ease);
  }
  .side-bar.small-view-side-active {
    transform: translateX(0);
    box-shadow: 0 24px 60px -20px rgba(16, 24, 40, .45);
  }
  .overlay { backdrop-filter: blur(2px); background: rgba(11, 18, 32, .45); }
}

@media (prefers-reduced-motion: reduce) {
  .side-bar,
  .side-bar * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   5. Glass sweep on the selected row
   --------------------------------------------------------------------------
   The active row gets a glass face: a low fill, a hairline of light around it
   and a highlight along the top edge. A soft band of light then passes across
   it once when the page settles, and again on hover.

   The sweep is painted by moving a gradient's background-position rather than
   sliding a box, so it never needs overflow:hidden and the accent bar on
   ::before, which sits outside the row, keeps showing.
   ========================================================================== */

.side-bar #side-bar a.theme-sidebar-active,
.side-bar .chiled a.theme-sidebar-child-active {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, 0) 55%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .10),
    inset 0 1px 0 rgba(255, 255, 255, .16),
    0 6px 18px -10px rgba(0, 0, 0, .8);
}

.side-bar #side-bar a.theme-sidebar-active::after,
.side-bar .chiled a.theme-sidebar-child-active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg,
    rgba(255, 255, 255, 0) 38%,
    rgba(255, 255, 255, .30) 50%,
    rgba(255, 255, 255, 0) 62%);
  background-size: 260% 100%;
  background-position: 150% 0;
  /* Runs on its own, not on hover: a slow pass, then a rest, on repeat. */
  animation: rs-sweep 6s linear .4s infinite;
}

@keyframes rs-sweep {
  0%   { background-position: 150% 0; }
  75%  { background-position: -60% 0; }
  100% { background-position: -60% 0; }
}

/* RoboERP logo in sidebar brand */
.side-bar .rs-brand-mark.rs-brand-mark--logo{background:#fff;border:1px solid var(--rs-line);box-shadow:0 6px 16px -8px rgba(15,23,42,.35);padding:3px;overflow:hidden}
.side-bar .rs-brand-mark.rs-brand-mark--logo img{width:100%;height:100%;object-fit:contain;display:block}
