/*!
 * 修复 -ms-high-contrast 弃用警告
 * 将过时的 -ms-high-contrast 媒体查询替换为新的 Web 标准
 * 
 * Microsoft Edge 已弃用 -ms-high-contrast，推荐使用：
 * - forced-colors: active (强制颜色模式)
 * - prefers-contrast: high (高对比度偏好)
 * 
 * 参考: https://blogs.windows.com/msedgedev/2024/04/29/deprecating-ms-high-contrast/
 */

/* ========================================
   SweetAlert2 高对比度修复
   ======================================== */

/* 使用新的强制颜色模式标准 */
@media (forced-colors: active) {
  .swal2-popup {
    background: Canvas !important;
    color: CanvasText !important;
    border: 1px solid CanvasText !important;
  }
  
  .swal2-title {
    color: CanvasText !important;
  }
  
  .swal2-content {
    color: CanvasText !important;
  }
  
  .swal2-icon {
    border-color: CanvasText !important;
  }
  
  .swal2-confirm,
  .swal2-cancel {
    background: ButtonFace !important;
    color: ButtonText !important;
    border: 1px solid ButtonText !important;
  }
  
  .swal2-confirm:hover,
  .swal2-cancel:hover {
    background: Highlight !important;
    color: HighlightText !important;
  }
  
  .swal2-toast .swal2-icon::before {
    font-size: .25em;
  }
  
  .swal2-container .swal2-modal {
    margin: 0 !important;
  }
}

/* 使用高对比度偏好标准 */
@media (prefers-contrast: high) {
  .swal2-popup {
    border: 2px solid #000 !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.5) !important;
  }
  
  .swal2-title {
    font-weight: bold !important;
    color: #000 !important;
  }
  
  .swal2-content {
    color: #000 !important;
  }
  
  .swal2-confirm {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #000 !important;
  }
  
  .swal2-cancel {
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #000 !important;
  }
  
  .swal2-toast .swal2-icon::before {
    font-size: .25em;
  }
  
  .swal2-container .swal2-modal {
    margin: 0 !important;
  }
}

/* ========================================
   Bootstrap Toast 高对比度修复
   ======================================== */

/* 替换过时的 -ms-high-contrast 媒体查询 */
@media (forced-colors: active) {
  .toast-bs-container {
    position: fixed !important;
    background: Canvas !important;
    color: CanvasText !important;
    border: 1px solid CanvasText !important;
  }
}

@media (prefers-contrast: high) {
  .toast-bs-container {
    position: fixed !important;
    border: 2px solid #000 !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.5) !important;
  }
}

/* ========================================
   导航栏高对比度修复
   ======================================== */

@media (min-width: 1200px) and (forced-colors: active) {
  body:not([data-col="1-columns"]) {
    /* 针对强制颜色模式的样式 */
    background: Canvas !important;
    color: CanvasText !important;
  }
}

@media (min-width: 1200px) and (prefers-contrast: high) {
  body:not([data-col="1-columns"]) {
    /* 针对高对比度偏好的样式 */
    background: #fff !important;
    color: #000 !important;
  }
}

/* ========================================
   表单高对比度修复
   ======================================== */

@media (forced-colors: active) {
  .form-control,
  .form-select,
  .form-check-input {
    background: Field !important;
    color: FieldText !important;
    border: 1px solid FieldText !important;
  }
  
  .form-control:focus,
  .form-select:focus {
    border-color: Highlight !important;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25) !important;
  }
}

@media (prefers-contrast: high) {
  .form-control,
  .form-select,
  .form-check-input {
    border: 2px solid #000 !important;
    background: #fff !important;
    color: #000 !important;
  }
  
  .form-control:focus,
  .form-select:focus {
    border-color: #000 !important;
    box-shadow: 0 0 0 0.2rem rgba(0,0,0,.25) !important;
  }
}

/* ========================================
   TinyMCE 编辑器高对比度修复
   ======================================== */

@media (forced-colors: active) {
  .mce-content-body {
    background: Canvas !important;
    color: CanvasText !important;
  }
  
  .mce-content-body .mce-item-anchor {
    border: 1px solid CanvasText !important;
  }
}

@media (prefers-contrast: high) {
  .mce-content-body {
    background: #fff !important;
    color: #000 !important;
  }
  
  .mce-content-body .mce-item-anchor {
    border: 2px solid #000 !important;
  }
}

/* ========================================
   通用高对比度修复
   ======================================== */

/* 为所有可能使用 -ms-high-contrast 的元素提供现代替代方案 */
@media (forced-colors: active) {
  * {
    /* 使用系统颜色确保在强制颜色模式下正确显示 */
    forced-color-adjust: auto;
  }
}

@media (prefers-contrast: high) {
  /* 提高所有文本的对比度 */
  body {
    background: #fff !important;
    color: #000 !important;
  }
  
  a {
    color: #0000EE !important;
  }
  
  a:visited {
    color: #551A8B !important;
  }
}

/* ========================================
   开发者提示注释
   ======================================== */

/*
使用说明：
1. 这个文件修复了项目中 -ms-high-contrast 的弃用警告
2. 使用了新的 Web 标准：forced-colors 和 prefers-contrast
3. 覆盖了 Dcat Admin、SweetAlert2、TinyMCE 等组件的旧样式
4. 在HTML模板中引入此文件即可生效

更新组件版本时的注意事项：
- Dcat Laravel Admin: 更新到支持新标准的版本
- SweetAlert2: 更新到 v11.0.0+ 版本
- TinyMCE: 更新到 v6.0+ 版本

Microsoft官方迁移指南：
https://blogs.windows.com/msedgedev/2024/04/29/deprecating-ms-high-contrast/
*/
