/* ===================================================================
   LIA EMS -- layout.css
   App Shell, Sidebar, Main Area, Topbar, Pages
   =================================================================== */

/* -- APP SHELL -- */
.app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* -- SIDEBAR -- */
.sb {
  width: 232px;
  min-width: 232px;
  max-width: 232px;
  flex-shrink: 0;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  position: relative;
  z-index: 10;
}

.sb::-webkit-scrollbar {
  width: 3px;
}

.sb::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .15);
  border-radius: 2px;
}

/* -- Sidebar Brand -- */
.sb-brand {
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background .15s;
}

.sb-brand:hover {
  background: rgba(255, 255, 255, .04);
}

.sb-ico {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--blue), var(--ai));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(109, 40, 217, .35);
}

.sb-ico svg {
  width: 18px;
  height: 18px;
}

.sb-name {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -.2px;
}

.sb-ver {
  font-size: 9px;
  color: rgba(255, 255, 255, .3);
  margin-top: 1px;
}

.sb-ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 8px;
  font-weight: 800;
  background: var(--ai-p);
  border: 1px solid var(--ai-border);
  color: #c4b5fd;
  border-radius: 8px;
  padding: 1px 5px;
  margin-top: 2px;
}

/* -- Sidebar Section -- */
.sb-sec {
  padding: 2px 7px 4px;
  flex-shrink: 0;
}

.sb-lbl {
  font-size: 9px;
  font-weight: 800;
  color: rgba(255, 255, 255, .28);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 10px 9px 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.sb-lbl::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, .07);
}

/* -- Navigation Buttons -- */
.nav {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .55);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  margin-bottom: 1px;
  transition: all .12s;
  position: relative;
  line-height: 1.35;
  word-break: keep-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav:hover {
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .9);
  white-space: normal;
}

.nav.on {
  background: rgba(68, 114, 196, .55) !important;
  color: #fff !important;
  font-weight: 700;
  white-space: normal;
  box-shadow: inset 3px 0 0 var(--blue) !important;
}

.nav svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: .4;
}

.nav.on svg,
.nav:hover svg {
  opacity: .9;
}

.nav.ai-nav {
  border-left: 2px solid var(--ai-border);
}

.nav.ai-nav:hover {
  background: var(--ai-lt);
}

.nav-new {
  font-size: 8px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  background: rgba(8, 145, 178, .3);
  color: #7DD3FC;
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.nav-ai-badge {
  font-size: 7.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 6px;
  background: var(--ai-p);
  color: #c4b5fd;
  border: 1px solid var(--ai-border);
  margin-left: auto;
  flex-shrink: 0;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
  animation: pulseDot 2s ease infinite;
}

@keyframes pulseDot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: .5;
    transform: scale(1.4);
  }
}

/* -- Sidebar Footer -- */
.sb-footer {
  margin-top: auto;
  padding: 9px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  flex-shrink: 0;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  transition: background .12s;
}

.sb-user:hover {
  background: rgba(255, 255, 255, .1);
}

.sb-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sb-uname {
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
}

.sb-urole {
  font-size: 9.5px;
  color: rgba(255, 255, 255, .32);
}

/* -- MAIN AREA -- */
.main {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  position: relative;
}

.main::-webkit-scrollbar {
  width: 6px;
}

.main::-webkit-scrollbar-track {
  background: transparent;
}

.main::-webkit-scrollbar-thumb {
  background: var(--bd2);
  border-radius: 3px;
}

.main::-webkit-scrollbar-thumb:hover {
  background: var(--tx4);
}

#main-content {
  width: 100%;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* -- PAGES -- */
.page {
  display: none;
  width: 100%;
  min-width: 0;
  flex-direction: column;
}

.page.on {
  display: flex;
  animation: pageIn .2s cubic-bezier(.4, 0, .2, 1);
}

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

/* -- TOPBAR -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  width: 100%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bd);
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--sh);
  overflow: hidden;
}

.topbar > div:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.tb-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.2px;
}

.tb-sub {
  font-size: 10px;
  color: var(--tx4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.tb-acts {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* -- CONTENT -- */
.content {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 14px 18px 40px;
  overflow-x: hidden;
}

