/* ============================================================
   Chrome: top bar, side nav, dialogs, panels, snackbars, search
   ============================================================ */

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- Top bar ---------- */
#topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 8px 0 4px;
  border-bottom: 1px solid var(--g-border);
  background: var(--g-bg);
  position: relative;
  z-index: 300;
  gap: 2px;
}
.tb-icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--g-text-2);
  position: relative;
  flex: none;
}
.tb-icon-btn:hover { background: var(--g-bg-hover); color: var(--g-text); }
.tb-icon-btn:active { background: #e8eaed; }

.tb-logo {
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 2px;
  cursor: pointer;
  flex: none;
  border-radius: 4px;
}
.tb-logo .cloud-mark { display: flex; }
.tb-logo .wordmark {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--g-text-2);
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.tb-logo .wordmark b { font-weight: 400; color: var(--g-text); }
.tb-logo .env-tag {
  font-size: 11px; color: var(--g-text-3); margin-left: 2px; align-self: flex-end; padding-bottom: 1px;
}

.tb-project-btn {
  display: flex; align-items: center; gap: 6px;
  height: 36px;
  padding: 0 10px;
  margin-left: 8px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--g-text);
  max-width: 260px;
  flex: none;
}
.tb-project-btn:hover { background: var(--g-bg-hover); }
.tb-project-btn .pname {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-display); font-weight: 500;
}
.tb-project-btn .ms { font-size: 20px; color: var(--g-text-2); }

/* search */
.tb-search-wrap {
  flex: 1 1 620px;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  min-width: 160px;
}
.tb-search {
  display: flex; align-items: center;
  background: var(--g-bg-hover);
  border-radius: 8px;
  height: 40px;
  padding: 0 12px;
  gap: 8px;
  cursor: text;
  border: 1px solid transparent;
}
.tb-search:hover { background: #e8eaed; }
.tb-search.active {
  background: var(--g-bg);
  border-color: var(--g-border);
  box-shadow: var(--shadow-1);
}
.tb-search .ms { color: var(--g-text-2); font-size: 22px; }
.tb-search input {
  border: none; outline: none; background: transparent;
  width: 100%;
  font-size: 14px;
}
.tb-search input::placeholder { color: var(--g-text-3); }
.tb-search .filter-icon { color: var(--g-text-2); display: none; }

.tb-right { display: flex; align-items: center; gap: 0; flex: none; margin-left: auto; }
.tb-right .badge {
  position: absolute;
  top: 3px; right: 3px;
  background: var(--g-red);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.tb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #7b1fa2;
  color: #fff;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 6px 0 8px;
  font-weight: 500;
}
.tb-avatar-btn { border-radius: 50%; padding: 2px; }
.tb-avatar-btn:hover { box-shadow: 0 0 0 4px var(--g-bg-hover); }

/* ---------- Body row & side nav ---------- */
#body-row { display: flex; flex: 1; min-height: 0; position: relative; }

#sidenav {
  width: var(--nav-w);
  min-width: var(--nav-w);
  border-right: 1px solid var(--g-border);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--g-bg);
  transition: margin-left .18s ease;
  z-index: 250;
  padding-bottom: 24px;
}
#sidenav.collapsed { margin-left: calc(var(--nav-w) * -1); border-right-color: transparent; }

