/* ============================================================
   shell.css — the app frame: dark sidebar + translucent top bar
   + centred content column. Markup in references/components.md
   («Shell») and in assets/template.html.
   ============================================================ */

.app-shell {
  --sidebar-w: 248px;
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(1200px 400px at 70% -120px, rgba(91, 91, 246, 0.08), transparent 70%),
    var(--bg-primary);
}
.app-shell.is-collapsed { --sidebar-w: 76px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; height: 100vh; position: sticky; top: 0;
  display: flex; flex-direction: column; gap: 1.5rem; padding: 1.25rem 0.875rem;
  background:
    radial-gradient(400px 260px at 0% 0%, rgba(124, 108, 255, 0.22), transparent 70%),
    linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg));
  color: var(--sidebar-text);
  transition: width 0.28s var(--ease), padding 0.28s var(--ease);
  z-index: 60;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.75rem; padding: 0.25rem 0.375rem 0.5rem; min-height: 44px; }
.sidebar-logo {
  width: 38px; height: 38px; border-radius: 11px; object-fit: cover; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 8px 20px -6px rgba(124, 108, 255, 0.6);
}
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand-name { color: var(--sidebar-text-strong); font-weight: 800; font-size: 0.95rem; letter-spacing: -0.02em; white-space: nowrap; }
.sidebar-brand-sub { font-size: 0.72rem; color: var(--sidebar-text); white-space: nowrap; }

.sidebar-toggle-btn {
  position: absolute; right: -13px; top: 30px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg-secondary); border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--color-secondary-text); box-shadow: var(--shadow-md);
  transition: color 0.2s, transform 0.2s var(--ease);
}
.sidebar-toggle-btn:hover { color: var(--color-accent); transform: scale(1.08); }

.sidebar-nav { display: flex; flex-direction: column; gap: 1.375rem; overflow-y: auto; overflow-x: hidden; flex: 1; }
.sidebar-group { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-group-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.36); padding: 0 0.75rem; margin-bottom: 0.25rem; white-space: nowrap;
}
.sidebar-links { list-style: none; display: flex; flex-direction: column; gap: 0.125rem; }
.sidebar-link {
  position: relative; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.75rem; border-radius: 0.75rem;
  color: var(--sidebar-text); text-decoration: none; font-size: 0.875rem; font-weight: 600;
  transition: background 0.18s var(--ease), color 0.18s var(--ease); white-space: nowrap;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.sidebar-link.active { background: var(--sidebar-active); color: var(--sidebar-text-strong); box-shadow: inset 0 0 0 1px rgba(124, 108, 255, 0.25); }
.sidebar-link.active::before {
  content: ''; position: absolute; left: -0.875rem; top: 22%; bottom: 22%; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gradient-brand); box-shadow: 0 0 12px rgba(124, 108, 255, 0.8);
}
.sidebar-link-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-link-icon svg { width: 100%; height: 100%; }
/* A coloured square icon for a channel / module (24px, gradient fill, white glyph) */
.channel-icon { width: 24px; height: 24px; border-radius: 7px; color: white; box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.5); }
.channel-icon svg { width: 13px; height: 13px; stroke: white; fill: none; }
/* Status dot at the end of a link (connected / not) */
.conn-dot { width: 7px; height: 7px; border-radius: 50%; margin-left: auto; flex-shrink: 0; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18), 0 0 8px rgba(34, 197, 94, 0.7); }
.conn-dot.is-off { background: rgba(255, 255, 255, 0.18); box-shadow: none; }
.sidebar-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #f59e0b; color: #1f1300; font-size: 0.7rem; font-weight: 800; display: grid; place-items: center; }
.sidebar-footer {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem; border-radius: 0.875rem;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem; white-space: nowrap; overflow: hidden;
}
.sidebar-footer svg { width: 16px; height: 16px; flex-shrink: 0; color: #a5a0ff; }

/* Collapsed sidebar: icons only */
.is-collapsed .sidebar { padding: 1.25rem 0.75rem; }
.is-collapsed .sidebar-brand-text, .is-collapsed .sidebar-group-label, .is-collapsed .sidebar-link-text, .is-collapsed .conn-dot { display: none; }
.is-collapsed .sidebar-brand { justify-content: center; padding: 0.25rem 0 0.5rem; }
.is-collapsed .sidebar-link { justify-content: center; padding: 0.6rem; }
.is-collapsed .sidebar-footer { justify-content: center; padding: 0.75rem 0; }
.is-collapsed .sidebar-link.active::before { left: -0.75rem; }
.is-collapsed .sidebar-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; font-size: 0.6rem; }
.sidebar-scrim { display: none; }

