/* ============================================================
   APP SHELL — sidebar fija + contenido principal
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255 255 255 / 0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}

.sidebar-logo__mark {
  width: 28px;
  height: 28px;
  background: var(--color-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: white;
  flex-shrink: 0;
}

.sidebar-logo__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-inverse);
  line-height: var(--leading-tight);
}

.sidebar-logo__tagline {
  font-size: var(--text-xs);
  color: rgba(255 255 255 / 0.4);
  display: block;
}

/* Nav */

.sidebar-nav {
  padding: var(--space-4) var(--space-2);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-nav__section {
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
  padding: 0 var(--space-2);
  font-size: 0.65rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255 255 255 / 0.3);
}

.sidebar-nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: rgba(255 255 255 / 0.65);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.sidebar-nav__item:hover {
  background: rgba(255 255 255 / 0.07);
  color: var(--color-text-inverse);
  text-decoration: none;
}

.sidebar-nav__item.active {
  background: rgba(255 255 255 / 0.1);
  color: var(--color-text-inverse);
  font-weight: var(--weight-medium);
}

.sidebar-nav__item.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 28px;
  background: var(--color-accent);
  border-radius: 0 2px 2px 0;
  margin-left: calc(var(--space-2) * -1);
}

.sidebar-nav__item {
  position: relative;
}

.sidebar-nav__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav__item:hover .sidebar-nav__icon,
.sidebar-nav__item.active .sidebar-nav__icon {
  opacity: 1;
}

/* Footer del sidebar */

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255 255 255 / 0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-user__avatar {
  width: 30px;
  height: 30px;
  border-radius: 99px;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: white;
  flex-shrink: 0;
}

.sidebar-user__name {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: rgba(255 255 255 / 0.8);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user__email {
  font-size: 0.7rem;
  color: rgba(255 255 255 / 0.35);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Main --- */

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Page header */

.page-header {
  padding: var(--space-6) var(--space-8);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.page-header__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Page content */

.page-content {
  padding: var(--space-8);
  flex: 1;
}

/* Grid de stats */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
}

/* Grid de artículos */

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}

/* Stack vertical */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-8); }

/* Cluster horizontal */

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================================
   TOPBAR — navegación simple para las primeras iteraciones
   ============================================================ */

.topbar {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__brand {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar__brand::before {
  content: "S";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-accent);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  border-radius: var(--radius-sm);
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

.topbar__link {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}

.topbar__link:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
  text-decoration: none;
}

.topbar__link--active {
  color: var(--color-text);
  font-weight: var(--weight-medium);
  background: var(--color-primary-light);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

.topbar__email {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================================
   LAYOUT DE AUTH (login / OTP)
   ============================================================ */

.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: var(--space-6);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-10) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.auth-card__logo {
  text-align: center;
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  text-align: center;
}

.auth-card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-1);
}
