/* =========================================
   组件：Product Certificates Modal (产品证书弹窗)
   ========================================= */

/* --- 1. 前台正文上方的证书触发区 --- */
.mx-certificates-section {
    margin: 0 0 40px 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.mx-certs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.mx-certs-header h3 {
    font-size: 18px !important;
    font-weight: 700;
    margin: 0 !important;
    color: #111418;
    border-left: none !important;
    padding-left: 0 !important;
}

.mx-verified-icon {
    width: 18px;
    height: 18px;
}

.mx-certs-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

/* 证书卡片按钮 */
.mx-cert-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f0f6fc;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    min-width: 200px;
}

.mx-cert-card:hover {
    background: #e1effe;
    transform: translateY(-2px);
}

.mx-cert-card-icon img {
    width: 37px !important;  /* 👈 锁定宽度消除 CLS */
    height: 28px !important; /* 👈 锁定高度 */
    object-fit: contain;     /* 👈 保证所有长短不一的图标都在 37x28 盒子里完美缩放，绝不变形 */
}

.mx-cert-card-text h4 {
    margin: 0 0 2px 0 !important;
    font-size: 14px !important;
    font-weight: 700;
    color: #111418;
}

.mx-cert-card-text p {
    margin: 0 !important;
    font-size: 12px !important;
    color: #64748b;
}

/* --- 2. 弹窗基础框架 --- */
.mx-cert-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mx-cert-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.mx-cert-modal-box {
    position: relative;
    width: 90%;
    max-width: 900px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    z-index: 2;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 700px; /* 强制固定高度，解决切换时尺寸跳动的割裂感 */
    max-height: 85vh;
}

/* 弹窗头部 */
.mx-cert-modal-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 20px; /* 👈 原为：20px 24px 16px 24px，现改为统一 20px */
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.mx-mobile-title {
    display: none;
}

.mx-mobile-badge {
    display: none !important;
}

.mx-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 800;
    color: #111418;
}

.mx-info-icon {
    width: 18px;
    height: 18px;
    color: #64748b;
    cursor: help;
}

