/* ============================================================
   main.css — Layout Base — 706 Studio Dashboard
   ============================================================ */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
ul, ol { list-style: none; }
img, svg { display: block; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg-primary); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ============================================================
   SHELL / LAYOUT PRINCIPAL
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 220px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* --- Topbar --- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.topbar__logo {
  width: 28px;
  height: 28px;
}

.topbar__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.topbar__subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}

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

.topbar__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--color-sla-ok);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.topbar__time {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

/* --- Sidebar --- */
.sidebar {
  grid-area: sidebar;
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-4) 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav__section {
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border-radius: 0;
  transition: color var(--transition-base), background var(--transition-base);
  position: relative;
}

.nav__item:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-hover);
}

.nav__item.active {
  color: var(--color-text-primary);
  background: var(--color-bg-hover);
  font-weight: var(--weight-medium);
}

.nav__item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--color-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

.nav__badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-1);
  background: var(--color-sla-late-bg);
  color: var(--color-sla-late);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav__badge--warning {
  background: var(--color-sla-risk-bg);
  color: var(--color-sla-risk);
}

.sidebar__footer {
  margin-top: auto;
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
}

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

.sidebar__avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  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-info {
  min-width: 0;
}

.sidebar__user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* --- Main content --- */
.main-content {
  grid-area: main;
  padding: var(--space-8);
  overflow-y: auto;
  min-width: 0;
}

/* --- Page header --- */
.page-header {
  margin-bottom: var(--space-8);
}

.page-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

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

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  .sidebar {
    display: none;
  }

  .main-content {
    padding: var(--space-4);
  }
}
