/* layout.css — sidebar, topbar, grid, login shell */

/* -- App shell -- */

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  background: var(--bg-app);
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 12px;
}

.sidebar-brand .brand-mark {
  display: inline-flex;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-strong));
  align-items: center; justify-content: center;
  color: #1C1917;
  font-weight: 700;
}

.sidebar-brand h1 {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--sidebar-text);
  letter-spacing: 0.5px;
}

.sidebar-brand .brand-eyebrow {
  color: var(--sidebar-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  margin: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--sidebar-faint);
  padding: 16px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
  position: relative;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.05);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar-link[aria-current="page"] {
  background: var(--sidebar-active);
  color: var(--accent-soft);
}

.sidebar-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  background: var(--accent-soft);
  border-radius: 0 3px 3px 0;
}

.sidebar-link .icon {
  width: 18px; height: 18px;
  flex: 0 0 auto;
}

.sidebar-foot {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-channel-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  font-size: 12px;
}

.sidebar-channel-status .chan {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-channel-status .chan-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}
.sidebar-channel-status .chan-dot.ok { background: #4ADE80; box-shadow: 0 0 8px rgba(74,222,128,0.6); }
.sidebar-channel-status .chan-dot.warn { background: #F59E0B; }
.sidebar-channel-status .chan-dot.off { background: #6B7280; }

/* -- Topbar -- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px 14px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 0;
}

.page-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-secondary);
  margin: 0 0 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.12s ease;
}
.user-chip:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.user-chip .user-role {
  font-size: 11px;
  color: var(--text-secondary);
  border-left: 1px solid var(--border);
  padding-left: 8px;
}
.user-chip .user-role:empty { display: none; }
.user-chip .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-strong));
  color: #1C1917;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

/* -- Main content -- */

.main {
  padding: 28px;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

.section {
  margin-bottom: 32px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 16px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

.section-head .muted {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

@media (min-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Two column layout for main page */
.split-cols {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

@media (max-width: 980px) {
  .split-cols { grid-template-columns: 1fr; }
}

/* -- Login shell -- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at top right, #FBF7EE 0%, var(--bg-app) 60%);
}

[data-theme="dark"] .login-body {
  background: radial-gradient(ellipse at top right, #1E1B14 0%, var(--bg-app) 60%);
}

.login-orb {
  /* fixed, not absolute: these decorative blurs sit outside the viewport on
     purpose, and absolute ones counted towards the page width — a phone could
     scroll ~90px sideways into empty background. */
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  z-index: 0;
  pointer-events: none;
}

.login-orb-1 {
  width: 300px; height: 300px;
  top: -60px; right: -80px;
  background: var(--accent-soft);
  animation: orbdrift 12s ease-in-out infinite alternate;
}
.login-orb-2 {
  width: 360px; height: 360px;
  bottom: -100px; left: -80px;
  background: var(--instagram);
  opacity: 0.2;
  animation: orbdrift 16s ease-in-out infinite alternate-reverse;
}

[data-theme="dark"] .login-orb { opacity: 0.35; }

@keyframes orbdrift {
  0% { transform: translate(0,0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.08); }
}

.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: var(--bg-elev);
  border-radius: var(--radius-xl);
  padding: 32px 32px 28px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.login-lead {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 20px;
}

@media (max-width: 600px) {
  /* minmax(0,...) not 1fr: a grid item's automatic minimum size is its
     content, so one wide table stretched the whole shell past the viewport
     and the page scrolled sideways on every phone. */
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .app-shell > *, main, .card, .table-wrap { min-width: 0; max-width: 100%; }
  .sidebar {
    position: relative;
    height: auto;
    padding: 12px 14px;
    gap: 12px;
  }
  .sidebar-brand { padding: 0 4px; }
  .sidebar-brand .brand-eyebrow { display: none; }
  .sidebar-nav { flex: none; flex-direction: row; }
  .sidebar-link {
    flex: 1;
    justify-content: center;
    padding: 9px 6px;
    font-size: 12px;
    /* Measured 36px at 390px. This row IS the navigation once the sidebar
       collapses, and the rest of the phone rules already treat 44px as the
       finger target (components.css §"Touch targets"). */
    min-height: 44px;
  }
  .sidebar-link[aria-current="page"]::before { display: none; }
  .sidebar-foot {
    padding-top: 8px;
    flex-direction: row;
    justify-content: flex-end;
  }
  .sidebar-channel-status { display: none; }
  .main { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-left { width: 100%; justify-content: space-between; gap: 8px; }
  .topbar-right { width: 100%; justify-content: flex-end; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