.nav-section-label {
  padding: 14px 16px 4px 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--g-text-3);
}
.nav-item {
  display: flex; align-items: center;
  height: 40px;
  padding: 0 8px 0 20px;
  gap: 16px;
  cursor: pointer;
  color: var(--g-text);
  font-size: 14px;
  position: relative;
  user-select: none;
}
.nav-item:hover { background: var(--g-bg-subtle); }
.nav-item .nav-ic { width: 24px; height: 24px; flex: none; display: flex; align-items: center; justify-content: center; }
.nav-item .nav-ic svg { width: 20px; height: 20px; display: block; }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-pin {
  width: 32px; height: 32px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  color: var(--g-text-3); flex: none;
}
.nav-item:hover .nav-pin { display: inline-flex; }
.nav-item .nav-pin:hover { background: #e8eaed; color: var(--g-text); }
.nav-item .nav-pin.pinned { display: inline-flex; color: var(--g-text-2); }
.nav-item .nav-pin .ms { font-size: 18px; }
.nav-item .nav-expand { color: var(--g-text-2); display: flex; transition: transform .15s; }
.nav-item .nav-expand.open { transform: rotate(180deg); }
.nav-item.active {
  background: var(--g-blue-light);
  color: var(--g-blue);
  font-weight: 500;
}
.nav-item.active:hover { background: var(--g-blue-light-hover); }
.nav-item.nav-sub { padding-left: 44px; font-size: 13px; }
.nav-item.nav-sub.active { color: var(--g-blue); }
.nav-cat-items { overflow: hidden; }
.nav-divider { height: 1px; background: var(--g-border-light); margin: 8px 0; }
.nav-home-row .ms { font-size: 22px; color: var(--g-text-2); }
.nav-item.active .nav-home-row .ms, .nav-item.active .ms { color: var(--g-blue); }

/* ---------- Main ---------- */
#main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: var(--g-bg);
  outline: none;
}
#page { min-height: 100%; }

/* ---------- Scrim ---------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(32,33,36,.5);
  z-index: 400;
  opacity: 1;
  transition: opacity .15s;
}
.scrim[hidden] { display: none; }

/* ---------- Dialogs ---------- */
.dialog-wrap {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.dialog-wrap .scrim, .panel-wrap .scrim { z-index: 0; }
.dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.24), 0 0 2px rgba(0,0,0,.12);
  width: 560px;
  max-width: calc(100vw - 48px);
  max-height: 80vh;
  display: flex; flex-direction: column;
  animation: dlg-in .15s ease-out;
}
@keyframes dlg-in { from { transform: scale(.97) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  padding: 20px 24px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.dialog-body { padding: 4px 24px 16px; overflow-y: auto; font-size: 14px; color: var(--g-text-2); line-height: 1.5; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 24px 16px;
  border-top: none;
}

/* ---------- Right slide panels ---------- */
.panel-wrap { position: fixed; inset: 0; z-index: 450; pointer-events: none; }
.panel-wrap .scrim { pointer-events: auto; }
.side-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  z-index: 1;
  width: 420px; max-width: 92vw;
  background: #fff;
  box-shadow: -2px 0 12px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
  animation: panel-in .2s ease-out;
  pointer-events: auto;
}
@keyframes panel-in { from { transform: translateX(60px); opacity: .4; } to { transform: none; opacity: 1; } }
.side-panel .sp-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--g-border-light);
}
.side-panel .sp-title { font-family: var(--font-display); font-size: 16px; font-weight: 500; flex: 1; }
.side-panel .sp-body { flex: 1; overflow-y: auto; padding: 16px; }
.side-panel .sp-footer {
  border-top: 1px solid var(--g-border-light);
  padding: 12px 16px;
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ---------- Snackbars ---------- */
#layer-snackbar {
  position: fixed; left: 24px; bottom: 24px; z-index: 600;
  display: flex; flex-direction: column; gap: 8px;
}
.snackbar {
  background: #323232;
  color: #fff;
  border-radius: 4px;
  box-shadow: var(--shadow-2);
  padding: 14px 16px;
  font-size: 14px;
  display: flex; align-items: center; gap: 16px;
  max-width: 560px;
  animation: snack-in .18s ease-out;
}
@keyframes snack-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.snackbar.leaving { transition: opacity .2s, transform .2s; opacity: 0; transform: translateY(8px); }
.snackbar .sn-action {
  color: #8ab4f8;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: .3px;
  padding: 4px 8px;
  border-radius: 4px;
}
.snackbar .sn-action:hover { background: rgba(138,180,248,.12); }
.snackbar .sn-close { color: #bdc1c6; display: flex; padding: 2px; border-radius: 50%; }
.snackbar .sn-close:hover { color: #fff; background: rgba(255,255,255,.1); }
.snackbar .sn-msg { flex: 1; }

/* ---------- Global search dropdown ---------- */
.search-dd {
  position: fixed;
  z-index: 550;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-2);
  width: 720px;
  max-width: calc(100vw - 64px);
  max-height: 70vh;
  overflow-y: auto;
  padding: 8px 0;
  border: 1px solid var(--g-border-light);
}
.search-dd .sd-group-label {
  padding: 10px 16px 4px;
  font-size: 11px; font-weight: 500; color: var(--g-text-3);
  text-transform: uppercase; letter-spacing: .8px;
}
.search-dd .sd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
}
.search-dd .sd-item:hover, .search-dd .sd-item.hl { background: var(--g-bg-subtle); }
.search-dd .sd-item .sd-ic { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex: none; color: var(--g-text-2); }
.search-dd .sd-item .sd-ic svg { width: 18px; height: 18px; }
.search-dd .sd-item .sd-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-dd .sd-item .sd-kind { color: var(--g-text-3); font-size: 12px; flex: none; }
.search-dd .sd-item mark { background: transparent; font-weight: 500; color: var(--g-blue); }
.search-dd .sd-empty { padding: 20px 16px; color: var(--g-text-2); text-align: center; }

