/* ==========================================================================
   Topbar
   ========================================================================== */
.app-topbar {
  background: #c09530 !important;
  background-color: #c09530 !important;
  box-shadow: 0 2px 10px rgba(45, 45, 45, 0.12);
  box-sizing: border-box;
  color: #fff !important;
  display: block;
  margin: 0;
  max-width: 100%;
  /* Borda a borda em mobile / PWA: notch e home indicator. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: 0;
  padding-left: env(safe-area-inset-left, 0px);
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 30;
}

.app-topbar__inner {
  align-items: center;
  display: grid;
  gap: clamp(0.5rem, 1vw, 0.85rem);
  grid-template-columns: 2.25rem 1fr 2.25rem;
  margin: 0 auto;
  max-width: 96rem;
  min-height: 3.75rem;
  padding: 0.65rem clamp(0.75rem, 2vw, 1.5rem);
}

.app-brand {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  min-width: 0;
  text-align: center;
}

.app-brand__logo {
  display: block;
  height: 2.25rem;
  object-fit: contain;
  width: 2.25rem;
}

.app-brand__eyebrow {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: clamp(0.7rem, 0.4vw + 0.6rem, 0.85rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.app-brand__title {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: clamp(1.05rem, 0.6vw + 0.95rem, 1.5rem);
  font-weight: 800;
  line-height: 1.2;
  margin-top: 0.25rem;
  /* Em telas muito estreitas, evita estourar o cabeçalho. */
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-icon-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.5rem;
  color: #fff;
  display: inline-flex;
  flex: 0 0 2.25rem !important;
  height: 2.25rem !important;
  justify-content: center;
  justify-self: center;
  max-height: 2.25rem !important;
  max-width: 2.25rem !important;
  min-height: 0;
  min-width: 0;
  padding: 0 !important;
  transition: background 0.2s ease, transform 0.2s ease;
  width: 2.25rem !important;
}

.app-icon-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.app-icon-button:active {
  transform: scale(0.96);
}

.app-icon-button--spacer {
  pointer-events: none;
  visibility: hidden;
}

.app-back-icon {
  border-bottom: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  height: 0.55rem;
  transform: rotate(45deg);
  width: 0.55rem;
}

.app-menu-lines,
.app-menu-lines::before,
.app-menu-lines::after {
  background: currentColor;
  border-radius: 999px;
  content: "";
  display: block;
  height: 0.12rem;
  width: 1rem;
}

.app-menu-lines::before {
  transform: translateY(-0.32rem);
}

.app-menu-lines::after {
  transform: translateY(0.2rem);
}

/* ==========================================================================
   Página (container principal)
   ========================================================================== */
.app-page {
  margin: 0 auto;
  max-width: 96rem;
  padding: var(--comercial-page-y, 1.5rem) var(--comercial-page-x, 1rem);
  padding-bottom: calc(var(--comercial-page-y, 1.5rem) + env(safe-area-inset-bottom, 0px));
}

/* ==========================================================================
   Drawer lateral (menu)
   ========================================================================== */
.app-drawer-overlay {
  background: rgba(45, 45, 45, 0.45);
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.22s ease;
  z-index: 40;
  /* Garante que cobre 100% mesmo em iOS com barras dinâmicas. */
  height: 100dvh;
}

.app-drawer {
  background: #fff;
  box-shadow: 8px 0 24px rgba(45, 45, 45, 0.16);
  display: flex;
  flex-direction: column;
  inset: 0 auto 0 0;
  max-width: 24rem;
  position: fixed;
  transform: translateX(-100%);
  transition: transform 0.24s ease;
  width: min(86vw, 24rem);
  z-index: 50;
  /* Usa altura dinâmica para acompanhar a barra do iOS, com fallback. */
  height: 100vh;
  height: 100dvh;
  /* Respira em volta do notch / home indicator. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.app-drawer.is-open {
  transform: translateX(0);
}

.app-drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.app-drawer__header {
  border-bottom: 1px solid #e0e0e0;
  padding: 1.25rem 1.5rem;
}

.app-drawer__eyebrow {
  color: #a87d24;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-drawer__title {
  color: #2d2d2d;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  margin-top: 0.35rem;
}

.app-drawer__content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.app-drawer__section {
  color: #a87d24;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 1.1rem 0 0.5rem;
  text-transform: uppercase;
}

.app-drawer__section:first-child {
  margin-top: 0;
}

.app-drawer__link {
  border-radius: 0.75rem;
  color: #2d2d2d;
  display: block;
  font-size: 1rem;
  font-weight: 600;
  /* min-height confortável para o dedo (≥ 44px). */
  min-height: 2.75rem;
  padding: 0.75rem 0.75rem;
}