/* 弹窗关闭按钮 */
.mx-modal-close {
    position: absolute;
    right: 20px; /* 👈 原为：24px，配合 padding 改为 20px */
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.mx-modal-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* 弹窗内容区 */
.mx-cert-modal-body {
    padding: 0 20px 20px 20px; 
    overflow-y: auto;
    flex: 1; /* 让内容区自动伸展，填满下方固定高度 */
}

/* 顶部切换标签 (Tabs) */
.mx-cert-tabs {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 8px; /* 🔥 缩小标签之间的间距 (原12px) */
    padding: 24px 0 20px 0;
    border-bottom: none;
    margin-left: 0;
}

.mx-cert-tabs::-webkit-scrollbar {
    display: none !important; /* 🔥 彻底强制隐藏滚动条 */
    width: 0 !important;
    height: 0 !important;
}

.mx-cert-tab {
    padding: 4px 12px; /* 🔥 缩小按钮内部上下的留白，让按钮更小巧 (原6px 16px) */
    border: none !important;
    background: #f1f5f9 !important;
    border-radius: 16px; /* 🔥 圆角微调以适配更小的按钮 */
    font-size: 13px; /* 🔥 缩小字号 (原14px) */
    font-weight: 600; 
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap; 
    flex-shrink: 0; 
}

/* 🔥 新增：防止屏幕太小时，滑到最右侧 ISO 标签死死贴着右边框 */
.mx-cert-tab:last-child {
    margin-right: 12px; 
}

.mx-cert-tab:hover {
    background: #e2e8f0 !important;
}

.mx-cert-tab.active {
    background: transparent !important;
    color: #111418 !important;
    font-weight: 600 !important; /* 保持与默认一致的字重 */
    box-shadow: inset 0 0 0 1px #111418 !important;
}

@media (min-width: 769px) {
    .mx-cert-modal-header {
        justify-content: flex-start !important;
        border-bottom: 1px solid #f0f0f0 !important;
        padding-bottom: 20px !important; /* 👈 原为：16px !important */
    }
    
    .mx-cert-modal-body {
        display: grid;
        grid-template-columns: minmax(0, 50%) minmax(0, 1fr);
        grid-template-rows: max-content 1fr; /* 🔥 关键修复：将 auto 改为 max-content，强制第一行保持物理内容高度，绝对不允许被压扁 */
        gap: 0 40px;
        align-items: stretch;
        padding-top: 20px; 
    }
    .mx-cert-tabs {
        grid-column: 2;
        grid-row: 1;
        align-self: start; /* 🔥 关键修复：顶部对齐，解除网格强加的垂直拉伸，保护自身高度 */
        min-height: max-content; /* 🔥 增加硬性保底：无论屏幕多矮，高度绝不塌缩 */
        padding: 0 0 20px 0 !important; 
        margin-top: -4px; 
    }
    .mx-cert-panes, 
    .mx-cert-pane.active, 
    .mx-cert-layout {
        display: contents;
    }
    .mx-cert-layout-left {
        grid-column: 1;
        grid-row: 1 / span 2;
        animation: fadeIn 0.3s ease;
        margin-top: 0; /* 🔥 4. 清除负边距，严丝合缝贴合网格顶部 */
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    .mx-cert-image-frame {
        aspect-ratio: auto;
        height: 100%; /* 🔥 5. 高度 100% 填满左侧网格 */
        min-height: 520px; /* 给一个更大的保底高度 */
    }
    .mx-cert-layout-right {
        grid-column: 2;
        grid-row: 2;
        animation: fadeIn 0.3s ease;
        display: flex;
        flex-direction: column;
        justify-content: space-between; /* 🔥 6. 两端对齐！强制 AI 框沉底，与图片底部齐平 */
        height: 100%;
    }
}

/* 手机端降级排版 */
@media (max-width: 768px) {
    .mx-cert-panes {
        padding-top: 10px;
    }

    .mx-cert-pane {
        display: none;
    }

    .mx-cert-pane.active {
        display: block;
        animation: fadeIn 0.3s ease;
    }

    .mx-cert-layout {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
}

/* 基础面板显隐控制 */
.mx-cert-pane {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 4. 图片框与详情数据区 --- */
.mx-cert-image-frame {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

/* 🔥 新增：利用伪元素在底层植入 Loading 动画。(:has 确保只有真实的证书图才转圈，国内隐私和ISO面板不触发) */
.mx-cert-image-frame:has(.mx-dyn-img)::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin-top: -18px;
    margin-left: -18px;
    border: 3px solid #f1f5f9; /* 浅灰底环 */
    border-top-color: #1677ff; /* 品牌蓝转动环 */
    border-radius: 50%;
    animation: mx-spin 0.8s linear infinite;
    z-index: 0;
}

.mx-cert-image-frame img {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 4px;
    position: relative;
    z-index: 1; /* 🔥 关键：将图片层级置于转圈上方，加载完成后实体图片自动将其盖住 */
}

/* 🔥 新增：控制转圈的动画引擎 */
@keyframes mx-spin {
    to { transform: rotate(360deg); }
}

/* 数据列表 */
.mx-cert-details-list {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}
.mx-cert-detail-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    line-height: 1.5;
}

.mx-cert-detail-row:last-child {
    border-bottom: none;
}

.mx-cert-detail-label {
    color: #64748b;
    width: 140px;
    flex-shrink: 0;
}

.mx-cert-detail-value {
    color: #0f172a;
    font-weight: 500;
    flex-grow: 1;
    word-break: break-word;
}

/* 依托现有父级容器控制链接，常态继承文字颜色，仅下划线提示 */
.mx-cert-detail-value a {
    color: #0f172a; /* 🔥 强制颜色与普通文本绝对一致 */
    font-weight: 500; /* 🔥 强制字重为 500，取消加粗，大小和普通文本完全一样 */
    text-decoration: underline;
    text-decoration-color: #cbd5e1;
    text-underline-offset: 4px;
    transition: all 0.2s ease;
}

.mx-cert-detail-value a:hover {
    color: #1677ff;
    text-decoration-color: #1677ff;
}

/* AI 总结区 */
.mx-cert-ai-box {
    background: linear-gradient(180deg, #fff3e8 0%, #ffffff 100%) !important;
    border: none !important;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03), inset 0 0 0 1px rgba(255, 106, 0, 0.08) !important;
}

.mx-ai-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #c2410c;
    margin-bottom: 10px;
}

.mx-ai-content p {
    font-size: 13px !important;
    line-height: 1.6 !important;
    color: #431407;
    margin: 0 0 8px 0 !important;
}

.mx-ai-content p:last-child {
    margin-bottom: 0 !important;
}

/* --- 5. 极致移动端适配 (Alibaba 底端抽屉风格) --- */
@media (max-width: 768px) {
    .mx-certificates-section {
        padding: 0;
    }

    .mx-certs-grid {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
        scrollbar-width: none;
    }

    .mx-certs-grid::-webkit-scrollbar {
        display: none;
    }

    .mx-cert-card {
        flex-shrink: 0;
        width: 240px;
    }

    .mx-cert-modal-wrapper {
        align-items: flex-end !important;
    }

    .mx-cert-modal-box {
        width: 100% !important;
        max-width: 100% !important;
        height: 90vh !important; /* 手机端强制占满 90vh 屏高，消除高度差 */
        max-height: 90vh !important;
        border-radius: 24px 24px 0 0 !important;
        margin: 0 !important;
        animation: mxSlideUpModal 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .mx-cert-modal-header {
        position: relative;
        justify-content: center !important;
        padding: 25px 10px 10px 10px !important; /* 🔥 左右留白改为了 10px，并清理了重复的 padding-top */
        border-bottom: none !important;
    }

/* 🔥 新增：专门覆盖手机端内容区的左右留白为 10px */
    .mx-cert-modal-body {
        padding: 0 10px 20px 10px !important; 
    }

    /* 抽屉顶部灰色小把手 */
    .mx-cert-modal-header::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 4px;
    }

    .mx-cert-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-left: 0 !important;
        padding: 20px 0 5px 0 !important;
        scrollbar-width: none;
    }

    .mx-cert-tabs::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    .mx-cert-tab {
        flex-shrink: 0;
    }

    .mx-cert-layout {
        flex-direction: column;
        gap: 20px;
    }

    .mx-cert-layout-left {
        flex: 1;
        height: auto !important;
        margin-top: 0 !important;
    }

    .mx-cert-image-frame {
        padding: 20px;
        width: 100%;
        aspect-ratio: 1 / 1.35; /* 🔥 核心修复：按标准证书的纵横比提前占位 */
        min-height: 380px; /* 🔥 增加硬性保底高度，确保图片没出来前，架子也绝对不塌缩 */
    }

    .mx-modal-close {
        right: 10px !important; /* 🔥 配合全新的 10px 边界，让按钮对齐 */
    }

    .mx-desktop-title {
        display: none !important;
    }

    .mx-mobile-title {
        display: inline !important;
    }

    .mx-mobile-badge {
        display: flex !important;
    }
}

@keyframes mxSlideUpModal {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* --- 6. 幻灯片控制按钮 (箭头) --- */
.mx-cert-slide {
    display: none;
}

.mx-cert-slide.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.mx-slide-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 50% !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #111418 !important;
    padding: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s;
    z-index: 10;
}

.mx-slide-nav svg {
    width: 24px !important;
    height: 24px !important;
    stroke-width: 2.5 !important;
    stroke: #111418 !important;
}

.mx-slide-nav:hover {
    background: #f8fafc !important;
    color: #1677ff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-50%) scale(1.05);
}

.mx-slide-nav:hover svg {
    stroke: #1677ff !important;
}

.mx-slide-prev {
    left: 15px;
}

.mx-slide-next {
    right: 15px;
}

/* --- 7. 电脑端悬停放大器与操作按钮 --- */
@media (min-width: 993px) and (hover: hover) {
    .mx-cert-image-frame.is-zoomable {
        cursor: crosshair;
    }

    .mx-dyn-img {
        transition: opacity 0.15s ease-in-out, transform 0.1s ease-out !important;
    }

    .mx-cert-image-frame {
        overflow: hidden !important;
    }

    .mx-slide-nav {
        z-index: 20 !important;
    }
}

.mx-cert-layout-left a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background-color: var(--mx-text-dark, #1a1a1a);
    color: #ffffff;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    box-shadow: none;
    transition: background-color 0.3s ease;
}

.mx-cert-layout-left a:hover {
    background-color: #0056B3;
    box-shadow: none;
}