/* =============================================================
 * H5 全局交互层：轻提示 Toast + 二次确认 Dialog
 * 由 routes/app.php 注入，全部 /app/* 页面共用。
 * 目标：替代浏览器原生 alert/confirm，统一成可预期的产品级反馈。
 * ============================================================= */

/* ---------- 轻提示：顶部居中、短暂出现，不阻塞操作 ---------- */
.app-toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  z-index: 10050;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(86vw, 420px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(32, 30, 28, .94);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  letter-spacing: .01em;
  box-shadow: 0 10px 28px rgba(16, 14, 12, .22);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px);
  animation: app-toast-in .18s ease-out forwards,
             app-toast-out .18s ease-in 1.82s forwards;
}
.app-toast::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: #e3bf7e;
}
.app-toast--success::before { background: #86c9a3; }
.app-toast--error::before { background: #ff8a78; }
.app-toast--info::before { background: #e3bf7e; }

@keyframes app-toast-in {
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes app-toast-out {
  to { opacity: 0; transform: translate(-50%, -6px); }
}

/* ---------- 横向筛选：右缘渐隐，提示还能继续滑 ---------- */
html.h5-app .app-hscroll {
  padding-right: 34px !important;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent 100%);
}

/* ---------- 二次确认：删除、拉黑等不可逆操作 ---------- */
html.app-dialog-open,
html.app-dialog-open body {
  overflow: hidden;
  height: 100%;
}

.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(22, 22, 24, .46);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: app-dialog-fade .16s ease-out both;
}

.app-dialog__panel {
  width: min(100%, 340px);
  padding: 24px 20px 0;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(18, 16, 14, .26);
  text-align: center;
  animation: app-dialog-rise .2s cubic-bezier(.2, .7, .3, 1) both;
}

.app-dialog__badge {
  width: 38px;
  height: 38px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8efec;
  color: #a73a2f;
}
.app-dialog__badge svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-dialog__badge--danger { background: #fbecea; color: #b23528; }

.app-dialog__title {
  margin: 0;
  color: #292521;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: .01em;
}

.app-dialog__message {
  margin: 9px 0 22px;
  color: #6d655d;
  font-size: 13.5px;
  line-height: 1.7;
  text-align: center;
}

.app-dialog__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 -20px;
  border-top: 1px solid #eee9e3;
}

.app-dialog__btn {
  height: 49px;
  border: 0;
  background: #fff;
  color: #6d655d;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .14s ease, color .14s ease;
}
.app-dialog__btn:active { background: #f6f2ed; }
.app-dialog__btn:focus { outline: none; }
.app-dialog__btn:focus-visible { box-shadow: inset 0 0 0 2px rgba(178, 53, 40, .26); }
.app-dialog__btn--cancel { border-right: 1px solid #eee9e3; }
.app-dialog__btn--confirm { color: #b23528; }
.app-dialog__btn--confirm.is-danger:active { background: #fbf0ee; }

@keyframes app-dialog-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes app-dialog-rise {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .app-toast,
  .app-dialog,
  .app-dialog__panel {
    animation: none;
  }
  .app-toast { opacity: 1; }
}
