/* XSignsCartEditItem */

a.xsigns-edit-item {
    cursor: pointer;
    text-decoration: underline;
}

a.xsigns-edit-item:hover {
    opacity: 0.75;
}

/* ------------------------------------------------------------------
   /cart（Blocks 购物车）

   JS 把链接克隆进 .wc-block-cart-item__quantity，放在 Remove item 左边；
   原来 item_data 生成的那一条用 .xsigns-cei-source 藏掉。
   ------------------------------------------------------------------ */

.wc-block-components-product-details li.xsigns-cei-source {
    display: none !important;
}

/* 该容器原本是 column（数量选择器在上、Remove 在下），
   而数量选择器被 comun-woo 全局隐藏了，所以改成 row 不会留空位。
   只在我们插入过链接的容器上生效，不影响结算页等其它地方。

   选择器必须带上 table.wc-block-cart-items .wc-block-cart-items__row 这段前缀：
   WooCommerce 的 cart.css 里就是用这个层级设的 flex-direction: column，
   只写 .wc-block-cart-item__quantity.xsigns-cei-row 特异性不够，压不过它。 */
table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity.xsigns-cei-row {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

/* 与 Remove item 完全一致：12px/24px、下划线、无背景无边框无内距 */
a.xsigns-edit-item.xsigns-cei-inline {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-size: 12px;
    line-height: 24px;
    font-weight: 400;
    color: inherit;
    text-decoration: underline;
}

/* ------------------------------------------------------------------
   结算页的订单摘要里不要这个链接

   服务端已经在 is_checkout() 时不输出了（见 xsigns_cei_add_item_data），这一条
   是兜底：结算页上任何一次 Store API 往返（用优惠券、改地址、换配送方式）都会
   用返回的数据重渲染摘要，而那些请求直接打到 /wp-json，没有页面上下文，
   is_checkout() 在那里恒为 false，链接会被重新塞回来。

   只圈定结算区块：抽屉在结算页上照样能打开，那里的编辑入口应当保留。
   ------------------------------------------------------------------ */

.wp-block-woocommerce-checkout a.xsigns-edit-item {
    display: none !important;
}

/* ------------------------------------------------------------------
   betheme 侧边抽屉：链接跟在数量后面，与右侧的 Remove 左右呼应
   ------------------------------------------------------------------ */

/* 由 JS 搬进 .mfn-chpf-right，与 Remove 并排。
   字号/行高/颜色继承该格子，和 .mfn-chp-remove 一致；同样不要下划线。 */
.mfn-chpf-right a.xsigns-edit-item.xsigns-cei-sidecart {
    display: inline-block;
    margin: 0 16px 0 0;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    text-decoration: none;
}

/* 保险：让每个动作成为不可分割的整体。
   这两个链接都是「图标 + 空格 + 文字」，不加 nowrap 的话，一旦右列宽度不够，
   浏览器会优先从那个空格断开 —— 结果是垃圾桶图标独占一行、Remove 掉到下一行，
   比整体换行难看得多。文案改短后余量已经很足，这条只是兜底。 */
.mfn-chpf-right a.xsigns-edit-item.xsigns-cei-sidecart,
.mfn-chpf-right a.mfn-chp-remove {
    white-space: nowrap;
}

.mfn-chpf-right a.xsigns-edit-item.xsigns-cei-sidecart:hover {
    opacity: 0.7;
}

/* ------------------------------------------------------------------
   抽屉首屏空白期的加载提示

   内容由 mfnrefreshcart 这个 AJAX 后填（betheme js/woocommerce.js:1302）。
   主题自带 .mfn-cart-holder.loading 的样式，但它只在成功回调里移除、从不添加，
   所以这段时间抽屉里什么都没有。这里用自己的类补上。
   ------------------------------------------------------------------ */

.mfn-cart-holder.xsigns-cei-loading .mfn-ch-content {
    position: relative;
    min-height: 180px;
}

.mfn-cart-holder.xsigns-cei-loading .mfn-ch-content::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 28px;
    height: 28px;
    margin: -38px 0 0 -14px;
    border: 3px solid #ddd;
    border-top-color: #666;
    border-radius: 50%;
    animation: xsigns-cei-spin 0.8s linear infinite;
}

/* 文案由 JS 从 PHP 的 i18n 写进 data 属性，保持可翻译 */
.mfn-cart-holder.xsigns-cei-loading .mfn-ch-content::before {
    content: attr(data-xsigns-loading);
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    margin-top: 8px;
    text-align: center;
    font-size: 14px;
    color: #666;
}

/* 回填遮罩 */
.xsigns-cei-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
}

.xsigns-cei-overlay.xsigns-cei-hidden {
    display: none;
}

.xsigns-cei-box {
    background: #fff;
    border-radius: 6px;
    padding: 28px 36px;
    text-align: center;
    max-width: 320px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.xsigns-cei-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 14px;
    border: 3px solid #ddd;
    border-top-color: #666;
    border-radius: 50%;
    animation: xsigns-cei-spin 0.8s linear infinite;
}

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

.xsigns-cei-msg {
    margin: 0;
    font-size: 14px;
    color: #333;
}
