/* ─── Application Shell ────────────────────────────────────────────────────── */
/* Layout: header + nav bar + content area.                                      */
/* No component-level styles here — see components.css.                          */

/* ── Shell-level layout variables ───────────────────────────────────────────── */
/* --viewas-h is 0px by default; set to 32px via JS when View As banner is shown */
:root {
  --viewas-h: 0px;
}

/* ── Root layout ────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.shell-header {
  height: var(--header-h);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow2);
  flex-shrink: 0;
}

/* Brand */
.shell-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.shell-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--acc), #7c3aed);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -.02em;
}

.shell-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.shell-brand-sub {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.2;
}

/* Header center — search */
.shell-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.shell-search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--rad-sm);
  padding: 7px 14px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 280px;
  transition: border-color .15s, background .15s;
}

.shell-search-trigger:hover {
  background: #263548;
  border-color: var(--acc2);
  color: #cbd5e1;
}

.shell-search-trigger svg {
  flex-shrink: 0;
  opacity: .7;
}

.shell-search-trigger span {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-search-trigger kbd {
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  color: #64748b;
  font-family: inherit;
  flex-shrink: 0;
}

/* Header right — sync + user */
.shell-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Sync badge */
.shell-sync-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  color: #94a3b8;
}

.shell-sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.shell-sync-dot.loading {
  background: var(--acc);
  animation: sync-pulse 1s ease-in-out infinite;
}

.shell-sync-dot.stale {
  background: var(--amber);
}

@keyframes sync-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* User pill placeholder (fully wired in M0b) */
.shell-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  color: #e2e8f0;
  cursor: pointer;
  user-select: none;
}

.shell-user-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--acc), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.shell-user-name {
  font-weight: 600;
}

.shell-user-role {
  background: #334155;
  color: #94a3b8;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Refresh button */
.shell-refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #94a3b8;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .15s, color .15s;
}

.shell-refresh-btn:hover {
  border-color: var(--acc2);
  color: #cbd5e1;
}

.shell-refresh-btn.spinning #refreshIcon {
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* User caret */
.shell-user-caret {
  flex-shrink: 0;
  opacity: .6;
  transition: transform .15s;
}

.shell-user-pill:hover .shell-user-caret {
  opacity: 1;
}

/* User dropdown menu */
.shell-user-menu {
  position: fixed;
  z-index: 200;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--bdr);
  border-radius: var(--rad);
  box-shadow: var(--shadow2);
  display: none;
  padding: 4px 0;
}

.shell-user-menu.open {
  display: block;
}

.shell-user-menu-email {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-user-menu-divider {
  height: 1px;
  background: var(--bdr);
  margin: 4px 0;
}

.shell-user-menu-item {
  display: block;
  width: 100%;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--txt);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}

.shell-user-menu-item:hover {
  background: var(--acc-bg);
  color: var(--acc);
}

/* ── View As Banner ─────────────────────────────────────────────────────────── */
.view-as-banner {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  background: #1e3a5f;
  border-bottom: 1px solid #2563eb;
  font-size: 12px;
  color: #93c5fd;
  position: sticky;
  top: var(--header-h);
  z-index: 99;
  flex-shrink: 0;
}

.view-as-banner[hidden] {
  display: none;
}

.view-as-banner-label strong {
  font-weight: 600;
}

.view-as-banner-role {
  color: #60a5fa;
  opacity: 0.75;
}

.view-as-banner-exit {
  margin-left: auto;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid #2563eb;
  color: #93c5fd;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  line-height: 1;
  transition: background 0.12s;
}

.view-as-banner-exit:hover {
  background: rgba(37, 99, 235, 0.38);
}

/* ── Primary navigation ─────────────────────────────────────────────────────── */
.shell-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--bdr);
  display: flex;
  align-items: stretch;
  padding: 0 24px;
  position: sticky;
  top: calc(var(--header-h) + var(--viewas-h));
  z-index: 90;
  flex-shrink: 0;
}

.shell-nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  letter-spacing: .01em;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  position: relative;
  top: 1px; /* align border-bottom flush with nav border */
}

.shell-nav-item:hover {
  color: var(--txt);
}

.shell-nav-item.active {
  color: var(--acc);
  border-bottom-color: var(--acc);
  font-weight: 700;
}

.shell-nav-item .nav-badge {
  background: var(--acc-bg);
  color: #3730a3;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
}

/* ── Content area ───────────────────────────────────────────────────────────── */
.shell-content {
  flex: 1;
  min-height: 0;
}

.shell-pane {
  display: none;
  padding: 24px;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

.shell-pane.active {
  display: block;
}

/* Placeholder content — shown in empty panes during migration */
.pane-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: var(--dim);
  font-size: 13px;
  gap: 8px;
}

.pane-placeholder-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
}

.pane-placeholder-sub {
  font-size: 12px;
  color: var(--dim);
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .shell-header {
    padding: 0 16px;
    gap: 10px;
  }

  .shell-header-center {
    display: none;
  }

  .shell-brand-sub {
    display: none;
  }

  .shell-nav {
    padding: 0 16px;
    overflow-x: auto;
  }

  .shell-pane {
    padding: 16px;
  }
}