.app-drawer__link:hover,
.app-drawer__link:focus-visible {
  background: #f8f5f0;
}

.app-drawer__footer {
  border-top: 1px solid #e0e0e0;
  padding: 1rem 1.25rem;
}

.app-drawer__logout {
  align-items: center;
  border: 1px solid #e0e0e0;
  border-radius: 0.85rem;
  color: #666666;
  cursor: pointer;
  display: flex;
  font-weight: 700;
  justify-content: center;
  min-height: 3rem;
  width: 100%;
}

.app-drawer__logout:hover {
  background: #f8f5f0;
}

/* ==========================================================================
   Toasts (notificações)
   ========================================================================== */
.app-toast-container {
  display: grid;
  gap: 0.75rem;
  /* Em mobile usa toda a largura útil (com pequena margem). */
  max-width: min(24rem, calc(100vw - 1.5rem));
  pointer-events: none;
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  top: calc(0.75rem + env(safe-area-inset-top, 0px));
  width: calc(100% - 1.5rem);
  z-index: 90;
}

@media (min-width: 640px) {
  .app-toast-container {
    right: 1rem;
    top: calc(1rem + env(safe-area-inset-top, 0px));
    width: 100%;
  }
}

.app-toast {
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #e0e0e0;
  border-left: 0.35rem solid #c09530;
  border-radius: 1rem;
  box-shadow: 0 16px 40px rgba(45, 45, 45, 0.16);
  color: #2d2d2d;
  display: grid;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  pointer-events: auto;
  transform: translateY(-0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.is-visible {
  transform: translateY(0);
}

.app-toast.is-leaving {
  opacity: 0;
  transform: translateY(-0.5rem);
}

.app-toast--sucesso {
  border-left-color: #16a34a;
}

.app-toast--erro {
  border-left-color: #dc2626;
}

.app-toast--info {
  border-left-color: #c09530;
}

.app-toast__title {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
}

.app-toast__message {
  color: #666666;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Diálogo de confirmação
   ========================================================================== */
.app-confirm-overlay {
  align-items: center;
  background: rgba(45, 45, 45, 0.55);
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 0;
  padding: 1rem;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.2s ease;
  z-index: 95;
  height: 100dvh;
}

.app-confirm-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.app-confirm-dialog {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 1.15rem;
  box-shadow: 0 24px 60px rgba(45, 45, 45, 0.22);
  display: grid;
  gap: 1rem;
  max-width: 28rem;
  padding: clamp(1rem, 2vw, 1.5rem);
  transform: scale(0.96);
  transition: transform 0.2s ease;
  width: 100%;
}

.app-confirm-overlay.is-open .app-confirm-dialog {
  transform: scale(1);
}

.app-confirm-icon {
  align-items: center;
  background: #f2f0ed;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  color: #9b7520;
  display: flex;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-weight: 800;
  height: 2.5rem;
  justify-content: center;
  width: 2.5rem;
}

.app-confirm-title {
  color: #2d2d2d;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
}

.app-confirm-message {
  color: #666666;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-top: 0.25rem;
}

.app-confirm-actions {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}

@media (min-width: 420px) {
  .app-confirm-actions {
    grid-template-columns: 1fr 1fr;
  }
}

.app-confirm-button {
  border-radius: 0.85rem;
  cursor: pointer;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-weight: 700;
  min-height: 3rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.app-confirm-button:active {
  transform: scale(0.98);
}

.app-confirm-button--cancel {
  background: #fff;
  border: 1px solid #e0e0e0;
  color: #666666;
}

.app-confirm-button--cancel:hover {
  background: #f8f5f0;
}

.app-confirm-button--confirm {
  background: #c09530;
  color: #fff;
}

.app-confirm-button--confirm:hover {
  background: #a87d24;
}

/* ==========================================================================
   Date picker
   ========================================================================== */
.app-date-field {
  position: relative;
}

.app-date-trigger {
  align-items: center;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 0.85rem;
  color: #2d2d2d;
  cursor: pointer;
  display: flex;
  font-size: 0.95rem;
  justify-content: space-between;
  min-height: 2.75rem;
  outline: none;
  padding: 0.6rem 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.app-date-trigger:hover,
.app-date-trigger:focus {
  border-color: #c09530;
  box-shadow: 0 0 0 3px rgba(192, 149, 48, 0.18);
}

.app-date-trigger.has-value {
  font-weight: 700;
}

.app-date-picker {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 1rem;
  box-shadow: 0 20px 45px rgba(45, 45, 45, 0.18);
  display: none;
  left: 0;
  padding: 0.9rem;
  position: absolute;
  top: calc(100% + 0.5rem);
  width: min(22rem, calc(100vw - 1.5rem));
  z-index: 80;
}

.app-date-picker.is-open {
  display: block;
}

.app-date-picker__header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.app-date-picker__title {
  color: #2d2d2d;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: capitalize;
}

.app-date-picker__nav {
  align-items: center;
  background: #f2f0ed;
  border-radius: 0.6rem;
  color: #9b7520;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  height: 2.25rem;
  justify-content: center;
  width: 2.25rem;
}

.app-date-picker__weekdays,
.app-date-picker__days {
  display: grid;
  gap: 0.25rem;
  grid-template-columns: repeat(7, 1fr);
}

.app-date-picker__weekday {
  color: #666666;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.25rem 0;
  text-align: center;
  text-transform: uppercase;
}

.app-date-picker__day {
  align-items: center;
  border-radius: 0.65rem;
  color: #2d2d2d;
  cursor: pointer;
  display: flex;
  font-size: 0.9rem;
  font-weight: 700;
  height: 2.25rem;
  justify-content: center;
}

.app-date-picker__day:hover {
  background: #f8f5f0;
}

.app-date-picker__day.is-muted {
  color: #999999;
}

.app-date-picker__day.is-selected {
  background: #c09530;
  color: #fff;
}

.app-date-picker__footer {
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.app-date-picker__clear,
.app-date-picker__today {
  color: #9b7520;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

/* ==========================================================================
   Breakpoints — refinos
   ========================================================================== */

/* Telemóveis pequenos (≤ 360px). */
@media (max-width: 360px) {
  .app-topbar__inner {
    grid-template-columns: 2rem 1fr 2rem;
    padding: 0.55rem 0.75rem;
  }

  .app-icon-button {
    flex: 0 0 2rem !important;
    height: 2rem !important;
    max-height: 2rem !important;
    max-width: 2rem !important;
    width: 2rem !important;
  }

  .app-brand__title {
    font-size: 1rem;
  }
}

/* Desktop pequeno / tablets em retrato (≥ 1024px). */
@media (min-width: 1024px) {
  .app-topbar__inner {
    grid-template-columns: 2.5rem 1fr 2.5rem;
    min-height: 4rem;
  }

  .app-brand__logo {
    height: 3rem;
    width: 3rem;
  }

  .app-icon-button {
    flex: 0 0 2.5rem !important;
    height: 2.5rem !important;
    max-height: 2.5rem !important;
    max-width: 2.5rem !important;
    width: 2.5rem !important;
  }
}

/* Monitor grande (≥ 1280px). */
@media (min-width: 1280px) {
  .app-topbar__inner {
    min-height: 4.25rem;
  }
}

/* Telas muito largas (≥ 1536px): topbar e página continuam centradas mas com mais respiro. */
@media (min-width: 1536px) {
  .app-page {
    padding-left: clamp(2rem, 2.5vw, 3rem);
    padding-right: clamp(2rem, 2.5vw, 3rem);
  }
}
