/* ============================================================
   layout.css — Estrutura base: app, header, nav, screens, drawers
   ============================================================ */

@import url('https://rsms.me/inter/inter.css');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #0A0A0B;
  font-family: 'Inter', sans-serif;
  color: var(--black);
}

/* ===== APP WRAPPER ===== */
#app {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: #0A0A0B;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER ===== */
#header {
  position: relative;
  z-index: 100;
  height: var(--header-height);
  background: #0A0A0B;
  display: flex;
  align-items: center;
  padding: 8px 16px 0 16px;
  gap: 12px;
  flex-shrink: 0;
  border-top: 4px solid var(--success);
}

.header-profile-btn,
.header-cart-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  overflow: visible;
  /* Para o badge não cortar */
  transition: all 0.2s;
  position: relative;
}

.header-profile-btn:active,
.header-cart-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
}

.header-cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #FF4500;
  color: white;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.3px solid #121214;
  box-shadow: 0 0 12px rgba(255, 69, 0, 0.4);
  z-index: 10;
  pointer-events: none;
  animation: badgeIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bottom-cart-badge {
  border-color: rgba(255, 255, 255, 0.4);
  /* Laranja fraco (por transparência no fundo) */
  border-width: 1.2px;
  /* Borda mais fina e menor */
  top: -10px;
  /* Mais para cima */
  right: -12px;
  /* Mais para a direita */
}

@keyframes badgeIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-profile-initials {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

#header.closed {
  border-top-color: var(--danger);
}

.header-logo {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
  letter-spacing: -0.5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-info {
  flex: 1;
  min-width: 0;
}

.header-info h1 {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
  /* Garante o truncamento */
}

/* ===== STATUS BADGE ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  border: 1px solid rgba(255, 255, 255, 0.08);
  /* #ffffff14 aprox */
  cursor: pointer;
  margin-top: 5px;
}

.status-badge.closed {
  color: var(--danger);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
  flex-shrink: 0;
}

.status-dot::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: currentColor;
  border-radius: 50%;
  opacity: 0.7;
  animation: pulse-continuous 2.5s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

/* ===== STATUS POPUP ===== */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: transparent;
}

.status-popup {
  position: fixed;
  top: calc(var(--header-height) + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 440px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popup);
  z-index: 201;
  padding: 16px;
  animation: popIn 0.18s ease forwards;
}

/* ===== SCREENS ===== */
#screenContainer {
  flex: 1;
  overflow: visible;
  position: relative;
  padding-bottom: 90px;
}

#screenHome {
  border-radius: 28px 28px 0 0;
  margin-top: 10px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  height: calc(100% - 10px);
}

#app.search-mode #screenHome {
  margin-top: 0;
  border-radius: 0;
  height: 100%;
}

/* Telas de checkout e produto não têm margin para ocupar tudo */
#screenCategory,
#screenProduct,
#screenCheckout {
  height: 100dvh !important;
  min-height: 100dvh !important;
  margin-top: 0 !important;
  top: 0 !important;
  position: fixed !important;
  border-radius: 0;
  z-index: 105;
  padding-bottom: 0 !important;
}

/* HANDLE REMOVIDO PARA CLEAN UI */

.screen {
  display: none;
  width: 100%;
  min-height: 100%;
  background: var(--white);
  transition: filter 0.4s ease, transform 0.4s ease, opacity 0.4s ease;
}

