/* 通知系统样式 */

.notification-container {
  position: fixed;
  top: max(16px, calc(env(safe-area-inset-top, 0px) + 12px));
  right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px));
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  pointer-events: none;
}

.notification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-md, 12px);
  box-shadow: var(--shadow-lg, 0 8px 28px rgba(0,0,0,0.18));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  transition: transform var(--transition-base, 240ms var(--ease-out, cubic-bezier(.2,.8,.2,1))),
              opacity var(--transition-base, 240ms var(--ease-out, cubic-bezier(.2,.8,.2,1)));
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

.notification.hide {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
}

.notification-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.notification-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.notification-message {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

.notification-close {
  background: none;
  border: none;
  padding: 4px;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  transition: opacity var(--transition-fast, 160ms);
  flex-shrink: 0;
  border-radius: 4px;
}

.notification-close:hover {
  opacity: 1;
}

.notification-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* 通知类型样式 */
.notification-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
  color: white;
}

.notification-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95));
  color: white;
}

.notification-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.95));
  color: white;
}

.notification-info {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(139, 92, 246, 0.95));
  color: white;
}

/* 响应式 + 安全区 */
@media (max-width: 768px) {
  .notification-container {
    top: max(10px, calc(env(safe-area-inset-top, 0px) + 8px));
    right: max(10px, calc(env(safe-area-inset-right, 0px) + 8px));
    left: max(10px, calc(env(safe-area-inset-left, 0px) + 8px));
    max-width: none;
  }

  .notification {
    padding: 14px 16px;
    transform: translateY(calc(-100% - 16px));
  }

  .notification.show {
    transform: translateY(0);
  }

  .notification.hide {
    transform: translateY(calc(-100% - 16px));
  }

  .notification-message {
    font-size: 14px;
  }
}

/* 减少动效 */
@media (prefers-reduced-motion: reduce) {
  .notification {
    transition: none !important;
  }

  .notification.show {
    transform: none;
    opacity: 1;
  }

  .notification.hide {
    display: none;
  }
}

/* 网络状态指示器 */
.network-status {
    position: fixed;
    top: max(16px, calc(env(safe-area-inset-top, 0px) + 12px));
    right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px));
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform var(--transition-base, 240ms ease);
}

.network-status.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.network-status.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.network-status.fade-in {
    transform: translateX(0);
}

.network-status.fade-out {
    transform: translateX(100%);
}

.update-notification {
    position: fixed;
    bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px));
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
    z-index: 10000;
    max-width: min(300px, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
}

/* 限定在更新提示内，避免覆盖通用 .notification-content */
.update-notification .notification-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* 加载状态样式 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base, 240ms ease);
}

.loading-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.loading-content p {
    margin: 0;
    color: #6b7280;
    font-weight: 500;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary, #6366f1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  .loading-overlay {
    background: rgba(0, 0, 0, 0.65);
  }

  .loading-content {
    background: #1e1e1e;
    color: #e9ecef;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.45);
  }

  .loading-content p {
    color: #adb5bd;
  }

  .loading-spinner {
    border-color: #333;
    border-top-color: var(--primary, #8b5cf6);
  }
}
