/* =========================================================
   WooCommerce Wholesale Cart & Checkout Optimizer (Flatsome)
   自动继承 Flatsome 原生 CSS 变量 (--primary-color)
   ========================================================= */

/* 1. 保持表格单元格原生属性，避免撑破 Flatsome 两栏布局 */
.woocommerce-cart-form table.shop_table td.actions {
    display: table-cell !important;
    padding-top: 16px !important;
    text-align: left !important;
}

/* 清除 Flatsome 自带的浮动与外边距 */
.woocommerce-cart-form td.actions .continue-shopping,
.wc-wco-cart-actions-group {
    display: inline !important;
    float: none !important;
}

.woocommerce-cart-form td.actions .continue-shopping .button,
.woocommerce-cart-form td.actions button[name="update_cart"],
.wc-wco-cart-actions-group .button {
    float: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    line-height: 1;
    vertical-align: middle;
}

/* 桌面端通过双列定宽实现 2x2 网格对齐，不破坏 table-cell 宽度 */
@media (min-width: 768px) {
    .woocommerce-cart-form td.actions .continue-shopping .button,
    .wc-wco-cart-actions-group .wc-wco-open-modal-btn {
        margin: 0 10px 10px 0 !important;
        min-width: 215px;
    }

    .wc-wco-cart-actions-group .wc-wco-clear-cart-btn,
    .woocommerce-cart-form td.actions button[name="update_cart"] {
        margin: 0 10px 0 0 !important;
        min-width: 215px;
    }

    /* 强制在第二个按钮后换行：第一行(添加更多 + 快速清单)，第二行(清除购物车 + 更新购物车) */
    .wc-wco-cart-actions-group .wc-wco-open-modal-btn::after {
        content: "";
    }
}

.wc-wco-checkout-summary-bar .button,
.wc-wco-footer-actions .button,
.wc-wco-confirm-footer .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 0 !important;
}

.wc-wco-icon {
    flex-shrink: 0;
}

/* 清空购物车按钮：采用警示红描边，悬停反白，避免批发误触 */
.wc-wco-clear-cart-btn {
    border-color: #d9534f !important;
    color: #d9534f !important;
}

.wc-wco-clear-cart-btn:hover {
    background-color: #d9534f !important;
    border-color: #d9534f !important;
    color: #ffffff !important;
}

/* 2. 结账页 YOUR ORDER 标题正下方按钮容器与上下间距 */
.wc-wco-checkout-summary-bar {
    margin: 12px 0 18px 0;
    padding-bottom: 14px;
    border-bottom: 1px solid #ececec;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* 3. 弹窗遮罩与居中容器 */
.wc-wco-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.62);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
}

.wc-wco-modal-dialog {
    background: #ffffff;
    width: 100%;
    max-width: 560px;
    max-height: 82vh;
    border-radius: 6px;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wcWcoFadeIn 0.18s ease-out;
}

@keyframes wcWcoFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 弹窗头部：顶部边条继承 Flatsome 主题主色 */
.wc-wco-modal-header {
    padding: 15px 20px;
    border-top: 4px solid var(--primary-color, #446084);
    border-bottom: 1px solid #ececec;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wc-wco-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #111827;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.wc-wco-close-modal-btn:not(.button),
.wc-wco-close-confirm-btn:not(.button) {
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s ease;
}

.wc-wco-close-modal-btn:not(.button):hover,
.wc-wco-close-confirm-btn:not(.button):hover {
    color: #111827;
}

/* 弹窗主体滚动区 */
.wc-wco-modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1;
}

.wc-wco-empty-msg {
    text-align: center;
    color: #6b7280;
    margin: 24px 0;
}

/* 4. 父级产品聚合卡片 */
.wc-wco-product-group {
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    margin-bottom: 14px;
    overflow: hidden;
}

.wc-wco-product-group:last-child {
    margin-bottom: 0;
}

.wc-wco-group-header {
    background: #f3f4f6;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.wc-wco-parent-title {
    font-weight: 700;
    font-size: 14px;
    color: #1f2937;
    line-height: 1.35;
}

/* 父级数量汇总徽章：自动继承 Flatsome 主题主色 */
.wc-wco-parent-badge {
    background: var(--primary-color, #446084);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

/* 变体分行列表 */
.wc-wco-variant-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff;
}

.wc-wco-variant-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 8px 22px;
    border-top: 1px solid #f3f4f6;
    font-size: 13.5px;
    color: #4b5563;
    margin: 0 !important;
}

.wc-wco-variant-name {
    position: relative;
}

.wc-wco-variant-name::before {
    content: "•";
    position: absolute;
    left: -11px;
    color: #9ca3af;
}

.wc-wco-variant-qty {
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    margin-left: 12px;
}

/* 5. 弹窗底部总计与操作栏 */
.wc-wco-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #ececec;
    background: #f9fafb;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.wc-wco-grand-total {
    font-size: 15px;
    color: #111827;
}

.wc-wco-grand-total strong {
    font-size: 17px;
    color: var(--primary-color, #446084);
    margin-left: 4px;
}

.wc-wco-footer-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* 6. 清空购物车富文本警示确认弹窗专属样式 */
.wc-wco-confirm-dialog {
    max-width: 460px;
}

.wc-wco-confirm-header {
    border-top-color: #d9534f;
}

.wc-wco-warn-icon {
    flex-shrink: 0;
}

.wc-wco-confirm-body {
    font-size: 14.5px;
    line-height: 1.65;
    color: #374151;
}

.wc-wco-confirm-body p {
    margin-bottom: 10px;
}

.wc-wco-confirm-body p:last-child {
    margin-bottom: 0;
}

.wc-wco-confirm-footer {
    justify-content: flex-end;
}

.wc-wco-confirm-footer .wc-wco-close-confirm-btn.button {
    color: #4b5563 !important;
    border-color: #d1d5db !important;
}

.wc-wco-confirm-footer .wc-wco-close-confirm-btn.button:hover {
    background-color: #f3f4f6 !important;
    color: #111827 !important;
}

.wc-wco-proceed-clear-btn {
    background-color: #d9534f !important;
    border-color: #d9534f !important;
    color: #ffffff !important;
}

.wc-wco-proceed-clear-btn:hover {
    background-color: #c9302c !important;
    border-color: #c9302c !important;
    color: #ffffff !important;
}

/* 7. 手机端适配（<= 767px）：一行一个按钮，全宽堆叠 */
@media (max-width: 767px) {
    .woocommerce-cart-form td.actions .continue-shopping .button,
    .woocommerce-cart-form td.actions button[name="update_cart"],
    .wc-wco-cart-actions-group .button {
        display: flex !important;
        width: 100% !important;
        margin: 0 0 10px 0 !important;
    }

    .woocommerce-cart-form td.actions button[name="update_cart"] {
        margin-bottom: 0 !important;
    }
}

/* =========================================================
   二级副标题分组样式（附加选项作为主标题下的二级分组标题）
   ========================================================= */
.wc-wco-subgroup-header {
    background: #fafafa;
    padding: 7px 14px 7px 18px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.wc-wco-subgroup-title {
    font-weight: 700;
    color: var(--primary-color, #446084);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wc-wco-subgroup-title::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background-color: var(--primary-color, #446084);
}

.wc-wco-subgroup-qty {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

/* 当存在二级副标题时，其下方的变体列表适当增加左侧缩进以体现层级 */
.wc-wco-subgroup-header + .wc-wco-variant-list .wc-wco-variant-item {
    padding-left: 30px;
}