/* ---------- Notification tray ---------- */
.notif-tray {
  position: fixed;
  top: calc(var(--topbar-h) + 4px);
  right: 8px;
  width: 400px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 90px);
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-2);
  z-index: 540;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: dlg-in .15s ease-out;
}
.notif-tray .nt-header {
  display: flex; align-items: center;
  padding: 12px 16px;
  font-family: var(--font-display); font-size: 16px;
}
.notif-tray .nt-header .nt-count { color: var(--g-text-3); margin-left: 6px; font-size: 14px; font-family: var(--font-body); }
.notif-tray .nt-actions { margin-left: auto; display: flex; gap: 4px; }
.notif-list { overflow-y: auto; }
.notif-item { border-top: 1px solid var(--g-border-light); padding: 12px 16px; cursor: pointer; }
.notif-item:hover { background: var(--g-bg-subtle); }
.notif-item .ni-top { display: flex; gap: 12px; align-items: flex-start; }
.notif-item .ni-ic { width: 24px; height: 24px; flex: none; display: flex; align-items: center; justify-content: center; }
.notif-item .ni-ic svg { width: 20px; height: 20px; }
.notif-item .ni-title { font-weight: 500; font-size: 13px; line-height: 1.4; }
.notif-item .ni-sub { color: var(--g-text-2); font-size: 12px; margin-top: 2px; }
.notif-item .ni-detail { font-size: 13px; color: var(--g-text-2); margin-top: 8px; line-height: 1.5; }
.notif-item .ni-detail code { font-family: var(--font-mono); font-size: 12px; background: var(--g-bg-subtle); padding: 1px 4px; border-radius: 3px; }
.notif-item .ni-toggle { color: var(--g-blue); font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 2px; }
.notif-item .ni-toggle:hover { text-decoration: underline; }
.notif-empty { padding: 40px 16px; text-align: center; color: var(--g-text-2); }

/* ---------- Avatar menu ---------- */
.avatar-menu {
  position: fixed; top: calc(var(--topbar-h) + 4px); right: 8px;
  width: 340px; background: #fff; border-radius: 12px;
  box-shadow: var(--shadow-2); z-index: 540; overflow: hidden;
  animation: dlg-in .15s ease-out;
}
.avatar-menu .am-head { text-align: center; padding: 20px 16px 12px; }
.avatar-menu .am-email { color: var(--g-text-2); font-size: 13px; }
.avatar-menu .am-big {
  width: 72px; height: 72px; border-radius: 50%;
  background: #7b1fa2; color: #fff; font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  margin: 12px auto 8px;
}
.avatar-menu .am-name { font-size: 20px; font-family: var(--font-display); }
.avatar-menu .am-foot { border-top: 1px solid var(--g-border-light); padding: 8px; display: flex; justify-content: center; gap: 8px; }