/* ---------- Main column + top bar ---------- */
.main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 2rem;
  background: var(--topbar-bg); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--topbar-border);
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.topbar-menu-btn {
  display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--color-border);
  background: var(--bg-secondary); color: var(--color-primary-text); align-items: center; justify-content: center; cursor: pointer;
}
/* Breadcrumb: «Sección / Página» */
.topbar-title { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; white-space: nowrap; }
.topbar-section { font-size: 0.8rem; font-weight: 600; color: var(--color-muted-text); }
.topbar-section::after { content: '/'; margin-left: 0.5rem; color: var(--color-border-strong); }
.topbar-page { font-size: 1rem; font-weight: 800; letter-spacing: -0.02em; color: var(--color-primary-text); overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 0.625rem; }
.topbar-role { font-size: 0.75rem; font-weight: 700; color: var(--color-accent); background: var(--color-accent-light); padding: 0.35rem 0.7rem; border-radius: 999px; }

/* User avatar + dropdown */
.user-menu { position: relative; }
.user-avatar-btn {
  width: 38px; height: 38px; border-radius: 12px; border: none; background: var(--gradient-brand); cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0;
  box-shadow: 0 0 0 3px var(--bg-secondary), 0 0 0 4px var(--color-border); transition: box-shadow 0.18s var(--ease);
}
.user-avatar-btn:hover { box-shadow: 0 0 0 3px var(--bg-secondary), 0 0 0 4px var(--color-accent); }
.user-avatar-initials { font-size: 0.75rem; font-weight: 800; color: white; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 10px); background: var(--bg-secondary);
  border: 1px solid var(--color-border); border-radius: 14px; min-width: 220px; box-shadow: var(--shadow-lg);
  z-index: 500; overflow: hidden; animation: dropdown-in 0.16s var(--ease) both;
}
@keyframes dropdown-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
.user-dropdown-name { padding: 0.85rem 1rem 0.1rem; font-size: 0.85rem; font-weight: 700; }
.user-dropdown-email { padding: 0 1rem 0.75rem; font-size: 0.75rem; color: var(--color-secondary-text); }
.user-dropdown-sep { border-top: 1px solid var(--color-border); }
.user-dropdown-item {
  width: 100%; padding: 0.7rem 1rem; display: flex; align-items: center; gap: 0.5rem; background: none; border: none;
  cursor: pointer; font-family: inherit; font-size: 0.83rem; font-weight: 600; text-align: left; color: var(--color-primary-text);
}
.user-dropdown-item:hover { background: var(--bg-subtle); }
.user-dropdown-item.is-danger { color: var(--color-danger); }
.user-dropdown-item.is-danger:hover { background: var(--color-danger-light); }

/* ---------- Content ---------- */
.content-area { flex: 1; min-width: 0; }
.content-inner { padding: 2rem 2.25rem 3rem; max-width: 1280px; margin: 0 auto; animation: fadeIn 0.3s var(--ease); }
.content-inner--roomy { max-width: 1840px; }               /* analytics, wide tables */
.content-inner--wide { max-width: none; padding: 1.1rem 1.5rem 1.15rem; } /* calendars, inboxes, editors */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .app-shell, .app-shell.is-collapsed { --sidebar-w: 260px; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-105%); transition: transform 0.28s var(--ease); box-shadow: var(--shadow-lg); }
  .is-mobile-open .sidebar { transform: translateX(0); }
  .is-collapsed .sidebar-brand-text, .is-collapsed .sidebar-group-label, .is-collapsed .sidebar-link-text, .is-collapsed .conn-dot { display: revert; }
  .sidebar-toggle-btn { display: none; }
  .is-mobile-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(15, 12, 41, 0.45); backdrop-filter: blur(2px); z-index: 55; }
  .topbar { padding: 0 1rem; }
  .topbar-menu-btn { display: inline-flex; }
  .topbar-section { display: none; }
  .content-inner, .content-inner--wide { padding: 1.25rem 1rem 2.5rem; }
}
