/* ============================================================
   layout.css — NeuroIAMSPE
   App shell, header, sidebar, bottom nav — mobile-first
   ============================================================ */

/* ------------------------------------------------------------
   App Shell
   ------------------------------------------------------------ */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ------------------------------------------------------------
   App Header (fixed top)
   ------------------------------------------------------------ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background-color: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  z-index: var(--z-header);
  box-shadow: var(--shadow-md);
}

.app-header__title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--white);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--transition-fast);
}

.app-header__action:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

/* Hide hamburger on desktop (sidebar is always visible) */
.app-header__action--desktop {
  display: none;
}

@media (min-width: 768px) {
  .app-header__action--mobile {
    display: none;
  }
}

/* ------------------------------------------------------------
   App Sub-header (user info bar)
   ------------------------------------------------------------ */
.app-subheader {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  height: 36px;
  background-color: var(--light);
  border-bottom: 1px solid var(--beige);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-2);
  z-index: calc(var(--z-header) - 1);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.app-subheader:hover {
  background-color: var(--beige);
}

.app-subheader__name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-subheader__turma {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray);
  flex-shrink: 0;
}

.app-subheader__badge {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.app-subheader__badge--admin,
.app-subheader__badge--professor {
  background-color: var(--primary);
  color: var(--white);
}

.app-subheader__badge--residente {
  background-color: var(--beige);
  color: var(--primary);
}

.app-subheader__badge--fellow {
  background-color: var(--gray);
  color: var(--white);
}

/* ------------------------------------------------------------
   App Content
   ------------------------------------------------------------ */
.app-content {
  flex-grow: 1;
  padding-top: 92px;      /* header 56px + sub-header 36px */
  padding-bottom: 64px;   /* bottom nav height on mobile */
  min-height: 100vh;
}

/* Login/auth pages: no header/sidebar/bottom-nav offset */
.app-content--full {
  padding-top: 0;
  padding-bottom: 0;
  margin-left: 0 !important;
}

/* ------------------------------------------------------------
   Bottom Navigation (mobile only)
   ------------------------------------------------------------ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background-color: var(--white);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  z-index: var(--z-header);
  padding: 0 var(--space-2);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  color: var(--gray);
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color var(--transition-fast);
  text-transform: uppercase;
  text-decoration: none;
  min-width: 44px;
  padding: var(--space-2) var(--space-1);
}

.bottom-nav__item svg,
.bottom-nav__item .bottom-nav__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.bottom-nav__item:hover,
.bottom-nav__item--active {
  color: var(--primary);
}

/* ------------------------------------------------------------
   Sidebar (desktop only)
   ------------------------------------------------------------ */
.sidebar {
  display: none; /* hidden on mobile */
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--light);
}

.sidebar__logo-text {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.sidebar__section {
  padding: var(--space-4) 0 var(--space-2);
}

.sidebar__section-label {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray);
  padding: 0 var(--space-5) var(--space-2);
}

/* ------------------------------------------------------------
   Navigation Tabs (sidebar nav items)
   ------------------------------------------------------------ */
.nav-tab {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid transparent;
  color: var(--gray);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
  text-decoration: none;
  user-select: none;
}

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

.nav-tab--active {
  border-left-color: var(--primary);
  background-color: var(--light);
  color: var(--primary);
  font-weight: 600;
}

.nav-tab__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-tab__label {
  flex: 1;
}

/* Nav tab with chevron/arrow indicator */
.nav-tab-container {
  position: relative;
}

.nav-tab-container .nav-tab__chevron {
  width: 16px;
  height: 16px;
  color: var(--gray);
  transition: transform var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.nav-tab-container.nav-tab-container--open .nav-tab__chevron {
  transform: rotate(90deg);
  color: var(--primary);
}

/* Sub-tabs (nested navigation) */
.sub-tab {
  padding-left: 32px;
  font-size: 13px;
  font-weight: 400;
}

.sub-tab--active {
  border-left-color: var(--primary);
  background-color: var(--light);
  color: var(--primary);
  font-weight: 600;
}

/* ------------------------------------------------------------
   Desktop breakpoint (min-width: 768px)
   ------------------------------------------------------------ */
@media (min-width: 768px) {
  /* Hide bottom navigation on desktop */
  .bottom-nav {
    display: none;
  }

  /* Sidebar — always visible on desktop */
  .sidebar {
    display: block;
    position: fixed;
    left: 0;
    top: 92px;
    bottom: 0;
    width: 260px;
    background-color: var(--white);
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.06);
    z-index: calc(var(--z-header) - 1);
    overscroll-behavior: contain;
  }

  /* Push content right, header/sub-header stay full-width */
  .app-content {
    margin-left: 260px;
    padding-bottom: 0;
  }

  .app-header {
    left: 0;
  }

  .app-subheader {
    left: 0;
  }
}

/* ------------------------------------------------------------
   Mobile Drawer (sidebar slide-in — mobile only)
   ------------------------------------------------------------ */
.mobile-drawer {
  display: none; /* hidden on desktop */
}

.mobile-drawer-overlay {
  display: none;
}

@media (max-width: 767px) {
  .mobile-drawer {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background-color: var(--white);
    z-index: calc(var(--z-header) + 10);
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
  }

  .mobile-drawer--open {
    transform: translateX(0);
  }

  .mobile-drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: calc(var(--z-header) + 9);
  }

  .mobile-drawer__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-4);
    border-bottom: 1px solid var(--light);
    background-color: var(--primary);
    color: var(--white);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
  }

  .mobile-drawer__close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.1rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: background-color var(--transition-fast);
  }

  .mobile-drawer__close:hover {
    background-color: rgba(255, 255, 255, 0.15);
  }

  .mobile-drawer__footer {
    padding: var(--space-2) 0;
    border-top: 1px solid var(--light);
    margin-top: var(--space-2);
  }
}

/* ------------------------------------------------------------
   Large desktop breakpoint (min-width: 1024px)
   ------------------------------------------------------------ */
@media (min-width: 1024px) {
  .app-content {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}
