/* ============================================================
   LAYOUT.CSS — Estrutura de layout, navbar, sidebar e grid
   Central de Ouvintes Maisnova
   ============================================================ */

/* ===============================================
   NAVBAR — Barra de navegação superior
   =============================================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-secondary);
  z-index: var(--z-fixed);
  transition: background var(--transition-slow);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar-logo svg {
  width: 100%;
  height: 100%;
}

.navbar-title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  letter-spacing: var(--letter-spacing-tight);
}

.navbar-title span {
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
}

/* Links de navegação */
.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.navbar-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.navbar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.navbar-link.active {
  color: var(--color-primary);
  background: var(--color-primary-50);
}

/* Área do usuário na navbar */
.navbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.navbar-user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1-5) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.navbar-user-info:hover {
  background: var(--bg-hover);
}

.navbar-user-name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  line-height: 1.2;
}

.navbar-user-role {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
}

/* Hamburger menu (mobile) */
.navbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

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

.navbar-hamburger svg {
  width: 22px;
  height: 22px;
}

/* Botão de tema na navbar */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* ===============================================
   SIDEBAR — Barra lateral
   =============================================== */
.sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--navbar-height));
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-secondary);
  overflow-y: auto;
  z-index: var(--z-sticky);
  transition: transform var(--transition-slow),
              width var(--transition-slow);
  padding: var(--space-4) var(--space-3);
}

.sidebar-section {
  margin-bottom: var(--space-6);
}

.sidebar-section-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2-5) var(--space-3);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none;
  cursor: pointer;
  margin-bottom: var(--space-0-5);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.sidebar-link.active {
  color: var(--color-primary);
  background: var(--color-primary-50);
}

/* Overlay do sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--navbar-height);
  background: var(--overlay-bg);
  z-index: calc(var(--z-sticky) - 1);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
  opacity: 1;
}

/* ===============================================
   CONTAINERS DE PÁGINA
   =============================================== */
.page-container {
  margin-top: var(--navbar-height);
  min-height: calc(100vh - var(--navbar-height));
}

/* Conteúdo com sidebar */
.page-with-sidebar {
  margin-left: var(--sidebar-width);
}

/* Conteúdo principal */
.page-content {
  padding: var(--space-8) var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
}

/* Seção da página */
.page-section {
  margin-bottom: var(--space-8);
}

/* Header da página */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.page-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

.page-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

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

/* Tela cheia (login, qrcode) */
.page-fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ===============================================
   SISTEMA DE GRID
   =============================================== */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Gap variantes */
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ===============================================
   UTILITÁRIOS FLEXBOX
   =============================================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.items-start   { align-items: flex-start; }
.items-center  { align-items: center; }
.items-end     { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start   { justify-content: flex-start; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }

.self-start  { align-self: flex-start; }
.self-center { align-self: center; }
.self-end    { align-self: flex-end; }

/* ===============================================
   RESPONSIVO — MOBILE (<768px)
   =============================================== */
@media (max-width: 767px) {
  /* Navbar ajustes */
  .navbar {
    padding: 0 var(--space-4);
  }

  .navbar-nav {
    display: none;
  }

  .navbar-hamburger {
    display: flex;
  }

  .navbar-user-name,
  .navbar-user-role {
    display: none;
  }

  /* Sidebar mobile — escondida por padrão */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .sidebar-overlay {
    display: block;
  }

  /* Sem margem do sidebar */
  .page-with-sidebar {
    margin-left: 0;
  }

  /* Conteúdo */
  .page-content {
    padding: var(--space-4) var(--space-4);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Grid responsivo */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  /* Toast ajuste */
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
  }

  .toast {
    min-width: auto;
  }

  /* Tabela scroll */
  .table-wrapper {
    border-radius: var(--radius-md);
  }
}

/* ===============================================
   RESPONSIVO — TABLET (768px - 1024px)
   =============================================== */
@media (min-width: 768px) and (max-width: 1024px) {
  .navbar {
    padding: 0 var(--space-4);
  }

  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar .sidebar-section-title,
  .sidebar .sidebar-link span {
    display: none;
  }

  .sidebar .sidebar-link {
    justify-content: center;
    padding: var(--space-3);
  }

  .page-with-sidebar {
    margin-left: var(--sidebar-collapsed-width);
  }

  /* Grid responsivo */
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===============================================
   RESPONSIVO — DESKTOP GRANDE (>1400px)
   =============================================== */
@media (min-width: 1400px) {
  .page-content {
    padding: var(--space-8);
  }
}

/* ===============================================
   LAYOUT DE DUAS COLUNAS (tipo chat)
   =============================================== */
.layout-split {
  display: flex;
  height: calc(100vh - var(--navbar-height));
  margin-top: var(--navbar-height);
  overflow: hidden;
}

.layout-split-left {
  width: var(--chat-sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
}

.layout-split-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

@media (max-width: 767px) {
  .layout-split {
    flex-direction: column;
  }

  .layout-split-left {
    width: 100%;
    height: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-secondary);
  }

  .layout-split-left.hidden-mobile {
    display: none;
  }

  .layout-split-right {
    width: 100%;
    height: 100%;
  }

  .layout-split-right.hidden-mobile {
    display: none;
  }
}

/* ===============================================
   CONTAINER CENTRALIZADO (login, qrcode)
   =============================================== */
.centered-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
}

/* ===============================================
   CONTAINER COM SCROLL INTERNO
   =============================================== */
.scroll-container {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

/* ===============================================
   FOOTER
   =============================================== */
.footer {
  padding: var(--space-6);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-secondary);
}
