/**
 * 替代浏览器原生 alert/confirm/prompt
 */

/* 弹窗遮罩层 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(17, 28, 27, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 弹窗容器 */
.modal-container {
  background: linear-gradient(145deg, #1F2E2D 0%, #182422 100%);
  border: 1px solid rgba(94, 234, 212, 0.15);
  border-radius: 16px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(94, 234, 212, 0.05),
    0 0 30px rgba(94, 234, 212, 0.1);
  min-width: 360px;
  max-width: 480px;
  width: 90%;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.3s ease;
  overflow: hidden;
  position: relative;
}

.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* 弹窗头部装饰线 */
.modal-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    #5EEAD4 20%, 
    #99F6E4 50%, 
    #5EEAD4 80%, 
    transparent 100%
  );
  opacity: 0.8;
}

/* 弹窗头部 */
.modal-header {
  padding: 24px 24px 16px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.modal-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  opacity: 0.15;
}

/* 不同类型图标样式 */
.modal-icon.info {
  color: #5EEAD4;
}
.modal-icon.info::before {
  background: #5EEAD4;
}

.modal-icon.success {
  color: #2DD4BF;
}
.modal-icon.success::before {
  background: #2DD4BF;
}

.modal-icon.warning {
  color: #FBBF24;
}
.modal-icon.warning::before {
  background: #FBBF24;
}

.modal-icon.error {
  color: #F87171;
}
.modal-icon.error::before {
  background: #F87171;
}

.modal-icon.confirm {
  color: #99F6E4;
}
.modal-icon.confirm::before {
  background: #99F6E4;
}

.modal-icon svg {
  width: 24px;
  height: 24px;
  position: relative;
  z-index: 1;
}

/* 标题区域 */
.modal-title-wrap {
  flex: 1;
  min-width: 0;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #D1FAE5;
  margin: 0 0 6px 0;
  line-height: 1.4;
}

.modal-subtitle {
  font-size: 0.875rem;
  color: rgba(209, 250, 229, 0.6);
  margin: 0;
  line-height: 1.5;
}

/* 关闭按钮 */
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(94, 234, 212, 0.08);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(209, 250, 229, 0.6);
  transition: all 0.2s ease;
  padding: 0;
}

.modal-close:hover {
  background: rgba(94, 234, 212, 0.15);
  color: #D1FAE5;
  transform: rotate(90deg);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

/* 弹窗内容 */
.modal-body {
  padding: 0 24px 20px;
}

.modal-message {
  font-size: 0.9375rem;
  color: rgba(209, 250, 229, 0.85);
  line-height: 1.7;
  margin: 0;
}

/* 输入框样式 */
.modal-input-wrap {
  margin-top: 16px;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(17, 28, 27, 0.6);
  border: 1px solid rgba(94, 234, 212, 0.15);
  border-radius: 10px;
  color: #D1FAE5;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.modal-input:focus {
  outline: none;
  border-color: #5EEAD4;
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.1);
}

.modal-input::placeholder {
  color: rgba(209, 250, 229, 0.4);
}

/* 弹窗底部 */
.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-footer.center {
  justify-content: center;
}

/* 按钮样式 */
.modal-btn {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.modal-btn-primary {
  background: linear-gradient(135deg, #5EEAD4 0%, #2DD4BF 100%);
  color: #111C1B;
}

.modal-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(94, 234, 212, 0.3);
}

.modal-btn-secondary {
  background: rgba(94, 234, 212, 0.08);
  color: #D1FAE5;
  border: 1px solid rgba(94, 234, 212, 0.15);
}

.modal-btn-secondary:hover {
  background: rgba(94, 234, 212, 0.15);
  border-color: rgba(94, 234, 212, 0.25);
}

.modal-btn-danger {
  background: linear-gradient(135deg, #F87171 0%, #EF4444 100%);
  color: white;
}

.modal-btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(248, 113, 113, 0.3);
}

/* 加载动画 */
.modal-loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(17, 28, 27, 0.3);
  border-top-color: #111C1B;
  border-radius: 50%;
  animation: modal-spin 0.8s linear infinite;
}

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

/* Toast 提示 */
.modal-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.modal-toast {
  background: linear-gradient(145deg, #1F2E2D 0%, #182422 100%);
  border: 1px solid rgba(94, 234, 212, 0.15);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(94, 234, 212, 0.05);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.3s ease;
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
}

.modal-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.modal-toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-toast-icon.success {
  background: rgba(45, 212, 191, 0.15);
  color: #2DD4BF;
}

.modal-toast-icon.error {
  background: rgba(248, 113, 113, 0.15);
  color: #F87171;
}

.modal-toast-icon.warning {
  background: rgba(251, 191, 36, 0.15);
  color: #FBBF24;
}

.modal-toast-icon.info {
  background: rgba(94, 234, 212, 0.15);
  color: #5EEAD4;
}

.modal-toast-content {
  flex: 1;
}

.modal-toast-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #D1FAE5;
  margin: 0 0 4px 0;
}

.modal-toast-message {
  font-size: 0.8125rem;
  color: rgba(209, 250, 229, 0.7);
  margin: 0;
}

.modal-toast-close {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: rgba(209, 250, 229, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-toast-close:hover {
  background: rgba(94, 234, 212, 0.1);
  color: #D1FAE5;
}

/* 进度条 */
.modal-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #5EEAD4, #2DD4BF);
  border-radius: 0 0 0 12px;
  transition: width linear;
}

/* 响应式适配 */
@media (max-width: 640px) {
  .modal-container {
    min-width: auto;
    max-width: calc(100vw - 32px);
    width: calc(100vw - 32px);
    margin: 16px;
  }
  
  .modal-header {
    padding: 20px 20px 12px;
  }
  
  .modal-body {
    padding: 0 20px 16px;
  }
  
  .modal-footer {
    padding: 0 20px 20px;
    flex-direction: column-reverse;
  }
  
  .modal-btn {
    width: 100%;
    justify-content: center;
  }
  
  .modal-toast-container {
    left: 16px;
    right: 16px;
    top: 16px;
  }
  
  .modal-toast {
    max-width: none;
    width: 100%;
  }
}

/* 动画关键帧 */
@keyframes modal-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.modal-container.shake {
  animation: modal-shake 0.5s ease;
}

/* 暗色模式适配（项目本身已是暗色主题） */
@media (prefers-color-scheme: dark) {
  .modal-container {
    background: linear-gradient(145deg, #1F2E2D 0%, #182422 100%);
  }
}

/* 无障碍支持 */
.modal-overlay:focus {
  outline: none;
}

.modal-btn:focus-visible {
  outline: 2px solid #5EEAD4;
  outline-offset: 2px;
}

.modal-input:focus-visible {
  outline: 2px solid #5EEAD4;
  outline-offset: 2px;
}

/* 禁用状态 */
.modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* 图标动画 */
@keyframes modal-icon-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.modal-icon svg {
  animation: modal-icon-pulse 2s ease-in-out infinite;
}
