/* ==========================================================================
   free校园助手 PWA - 浮层与全局组件样式
   uni.showToast / showLoading / showModal / previewImage 的 Web 实现
   以及 PWA 安装提示、离线提示、登录浮层
   ========================================================================== */

#uni-compat-root {
  position: relative;
  z-index: 10000;
}

/* -------------------------------- Toast -------------------------------- */
.uni-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  min-width: calc(240 * var(--rpx));
  max-width: 70vw;
  padding: calc(20 * var(--rpx)) calc(28 * var(--rpx));
  border-radius: calc(16 * var(--rpx));
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.uni-toast.is-show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.uni-toast__text {
  font-size: calc(26 * var(--rpx));
  line-height: 1.4;
  word-break: break-all;
}

.uni-toast__icon {
  display: none;
}

.uni-toast--icon .uni-toast__icon {
  display: block;
  font-size: calc(60 * var(--rpx));
  font-style: normal;
  line-height: 1;
  margin-bottom: calc(12 * var(--rpx));
}

.uni-toast--icon .uni-toast__icon.is-success {
  color: #4cd964;
}

/* ------------------------------- Loading ------------------------------- */
.uni-loading {
  position: fixed;
  inset: 0;
  background: transparent;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.uni-loading.is-show {
  display: flex;
}

.uni-loading__box {
  min-width: calc(240 * var(--rpx));
  padding: calc(30 * var(--rpx));
  border-radius: calc(16 * var(--rpx));
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(16 * var(--rpx));
}

.uni-loading__spinner {
  width: calc(56 * var(--rpx));
  height: calc(56 * var(--rpx));
  border: calc(5 * var(--rpx)) solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: uni-spin 0.8s linear infinite;
}

@keyframes uni-spin {
  to {
    transform: rotate(360deg);
  }
}

.uni-loading__text {
  font-size: calc(26 * var(--rpx));
}

/* -------------------------------- Modal -------------------------------- */
.uni-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(40 * var(--rpx));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.uni-modal.is-show {
  opacity: 1;
}

.uni-modal__box {
  width: 100%;
  max-width: calc(600 * var(--rpx));
  background: #fff;
  border-radius: calc(16 * var(--rpx));
  overflow: hidden;
  transform: scale(0.94);
  transition: transform 0.2s ease;
}

.uni-modal.is-show .uni-modal__box {
  transform: scale(1);
}

.uni-modal__title {
  padding: calc(40 * var(--rpx)) calc(30 * var(--rpx)) 0;
  font-size: calc(32 * var(--rpx));
  font-weight: bold;
  color: var(--color-text);
  text-align: center;
}

.uni-modal__content {
  padding: calc(24 * var(--rpx)) calc(30 * var(--rpx)) calc(30 * var(--rpx));
  font-size: calc(28 * var(--rpx));
  color: var(--color-text-sub);
  text-align: center;
  line-height: 1.5;
  word-break: break-all;
}

.uni-modal__input {
  margin: calc(24 * var(--rpx)) calc(30 * var(--rpx));
  padding: calc(16 * var(--rpx)) calc(20 * var(--rpx));
  font-size: calc(28 * var(--rpx));
  color: var(--color-text);
  border: calc(1 * var(--rpx)) solid #ebedf0;
  border-radius: calc(8 * var(--rpx));
  background: #fff;
  width: calc(100% - calc(60 * var(--rpx)));
  box-sizing: border-box;
}

.uni-modal__footer {
  display: flex;
  border-top: calc(1 * var(--rpx)) solid #ebedf0;
}

.uni-modal__btn {
  flex: 1;
  padding: calc(24 * var(--rpx)) 0;
  font-size: calc(30 * var(--rpx));
  text-align: center;
  cursor: pointer;
}

.uni-modal__btn--cancel {
  color: var(--color-text-sub);
  border-right: calc(1 * var(--rpx)) solid #ebedf0;
}

.uni-modal__btn--confirm {
  color: #07c160;
  font-weight: 500;
}

/* ---------------------------- ActionSheet ---------------------------- */
.uni-actionsheet {
  position: fixed;
  inset: 0;
  z-index: 10001;
}

.uni-actionsheet__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.uni-actionsheet.is-show .uni-actionsheet__mask {
  opacity: 1;
}

.uni-actionsheet__body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: var(--page-max-width, 100%);
  background: #f7f7f7;
  transform: translateY(100%);
  transition: transform 0.24s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.uni-actionsheet.is-show .uni-actionsheet__body {
  transform: translateY(0);
}

.uni-actionsheet__item,
.uni-actionsheet__cancel {
  padding: calc(26 * var(--rpx)) 0;
  font-size: calc(30 * var(--rpx));
  color: var(--color-text);
  text-align: center;
  background: #fff;
  cursor: pointer;
}

.uni-actionsheet__item {
  border-bottom: calc(1 * var(--rpx)) solid #ebedf0;
}

.uni-actionsheet__item:active {
  background: #f2f2f2;
}

.uni-actionsheet__cancel {
  margin-top: calc(12 * var(--rpx));
  color: var(--color-text-sub);
}

/* ------------------------------ 图片预览 ------------------------------ */
.uni-preview {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  cursor: zoom-out;
}

.uni-preview.is-show {
  opacity: 1;
}

.uni-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* --------------------------- PWA 安装提示条 --------------------------- */
.install-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  width: calc(100% - calc(30 * var(--rpx)));
  max-width: calc(470 * var(--rpx));
  bottom: calc(20 * var(--rpx) + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: calc(16 * var(--rpx));
  background: #fff;
  border-radius: calc(16 * var(--rpx));
  padding: calc(16 * var(--rpx)) calc(20 * var(--rpx));
  box-shadow: 0 calc(8 * var(--rpx)) calc(28 * var(--rpx)) rgba(0, 0, 0, 0.18);
  z-index: 9999;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.install-bar.is-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.install-bar__logo {
  width: calc(64 * var(--rpx));
  height: calc(64 * var(--rpx));
  border-radius: calc(14 * var(--rpx));
}

.install-bar__text {
  flex: 1;
  min-width: 0;
}

.install-bar__title {
  display: block;
  font-size: calc(26 * var(--rpx));
  font-weight: bold;
  color: var(--color-text);
}

.install-bar__desc {
  display: block;
  font-size: calc(20 * var(--rpx));
  color: var(--color-text-light);
}

.install-bar__btn {
  flex: 0 0 auto;
  font-size: calc(24 * var(--rpx));
  color: #fff;
  background: linear-gradient(135deg, var(--theme-from) 0%, var(--theme-to) 100%);
  border-radius: calc(20 * var(--rpx));
  padding: calc(8 * var(--rpx)) calc(22 * var(--rpx));
  cursor: pointer;
}

.install-bar__close {
  flex: 0 0 auto;
  font-size: calc(28 * var(--rpx));
  color: var(--color-text-light);
  cursor: pointer;
  padding: 0 calc(4 * var(--rpx));
}

/* ---------------------------- 离线条 ---------------------------- */
.net-status {
  position: fixed;
  left: 50%;
  transform: translate(-50%, -120%);
  top: calc(16 * var(--rpx) + env(safe-area-inset-top, 0px));
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: calc(22 * var(--rpx));
  border-radius: calc(20 * var(--rpx));
  padding: calc(8 * var(--rpx)) calc(24 * var(--rpx));
  z-index: 9998;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.net-status.is-show {
  transform: translate(-50%, 0);
}
