/* ============================================
   LAYOUT — Sidebar, Bottom Nav, Shell
   ============================================ */

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

/* ============ MOBILE TOP BAR ============ */
.mobile-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--navy);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
  z-index: 90;
  backdrop-filter: blur(10px);
}

/* Inner row — conteúdo sempre 52px, centralizado */
.mobile-topbar-row {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.mobile-topbar-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.logo-img-sm {
  width: 28px; height: 28px;
  border-radius: 8px;
  object-fit: cover;
}
.logo-text-sm {
  font-size: 1rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.3px;
}

.btn-hamburger {
  width: 38px; height: 38px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  padding: 0;
}
.btn-hamburger:hover { color: var(--gold); background: var(--gold-muted); }
.btn-hamburger .icon-svg { width: 22px; height: 22px; }

/* Desktop: hide mobile topbar */
@media (min-width: 768px) {
  .mobile-topbar { display: none !important; }
}

/* ============ SIDEBAR OVERLAY (mobile) ============ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
  z-index: 149;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 150;
  overflow-y: auto;
  overflow-x: hidden;
  /* Mobile: starts off-screen */
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s ease;
}

/* Desktop: always visible */
@media (min-width: 768px) {
  .sidebar {
    transform: translateX(0) !important;
    box-shadow: none !important;
  }
}

/* Mobile: slide in when open */
.sidebar.open {
  transform: translateX(0);
  box-shadow: 8px 0 40px rgba(0,0,0,0.6);
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  padding-top: calc(1.25rem + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(212,175,55,0.08) 0%, transparent 100%);
  position: relative;
}
.logo-img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.logo-text {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.3px;
  flex: 1;
}

/* Close button — only on mobile */
.btn-close-sidebar {
  width: 32px; height: 32px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-fast);
  flex-shrink: 0;
  padding: 0;
}
.btn-close-sidebar:hover { color: var(--text-primary); background: var(--surface-3); }
.btn-close-sidebar .icon-svg { width: 18px; height: 18px; }

@media (min-width: 768px) {
  .btn-close-sidebar { display: none !important; }
}

/* ============ SIDEBAR NAV ============ */
.sidebar-nav {
  flex: 1;
  padding: 0.875rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover {
  background: var(--gold-muted);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--gold-muted);
  color: var(--gold);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  color: inherit;
}
.nav-icon .icon-svg { width: 18px; height: 18px; }

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.375rem 0.5rem;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 0.75rem 0.875rem 0.25rem;
}

.nav-admin-item {
  color: var(--gold) !important;
  border: 1px solid rgba(212,175,55,0.25);
  margin-top: 0.25rem;
}
.nav-admin-item:hover {
  background: var(--gold-muted) !important;
  border-color: var(--gold);
}

/* ============ SIDEBAR FOOTER ============ */
.sidebar-footer {
  padding: 0.875rem 0.625rem;
  border-top: 1px solid var(--border);
}
.btn-logout {
  width: 100%;
  padding: 0.7rem 0.875rem;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
}
.btn-logout:hover {
  border-color: rgba(244,67,54,0.4);
  color: #F44336;
  background: rgba(244,67,54,0.08);
}
.btn-logout .icon-svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ============ MAIN CONTENT ============ */
.main-content {
  flex: 1;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-content {
  min-height: 100vh;
}

/* Desktop: offset for sidebar */
@media (min-width: 768px) {
  .main-content.with-sidebar {
    margin-left: var(--sidebar-width);
  }
}

/* Mobile: offset for top bar + iOS safe area */
@media (max-width: 767px) {
  .main-content.with-sidebar {
    padding-top: calc(52px + env(safe-area-inset-top));
  }
}

/* ============ BOTTOM NAV (Mobile) ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  background: var(--navy);
  border-top: 1px solid var(--border);
  z-index: 80;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-items {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
  padding: 0 0.25rem;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  flex: 1;
  max-width: 72px;
  position: relative;
}
.bottom-nav-item:hover { color: var(--text-secondary); }
.bottom-nav-item.active { color: var(--gold); }
.bottom-nav-item.active .nav-icon-bottom::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  background: var(--gold);
  border-radius: 50%;
}

.nav-icon-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  line-height: 1;
}
.nav-icon-bottom .icon-svg { width: 22px; height: 22px; }

.nav-label-bottom {
  font-size: 0.6rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: 0.2px;
}

.nav-more-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.375rem 0.5rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  flex: 1;
  max-width: 72px;
}
.nav-more-btn:hover { color: var(--text-secondary); }
.nav-more-btn .icon-svg { width: 22px; height: 22px; }

/* More menu overlay */
.more-menu {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  background: var(--navy);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1.25rem 0.875rem;
  z-index: 200;
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}
.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.875rem 0.5rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  text-align: center;
}
.more-menu-item:hover {
  border-color: var(--border);
  color: var(--text-primary);
  background: var(--surface-2);
}
.more-menu-item.active { border-color: var(--gold); color: var(--gold); }
.more-menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.more-menu-icon .icon-svg { width: 22px; height: 22px; }
.more-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 190;
}

/* ============ TOP HEADER (per-section, mobile) ============ */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  background: var(--navy);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-header .logo-small {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1rem;
  color: var(--gold);
}
.top-header .logo-small img { width: 28px; height: 28px; border-radius: 8px; }

@media (min-width: 768px) {
  .top-header { display: none; }
  .sidebar { display: flex !important; }
  .bottom-nav { display: none !important; }
}
