/* Dashboard shell, sidebar, topbar, and primary navigation. */
/* Page-specific dashboard, account, settings, logs, media, and responsive styles. */
.app-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 278px;
  gap: 16px;
  align-items: start;
  direction: ltr;
}

.container {
  min-width: 0;
  display: grid;
  gap: 16px;
  direction: rtl;
}

.sidebar {
  position: sticky;
  top: 16px;
  min-height: calc(100vh - 32px);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--sidebar), #0f172a);
  color: #f8fafc;
  box-shadow: 0 20px 44px rgba(17, 24, 39, 0.22);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  direction: rtl;
  min-width: 0;
}

.sidebar,
.topbar {
  border: 1px solid rgba(17, 24, 39, 0.08);
}

.mobile-menu-button {
  display: none;
  position: sticky;
  top: 8px;
  z-index: 45;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #111827;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 26px rgba(17, 24, 39, 0.16);
  direction: rtl;
}

.mobile-menu-button svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.48);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #c8a45d;
  color: #111827;
  font-weight: 900;
  letter-spacing: 0;
}

.sidebar-brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.sidebar-brand .tiny { color: #b7c0cf; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 16px;
  z-index: 35;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  position: relative;
}

.account-switcher {
  position: relative;
}

.account-button {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 8px;
  align-items: center;
  min-width: 250px;
  max-width: min(420px, calc(100vw - 40px));
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.06);
  text-align: right;
}

.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-2);
  color: #fff;
  font-weight: 900;
}

.account-button-text {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.account-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 900;
}

.account-id {
  direction: ltr;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.account-cost {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.account-chevron {
  color: var(--muted);
  font-size: 14px;
}

.agent-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: min(360px, calc(100vw - 40px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: grid;
  gap: 8px;
}

.agent-menu[hidden] { display: none; }

.agent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: stretch;
}

.agent-option {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink);
  text-align: right;
  padding: 8px;
}

.agent-clone {
  min-width: 72px;
  padding: 8px 10px;
  background: #f8fafc;
  color: var(--ink);
  border-color: #d6dde5;
  box-shadow: none;
}

.agent-clone:hover {
  background: #edf4f6;
  transform: none;
}

.agent-option:hover,
.agent-option.active {
  background: #edf4f6;
  border-color: #cbd9df;
  transform: none;
}

.agent-create {
  border-top: 1px solid #edf1f4;
  padding-top: 8px;
  display: grid;
  gap: 6px;
}

.agent-create .tiny {
  word-break: break-word;
}

.agent-create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.sidebar-user-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-card strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-user-card .tiny {
  color: #b7c0cf;
  word-break: break-word;
}

.agent-nav,
body[data-shell-mode="account"] .agent-nav,
body[data-shell-mode="agent"] .account-nav {
  display: none;
}

body[data-shell-mode="agent"] .agent-nav {
  display: grid;
}

body[data-shell-mode="account"] .top-actions .account-switcher {
  display: none;
}
