// 全局提示组件样式
.gp-container {
  // 基础层级定义 - 统一管理z-index层级
  $z-index-backdrop: 10000;
  $z-index-modal: 10001;
  $z-index-toast: 10002;

  // 全屏模式背景遮罩 - 优化position:fixed布局
  .gp-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: $z-index-backdrop;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem; // 确保在所有设备上都有适当的边距
    transition: all 0.3s ease;
    
    // 强制所有设备都使用相同的居中布局
    @media (max-width: 640px) {
      padding: 1rem;
      align-items: center; // 确保移动端也完全居中
    }
    
    @media (min-width: 641px) and (max-width: 1024px) {
      padding: 1.5rem;
      align-items: center; // 确保平板端也完全居中
    }
    
    @media (min-width: 1025px) {
      padding: 2rem;
      align-items: center; // 确保桌面端也完全居中
    }
    
    &.gp-backdrop-visible {
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(4px);
    }
  }

  // 模态框背景遮罩 - 增强视觉效果
  .gp-modal-backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
  }

  // 全屏模式模态框 - 优化居中布局和响应式设计
  .gp-modal {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 90vw;
    max-height: 80vh; // 限制最大高度，避免内容溢出
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
    margin: 0; // 移除所有边距，完全依赖flex居中
    transform-origin: center; // 确保动画从中心开始
    
    &.gp-modal-dialog {
      min-width: 320px;
      width: 100%;
      max-width: 500px; // 设置合理的最大宽度
    }

    // 响应式调整 - 确保在所有设备上都能正确显示
    @media (max-width: 640px) {
      max-width: calc(100vw - 2rem); // 保持左右边距
      max-height: 75vh; // 移动端稍微降低高度
      border-radius: 12px;
      margin: 0; // 确保无边距
    }
    
    @media (min-width: 641px) and (max-width: 1024px) {
      max-width: 85vw;
      max-height: 78vh;
      margin: 0; // 确保无边距
    }
    
    @media (min-width: 1025px) {
      max-width: 600px;
      max-height: 80vh;
      margin: 0; // 确保无边距
    }

    .gp-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 24px 16px;
      border-bottom: 1px solid #f1f5f9;

      .gp-title {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #1e293b;
        
        @media (max-width: 640px) {
          font-size: 16px;
        }
      }

      .gp-close-btn {
        background: none;
        border: none;
        padding: 4px;
        cursor: pointer;
        color: #64748b;
        border-radius: 4px;
        transition: all 0.2s ease;
        flex-shrink: 0; // 防止按钮被压缩

        &:hover {
          background: #f1f5f9;
          color: #334155;
        }
      }
    }

    .gp-content {
      padding: 20px 24px;
      text-align: center;
      overflow-y: auto; // 允许内容滚动
      max-height: calc(80vh - 140px); // 确保内容区域不会溢出
      
      // 自定义滚动条样式
      &::-webkit-scrollbar {
        width: 6px;
      }
      
      &::-webkit-scrollbar-track {
        background: transparent;
      }
      
      &::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
        
        &:hover {
          background: rgba(0, 0, 0, 0.3);
        }
      }

      &.gp-modal-content {
        text-align: left;
        min-height: 60px;
      }

      .gp-icon {
        margin-bottom: 16px;
        
        &.text-green-500 { color: #22c55e; }
        &.text-blue-500 { color: #3b82f6; }
        &.text-orange-500 { color: #f97316; }
        &.text-red-500 { color: #ef4444; }
      }

      .gp-message {
        font-size: 16px;
        line-height: 1.5;
        color: #475569;
        margin: 0;
        
        @media (max-width: 640px) {
          font-size: 14px;
        }
      }
    }

    .gp-actions {
      padding: 16px 24px 20px;
      display: flex;
      gap: 12px;
      justify-content: flex-end;
      flex-shrink: 0; // 防止按钮区域被压缩
      
      @media (max-width: 640px) {
        flex-direction: column-reverse; // 移动端垂直排列按钮
        gap: 8px;
      }

      .gp-action-btn {
        padding: 10px 20px;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        border: 1px solid transparent;
        
        @media (max-width: 640px) {
          width: 100%; // 移动端按钮全宽
          justify-content: center;
        }

        &.gp-btn-primary {
          background: #3b82f6;
          color: white;
          
          &:hover {
            background: #2563eb;
          }
        }

        &.gp-btn-secondary {
          background: #f8fafc;
          color: #64748b;
          border-color: #e2e8f0;
          
          &:hover {
            background: #f1f5f9;
            color: #475569;
          }
        }
      }
    }
  }

  // 角落提示模式 - 优化position:fixed定位
  .gp-toast {
    position: fixed;
    z-index: $z-index-toast;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    animation: toastSlideIn 0.3s ease-out;
    max-width: 400px;
    min-width: 300px;

    .gp-toast-content {
      display: flex;
      align-items: flex-start;
      padding: 16px;
      gap: 12px;

      .gp-toast-icon {
        flex-shrink: 0;
        margin-top: 2px;
        
        &.text-green-500 { color: #22c55e; }
        &.text-blue-500 { color: #3b82f6; }
        &.text-orange-500 { color: #f97316; }
        &.text-red-500 { color: #ef4444; }
      }

      .gp-toast-text {
        flex: 1;
        min-width: 0;

        .gp-toast-title {
          font-size: 14px;
          font-weight: 600;
          color: #1e293b;
          margin-bottom: 4px;
        }

        .gp-toast-message {
          font-size: 13px;
          color: #64748b;
          line-height: 1.4;
        }
      }

      .gp-toast-close {
        background: none;
        border: none;
        padding: 2px;
        cursor: pointer;
        color: #94a3b8;
        border-radius: 4px;
        transition: all 0.2s ease;
        flex-shrink: 0;

        &:hover {
          background: #f1f5f9;
          color: #64748b;
        }
      }
    }
  }

  // 尺寸变体
  .gp-size-small {
    &.gp-modal {
      .gp-header { padding: 16px 20px 12px; }
      .gp-content { padding: 16px 20px; }
      .gp-actions { padding: 12px 20px 16px; }
      .gp-title { font-size: 16px; }
      .gp-message { font-size: 14px; }
    }
    
    &.gp-toast {
      min-width: 250px;
      .gp-toast-content { padding: 12px; }
    }
  }

  // .gp-size-medium 使用默认尺寸，无需额外样式定义

  .gp-size-large {
    &.gp-modal {
      .gp-header { padding: 24px 28px 20px; }
      .gp-content { padding: 24px 28px; }
      .gp-actions { padding: 20px 28px 24px; }
      .gp-title { font-size: 20px; }
      .gp-message { font-size: 18px; }
    }
    
    &.gp-toast {
      min-width: 350px;
      .gp-toast-content { padding: 20px; }
    }
  }

  // 位置变体 - 优化fixed定位
  .gp-position-top-right {
    top: 20px;
    right: 20px;
  }

  .gp-position-bottom-right {
    bottom: 20px;
    right: 20px;
  }

  .gp-position-top-left {
    top: 20px;
    left: 20px;
  }

  .gp-position-bottom-left {
    bottom: 20px;
    left: 20px;
  }

  // 响应式调整 - 优化移动端体验
  @media (max-width: 640px) {
    .gp-modal {
      margin: 0; // 移除边距，完全依赖backdrop的padding
      max-width: calc(100vw - 2rem);
      
      .gp-header, .gp-content, .gp-actions {
        padding-left: 20px;
        padding-right: 20px;
      }
    }

    .gp-toast {
      left: 16px !important;
      right: 16px !important;
      max-width: none;
      min-width: 0;
      
      &.gp-position-top-right,
      &.gp-position-top-left {
        top: 16px;
      }
      
      &.gp-position-bottom-right,
      &.gp-position-bottom-left {
        bottom: 16px;
      }
    }
  }
}

// 动画定义 - 优化动画效果
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}