.content > * {
  max-width: 100%;
  min-width: 0;
}

/* -- LANGUAGE SWITCHER -- */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, .08);
  border-radius: 20px;
  padding: 3px 3px;
  margin: 6px 9px 0;
  flex-shrink: 0;
}

.lang-btn {
  flex: 1;
  padding: 5px 0;
  border: none;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  color: rgba(255, 255, 255, .45);
  background: transparent;
  letter-spacing: .01em;
}

.lang-btn.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(68, 114, 196, .5);
}

.lang-btn:hover:not(.active) {
  color: rgba(255, 255, 255, .8);
  background: rgba(255, 255, 255, .1);
}

/* -- GLOBAL BACK BUTTON -- */



/* -- GLOBAL BAR (navbar: hamburger + search + shortcuts) -- */
.gbar { position: sticky; top: 0; z-index: 300; display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; background: #fff; border-bottom: 1px solid var(--line, #e2e8f0); }
.gbar-btn { border: 1px solid var(--line, #e2e8f0); background: #fff; border-radius: 6px;
  padding: 5px 9px; font-size: 13px; cursor: pointer; line-height: 1; position: relative; font-family: inherit; }
.gbar-btn:hover { background: #f1f5f9; }
.gbar-badge { position: absolute; top: -5px; right: -5px; background: #DC2626; color: #fff;
  border-radius: 999px; font-size: 9px; font-weight: 700; padding: 1px 4px; min-width: 14px; text-align: center; }
.gbar-search { position: relative; flex: 1; max-width: 430px; }
.gbar-search input { width: 100%; border: 1px solid var(--line, #e2e8f0); border-radius: 6px;
  padding: 6px 10px 6px 28px; font-size: 12px; font-family: inherit; background: #f8fafc; }
.gbar-search input:focus { outline: 2px solid rgba(68, 114, 196, .35); background: #fff; }
.gbar-search .gs-ico { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); opacity: .45; font-size: 12px; }
.gs-results { position: absolute; top: 112%; left: 0; right: 0; background: #fff;
  border: 1px solid var(--line, #e2e8f0); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .13);
  max-height: 62vh; overflow-y: auto; display: none; z-index: 60; }
.gs-group { font-size: 10px; font-weight: 700; color: #64748b; padding: 8px 10px 3px; text-transform: uppercase; letter-spacing: .04em; }
.gs-item { display: flex; gap: 8px; align-items: center; padding: 7px 10px; font-size: 12px; cursor: pointer; }
.gs-item:hover, .gs-item.sel { background: #eff6ff; }
.gs-item .gs-sub { color: #94a3b8; font-size: 10.5px; margin-left: auto; white-space: nowrap; }
.gs-empty { padding: 12px; font-size: 12px; color: #94a3b8; text-align: center; }

/* -- MINI SIDEBAR (desktop collapse) -- */
body.sb-mini .sb { width: 58px; min-width: 58px; max-width: 58px; }
body.sb-mini .sb .nav span, body.sb-mini .sb-lbl, body.sb-mini .lang-switch,
body.sb-mini .sb-brand > div:last-child, body.sb-mini #ems-user-chip,
body.sb-mini .sb-footer, body.sb-mini .nav-ai-badge, body.sb-mini .nav-new { display: none !important; }
body.sb-mini .sb .nav { justify-content: center; padding: 8px 0; }
body.sb-mini .sb .nav svg { width: 16px; height: 16px; opacity: .7; }
body.sb-mini .sb-brand { justify-content: center; }

/* -- MOBILE OFF-CANVAS SIDEBAR -- */
.gbar-backdrop { display: none; }
@media (max-width: 900px) {
  .sb { position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s ease; z-index: 100; box-shadow: 4px 0 18px rgba(0,0,0,.25); }
  body.sb-open .sb { transform: translateX(0); }
  body.sb-open .gbar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 99; }
  .gbar { padding: 7px 8px; }
  .gbar-search { max-width: none; }
}
@media (max-width: 600px) {
  .gbar .gbar-shortcut-optional { display: none; }
  .content { padding: 8px !important; }
  .fg.fg2, .fg.fg3, .fg.fg4 { grid-template-columns: 1fr !important; }
}

/* -- PINNED SIDEBAR FOOTER: scroll only the nav area -- */
.sb { overflow: hidden; }
.sb-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.sb-scroll::-webkit-scrollbar { width: 3px; }
.sb-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 2px; }
body.sb-mini .sb-scroll { overflow-y: auto; }

/* -- FOOTER PIN (belt & suspenders): sticky works even if .sb itself scrolls -- */
.sb-footer { position: sticky; bottom: 0; background: var(--navy); z-index: 2;
  box-shadow: 0 -6px 12px rgba(0, 0, 0, .25); }

/* -- COLLAPSIBLE NAV GROUPS -- */
.sb-lbl { cursor: pointer; user-select: none; }
.sb-lbl::before { content: '▾ '; font-size: 8px; opacity: .6; }
.sb-lbl.closed::before { content: '▸ '; }
.sb-lbl:hover { color: rgba(255, 255, 255, .75); }
.sb .grp-hidden { display: none !important; }
body.sb-mini .sb .grp-hidden { display: flex !important; }  /* mini rail: icons always visible */

/* -- shortcut icons: inline svg sizing -- */
.gbar-btn svg { width: 14px; height: 14px; vertical-align: -2px; }
#sb-quick-buttons svg { width: 13px; height: 13px; flex-shrink: 0; opacity: .8; }

/* -- CUSTOM SHORTCUTS: navbar balloon + sidebar icon grid -- */
.gbar-balloon { display: none; position: absolute; top: calc(100% + 10px); right: -6px;
  background: #fff; border: 1px solid var(--line, #e2e8f0); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .16); padding: 10px; z-index: 70; min-width: 216px; }
.gbar-balloon::before { content: ''; position: absolute; top: -6px; right: 14px; width: 10px; height: 10px;
  background: #fff; border-left: 1px solid var(--line, #e2e8f0); border-top: 1px solid var(--line, #e2e8f0);
  transform: rotate(45deg); }
.gbar-balloon.open { display: block; }
.sc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sc-tile { display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--line, #e2e8f0); border-radius: 8px; padding: 12px 6px;
  background: #f8fafc; cursor: pointer; font-family: inherit; min-height: 52px; }
.sc-tile:hover { background: #eff6ff; border-color: #93c5fd; }
.sc-tile .sc-ico { font-size: 24px; line-height: 1; }
.sc-tile .sc-ico svg { width: 24px; height: 24px; }
.sc-tile .sc-lbl { font-size: 8.5px; color: #475569; text-align: center; line-height: 1.15;
  max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gbar-balloon .sc-hint { font-size: 10.5px; color: #94a3b8; padding: 4px 2px; }
/* sidebar quick-access as icon grid */
#sb-quick-buttons.sc-sbgrid { display: grid !important; flex-direction: unset;
  grid-template-columns: repeat(3, 1fr); gap: 5px; }
#sb-quick-buttons.sc-sbgrid .sc-tile { background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .12); }
#sb-quick-buttons.sc-sbgrid .sc-tile:hover { background: rgba(255, 255, 255, .14); }
#sb-quick-buttons.sc-sbgrid .sc-lbl { color: rgba(255, 255, 255, .6); }
#sb-quick-buttons.sc-sbgrid .sc-ico { color: rgba(255, 255, 255, .85); }

/* -- add-shortcut tile + balloon picker -- */
.sc-tile.sc-add { border-style: dashed; background: #fff; color: #64748b; }
.sc-tile.sc-add .sc-ico { font-size: 22px; color: #94a3b8; }
.sc-picker { margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.sc-picker select { flex: 1; border: 1px solid var(--line, #e2e8f0); border-radius: 6px;
  padding: 5px 8px; font-size: 11.5px; font-family: inherit; }
.sc-picker button { border: 1px solid #059669; color: #059669; background: #fff;
  border-radius: 6px; padding: 5px 10px; font-size: 11.5px; cursor: pointer; font-family: inherit; }
#sb-quick-buttons.sc-sbgrid .sc-tile.sc-add { background: rgba(255,255,255,.03);
  border-style: dashed; border-color: rgba(255,255,255,.25); }
