/* ==========================================================================
   Sheet / Modal
   Mobile: "bottom sheet" que sobe da base (sensação de app).
   Desktop: modal centralizado.
   ========================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(40 28 18 / 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.overlay.is-open {
  opacity: 1;
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--surface-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  overflow: hidden;
}

.overlay.is-open .sheet {
  transform: none;
}

/* Alça visual do bottom sheet */
.sheet::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 3;
  width: 40px;
  height: 4px;
  margin-left: -20px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--primary-color) 22%, transparent);
}

.sheet--full {
  height: 100vh;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
}

.sheet--full::before {
  display: none;
}

.sheet__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 60px;
  padding: calc(var(--space-3) + var(--safe-top)) var(--space-3) var(--space-2);
  background: color-mix(in srgb, var(--surface-color) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sheet:not(.sheet--full) .sheet__header {
  padding-top: var(--space-5);
}

.sheet__title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sheet__header .icon-btn:only-of-type:last-child {
  margin-left: auto;
}

.sheet__left {
  display: flex;
  flex: none;
}

.sheet__spacer {
  display: block;
  width: 44px;
  flex: none;
}

.sheet__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-5) var(--space-6);
}

.sheet__footer {
  padding: var(--space-3) var(--space-5) calc(var(--space-4) + var(--safe-bottom));
  background: var(--surface-color);
  border-top: 1px solid var(--line-soft);
}

.sheet__footer:empty {
  display: none;
}

@media (min-width: 768px) {
  .overlay {
    align-items: center;
    padding: var(--space-6);
  }

  .sheet,
  .sheet--full {
    max-width: 560px;
    height: auto;
    max-height: min(88vh, 860px);
    border-radius: var(--radius-lg);
    transform: translateY(24px) scale(0.98);
    opacity: 0;
    transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur) var(--ease);
  }

  .sheet--full {
    height: min(88vh, 860px);
  }

  .sheet--wide {
    max-width: 760px;
  }

  .overlay.is-open .sheet {
    transform: none;
    opacity: 1;
  }

  .sheet::before {
    display: none;
  }

  .sheet__header,
  .sheet:not(.sheet--full) .sheet__header {
    padding-top: var(--space-3);
  }
}

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-4) + var(--safe-bottom));
  z-index: 300;
  display: grid;
  gap: var(--space-2);
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: #2E231A;
  color: #fff;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-out);
}

.toast svg {
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 1px;
}

.toast--success svg {
  color: #9BD1A1;
}

.toast--error svg {
  color: #F0A89C;
}

.toast.is-leaving {
  animation: toast-out var(--dur) var(--ease) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Diálogo de confirmação */
.confirm {
  padding: var(--space-2) 0 var(--space-2);
  text-align: center;
}

.confirm__title {
  margin-bottom: var(--space-2);
  font-size: var(--fs-xl);
}

.confirm__text {
  color: var(--text-muted);
}

.confirm__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
