/* ========================================
   ASTRO GESTÃO — Layout Principal
   ======================================== */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--dark-1);
  color: var(--gray-2);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: var(--font-body);
  background: var(--dark-3);
  border: 1px solid var(--dark-4);
  color: var(--white);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.875rem;
  outline: none;
  transition: border var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%236B6B78' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-4);
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--dark-3);
}

td {
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--dark-2);
  font-size: 0.875rem;
  color: var(--gray-2);
}

tr:hover td {
  background: var(--dark-2);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--dark-4);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--dark-5);
}

/* ========================================
   App Layout
   ======================================== */

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

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
  width: var(--sidebar-width);
  background: var(--dark-2);
  border-right: 1px solid var(--dark-3);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform var(--transition-slow);
}

/* Sidebar Header */
.sidebar-header {
  padding: 1.5rem 1.4rem;
  border-bottom: 1px solid var(--dark-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.68rem;
  color: var(--gray-4);
  margin-top: 0.15rem;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 0.5rem;
}

.nav-group-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray-5);
  padding: 0.9rem 1.5rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.5rem;
  margin: 2px 0.6rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--gray-3);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--dark-3);
  color: var(--gray-1);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: var(--pure-white);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--dark-3);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.85rem;
  color: var(--gray-1);
  font-weight: 500;
}

.user-role {
  font-size: 0.7rem;
  color: var(--gray-5);
}

/* ========================================
   Main Content
   ======================================== */

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  height: 100vh;      /* ancora a altura para o flex chain funcionar */
  display: flex;
  flex-direction: column;
  overflow: hidden;   /* evita scroll duplo */
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  flex-shrink: 0;       /* nunca encolhe */
  padding: 0.85rem 2rem;
  background: rgba(17, 17, 19, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--dark-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--white);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.global-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--dark-3);
  border: 1px solid var(--dark-4);
  border-radius: var(--radius);
  padding: 0 0.85rem;
  width: 320px;
  transition: border var(--transition);
}

.global-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.global-search svg {
  width: 16px;
  height: 16px;
  stroke: var(--gray-4);
  flex-shrink: 0;
}

.global-search input {
  border: none;
  background: none;
  padding: 0.55rem 0;
  font-size: 0.85rem;
}

.global-search input:focus {
  box-shadow: none;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  position: relative;
}

.icon-button:hover {
  background: var(--dark-3);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  stroke: var(--gray-3);
}

.notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--dark-1);
}

.menu-toggle {
  display: none !important;
}

/* Content Area */
.content {
  flex: 1;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;   /* páginas normais rolam aqui */
  overflow-x: hidden;
}

.page {
  display: none;
}

.page.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: fadeIn 0.3s ease;
}

/* Bloco interno que deve crescer e rolar dentro do kanban/chat.
   Aplicado via JS com class="page-fullheight" */
.page-fullheight {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1024px) {
  .global-search {
    width: 220px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  
  .main {
    margin-left: 0;
  }
  
  .content {
    padding: 1.25rem;
  }
  
  .menu-toggle {
    display: flex !important;
  }
  
  .global-search {
    display: none;
  }
}
