/* ===================================================================
   APP SHELL — SIDEBAR / TOPBAR / MAIN LAYOUT
   =================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--t-med) var(--ease);
}

.app-shell.is-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border-1);
  min-height: var(--topbar-h);
}

.sidebar-brand__logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-red);
}

.sidebar-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  transition: opacity var(--t-fast) var(--ease);
}

.sidebar-brand__text strong {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-0);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.sidebar-brand__text span {
  font-size: 11px;
  font-weight: 600;
  color: var(--ets-red-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell.is-collapsed .sidebar-brand__text { display: none; }

.sidebar-toggle {
  margin-left: auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
}
.sidebar-toggle:hover { color: var(--text-0); border-color: var(--ets-red); background: var(--bg-3); }
.app-shell.is-collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 16px 12px 6px;
  white-space: nowrap;
}
.app-shell.is-collapsed .sidebar-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  position: relative;
  transition: all var(--t-fast) var(--ease);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

.nav-item:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.nav-item.is-active {
  background: linear-gradient(90deg, rgba(192,0,0,0.18), rgba(192,0,0,0.03));
  color: var(--text-0);
  border-color: rgba(192,0,0,0.35);
}

.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: var(--r-full);
  background: var(--ets-red-bright);
}

.nav-item__label { transition: opacity var(--t-fast) var(--ease); }
.app-shell.is-collapsed .nav-item__label { display: none; }
.app-shell.is-collapsed .nav-item { justify-content: center; }

.sidebar-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border-1);
  font-size: 11px;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
}
.app-shell.is-collapsed .sidebar-footer { text-align: center; }
.app-shell.is-collapsed .sidebar-footer .full-text { display: none; }

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  background: rgba(19, 19, 21, 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border-1);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-3);
  font-weight: 600;
}
.breadcrumbs__current { color: var(--text-0); }
.breadcrumbs__sep { color: var(--text-4); }

.topbar-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  padding: 9px 16px;
  width: 280px;
  color: var(--text-3);
  transition: all var(--t-fast) var(--ease);
}
.topbar-search:focus-within {
  border-color: var(--ets-red);
  box-shadow: 0 0 0 3px rgba(192,0,0,0.15);
}
.topbar-search svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; }
.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-0);
  font-size: 13px;
  width: 100%;
  font-family: inherit;
}
.topbar-search input::placeholder { color: var(--text-4); }

.topbar-icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
}
.topbar-icon-btn:hover { color: var(--text-0); border-color: var(--ets-red); background: var(--bg-3); }
.topbar-icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }

.topbar-icon-btn__dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ets-red-bright);
  border: 2px solid var(--bg-1);
}

.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.topbar-profile:hover { border-color: var(--ets-red); background: var(--bg-3); }
.topbar-profile__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ets-red), var(--ets-red-dim));
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-0);
  flex-shrink: 0;
}
.topbar-profile__name { font-size: 13px; font-weight: 700; color: var(--text-0); }
.topbar-profile__role { font-size: 11px; color: var(--text-3); }

/* ---------- MAIN ---------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  padding: 28px 32px 64px;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 26px;
  margin-bottom: 6px;
}

.page-header p {
  color: var(--text-3);
  font-size: 14px;
}

.page-header__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Notification dropdown */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  overflow: hidden;
  animation: popIn var(--t-fast) var(--ease);
  transform-origin: top right;
}
.dropdown-panel__header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-1);
  font-size: 13px;
  font-weight: 800;
  color: var(--text-0);
}
.dropdown-panel__item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-1);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.dropdown-panel__item:last-child { border-bottom: none; }
.dropdown-panel__icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(192,0,0,0.15);
  color: var(--ets-red-bright);
  flex-shrink: 0;
}
.dropdown-panel__icon svg { width: 15px; height: 15px; }
.dropdown-panel__text strong { display: block; font-size: 12.5px; color: var(--text-1); font-weight: 700; margin-bottom: 2px; }
.dropdown-panel__text span { font-size: 11.5px; color: var(--text-3); }
.dropdown-anchor { position: relative; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .app-shell .sidebar-brand__text,
  .app-shell .sidebar-section-label,
  .app-shell .nav-item__label,
  .app-shell .sidebar-footer .full-text { display: none; opacity: 0; }
  .app-shell .nav-item { justify-content: center; }
  .topbar-search { width: 180px; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; width: var(--sidebar-w); transform: translateX(-100%); box-shadow: var(--shadow-lg); transition: transform var(--t-med) var(--ease); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar.is-open .sidebar-brand__text,
  .sidebar.is-open .sidebar-section-label,
  .sidebar.is-open .nav-item__label,
  .sidebar.is-open .sidebar-footer .full-text { display: flex; opacity: 1; }
  .sidebar.is-open .nav-item__label { display: inline; }
  .sidebar.is-open .nav-item { justify-content: flex-start; }
  .mobile-menu-btn { display: grid !important; }
  .topbar-search { display: none; }
  .page { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; gap: 12px; }
}

.mobile-menu-btn {
  display: none;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text-1);
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-menu-btn svg { width: 18px; height: 18px; stroke: currentColor; }

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 39;
  backdrop-filter: blur(2px);
}
.sidebar-scrim.is-open { display: block; }