.screen.active,
.screen.entering,
.screen.leaving {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

.screen.blurred {
  filter: blur(4px) brightness(0.7);
  -webkit-filter: blur(4px) brightness(0.7);
  pointer-events: none;
  transform: translateZ(0);
  /* Hardware acceleration */
}

/* ===== BOTTOM NAV ===== */
#bottomNav {
  position: fixed;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 75px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 4px;
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  border: none;
  background: none;
  color: #71717A;
  transition: all 0.2s ease;
  border-radius: 12px;
  flex-shrink: 0;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item span {
  display: none;
  /* Mais clean, seguindo Ref 1 */
}

.nav-item.active {
  color: var(--primary);
  background: rgba(255, 107, 0, 0.1);
}

.cart-btn {
  display: flex !important;
  flex-direction: row !important;
  /* Força horizontal anulando o nav-item */
  align-items: center;
  justify-content: center;
  gap: 12px;
  background-color: #FF4500;
  color: #FFFFFF;
  border-radius: 16px;
  flex: 1;
  margin-left: 12px;
  height: 48px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cart-btn span {
  display: block !important;
  font-size: 15px;
  font-weight: 600;
  color: #FFFFFF;
}

.cart-btn.empty {
  background-color: #F4F4F5;
  color: #A1A1AA;
  box-shadow: none;
  border: 1px solid #E4E4E7;
}

.cart-btn.empty span {
  color: #A1A1AA;
}

.cart-btn.empty .cart-badge {
  background-color: #D4D4D8;
  color: #71717A;
  border-color: #F4F4F5;
}

.cart-btn:active {
  transform: scale(0.96);
}

.cart-btn svg {
  width: 22px;
  height: 22px;
  margin-bottom: 0 !important;
  /* Remove margem padrão de ícones do nav */
}

.cart-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-badge {
  position: absolute;
  top: -10px;
  right: -12px;
  background-color: #0A0A0B;
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FF4500;
  z-index: 10;
  animation: badgeBounce 0.2s ease;
}

#app.search-mode #header {
  display: none;
}

#app.search-mode #screenContainer {
  margin-top: 0;
  border-radius: 0;
  overflow: hidden;
  height: 100dvh;
  animation: slideUpFull 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#app.search-mode #bottomNav {
  display: none;
}

#app.nav-hidden #bottomNav,
#app.subscreen-mode #bottomNav {
  display: none;
}

#app.subscreen-mode #header {
  display: none;
}

.drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#cartOverlay {
  z-index: 1201;
}

#cartDrawer {
  z-index: 1202;
}

#profileOverlay {
  z-index: 1101;
}

#profileDrawer {
  z-index: 1102;
}

#ordersOverlay {
  z-index: 1000;
  /* Abaixo do bottomNav para carregar como aba */
}

#ordersDrawer {
  z-index: 1001;
}

.drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: var(--white);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.drawer.closing {
  animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(100%);
  }
}

@keyframes slideUpSimple {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}


.drawer-overlay.closing {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.drawer-handle {
  width: 40px;
  height: 4px;
  background: #E5E7EB;
  border-radius: 10px;
  margin: 12px auto 8px;
  /* Give it more room above and below */
  flex-shrink: 0;
  z-index: 100;
  cursor: grab;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Área de toque expandida (hit area) */
.drawer-handle::after {
  content: "";
  position: absolute;
  top: -20px;
  left: -40px;
  right: -40px;
  bottom: -20px;
}

.drawer-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  min-height: 100px;
  padding-bottom: 30px;
  /* Offset for the body overlap */
  background: #121214;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.drawer-header h2 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  margin: 0;
}

.drawer-close,
.drawer-back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.2s ease;
  z-index: 2;
  margin-right: 12px;
  /* Espaço para o título centralizado */
}


.drawer-close:active,
.drawer-back-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.92);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--white);
  border-radius: 28px 28px 0 0;
  margin-top: -30px;
  /* Overlap to create the 70px visual height for the header */
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
}

.drawer-content {
  padding: 20px;
  padding-bottom: 100px;
  /* Respiro para botões e menu inferior */
  flex: 1;
}

.drawer-footer {
  padding: 16px;
  padding-bottom: 100px;
  border-top: 1px solid var(--gray-border);
  flex-shrink: 0;
  background: var(--white);
}

#cartDrawer .drawer-footer {
  padding-bottom: 16px;
}

.modal-overlay {
  z-index: 2000 !important;
  /* Overlap bottomNav */
}

/* ===== UTILITY ===== */
.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}