/**
 * 礼物包装与定制 — 独立样式（不依赖 Bootstrap）
 */

:root {
    --wcet-gwc-border: #d8d8d8;
    --wcet-gwc-bg: #fafafa;
    --wcet-gwc-text: #222;
    --wcet-gwc-muted: #666;
    --wcet-gwc-radius: 4px;
    --wcet-gwc-focus: #2271b1;
    --wcet-gwc-danger: #b32d2e;
    --wcet-gwc-warn: #996800;
}

/* 变体产品中定制选项独占一行 */
.woocommerce-variation-add-to-cart {
    flex-wrap: wrap !important;
}

.woocommerce-variation-add-to-cart .gift-wrap-customization-options {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    order: -1;
    margin-bottom: 1rem;
    display: block !important;
}

/* 外层面板 */
.wcet-gwc {
    width: 100%;
    margin-bottom: 1rem;
    border: 1px solid var(--wcet-gwc-border);
    border-radius: var(--wcet-gwc-radius);
    background: #fff;
    box-sizing: border-box;
}

.wcet-gwc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--wcet-gwc-bg);
    border-bottom: 1px solid var(--wcet-gwc-border);
}

.wcet-gwc-title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--wcet-gwc-muted);
}

.wcet-gwc-toggle {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--wcet-gwc-border);
    border-radius: var(--wcet-gwc-radius);
    background: #fff;
    color: var(--wcet-gwc-text);
    cursor: pointer;
    margin: 0;
    line-height: 1;
}

.wcet-gwc-toggle:hover {
    border-color: #999;
}

.wcet-gwc-hidden {
    display: none !important;
}

.wcet-gwc-body:not(.wcet-gwc-body--open) {
    display: none;
}

.wcet-gwc-fields {
    padding: 0.5rem 0.75rem 0.75rem;
}

/* 礼物包装行（保留勾选） */
.option-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--wcet-gwc-border);
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.option-item:last-child {
    border-bottom: none;
}

.option-content {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.option-image-container {
    width: 50px;
    height: 50px;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.option-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--wcet-gwc-radius);
}

.option-image-placeholder {
    width: 100%;
    height: 100%;
    background: var(--wcet-gwc-bg);
    border-radius: var(--wcet-gwc-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wcet-gwc-muted);
}

.option-image-placeholder .dashicons {
    font-size: 24px;
}

.option-details {
    flex: 1;
    min-width: 0;
}

.option-name {
    display: flex;
    align-items: center;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.option-link {
    font-weight: 500;
    color: var(--wcet-gwc-text);
    text-decoration: none;
}

.option-link:hover {
    color: var(--wcet-gwc-focus);
    text-decoration: underline;
}

.option-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--wcet-gwc-muted);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    cursor: help;
}

.option-price {
    font-size: 0.875rem;
    color: var(--wcet-gwc-muted);
    font-weight: 500;
}

.option-checkbox {
    margin-left: 0.75rem;
    flex-shrink: 0;
}

.option-checkbox-input {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

.option-checkbox-label {
    display: none;
}

/* 定制字段行：标签 + 输入同一列 */
.wcet-field-row {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--wcet-gwc-border);
}

.wcet-field-row:last-child {
    border-bottom: none;
}

.wcet-field-main {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.wcet-field-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: none;
}

.wcet-field-image .option-image,
.wcet-field-image .option-image-placeholder {
    width: 50px;
    height: 50px;
}

.wcet-field-body {
    flex: 1;
    min-width: 0;
}

.wcet-field-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.wcet-field-label {
    font-weight: 500;
    color: var(--wcet-gwc-text);
    font-size: 0.725rem;
}

.wcet-field-price {
    font-size: 0.8125rem;
    color: var(--wcet-gwc-muted);
    white-space: nowrap;
}

/* 输入区域 */
.wcet-custom-input-wrap {
    margin-top: 0;
}

.wcet-form-control,
.wcet-form-select {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-top: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--wcet-gwc-text);
    background: #fff;
    border: 1px solid var(--wcet-gwc-border);
    border-radius: var(--wcet-gwc-radius);
}

.wcet-form-control:focus,
.wcet-form-select:focus {
    outline: none;
    border-color: var(--wcet-gwc-focus);
    box-shadow: 0 0 0 1px var(--wcet-gwc-focus);
}

.wcet-custom-input-wrap textarea.wcet-form-control {
    min-height: 80px;
    resize: vertical;
}

.wcet-char-count,
.char-count {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--wcet-gwc-muted);
}

.wcet-char-warn {
    color: var(--wcet-gwc-warn);
}

.wcet-char-danger {
    color: var(--wcet-gwc-danger);
    font-weight: 600;
}

.wcet-alert {
    margin-top: 0.5rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.8125rem;
    border-radius: var(--wcet-gwc-radius);
    border: 1px solid #f0c0c0;
    background: #fcf0f0;
    color: var(--wcet-gwc-danger);
}

.wcet-cart-note {
    color: var(--wcet-gwc-muted);
}

/* 迷你购物车加载占位 */
.gift-wrap-loading-item {
    opacity: 0.85;
    padding: 0.65rem 0;
    border-bottom: 1px dashed var(--wcet-gwc-border);
}

.wcet-mini-loading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.wcet-mini-loading__img {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wcet-gwc-bg);
    border-radius: var(--wcet-gwc-radius);
}

.wcet-mini-loading__text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--wcet-gwc-muted);
    font-style: italic;
}

.wcet-mini-loading__meta {
    color: var(--wcet-gwc-muted);
    font-size: 0.75rem;
}

.wcet-spinner {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--wcet-gwc-border);
    border-top-color: var(--wcet-gwc-focus);
    border-radius: 50%;
    animation: wcet-spin 0.7s linear infinite;
    vertical-align: middle;
}

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

@media (max-width: 768px) {
    .option-image-container,
    .wcet-field-image {
        width: 45px;
        height: 45px;
    }

    .wcet-field-image .option-image,
    .wcet-field-image .option-image-placeholder {
        width: 45px;
        height: 45px;
    }

    .option-checkbox {
        margin-left: 0.5rem;
    }
}

@media print {
    .gift-wrap-customization-options {
        border: 1px solid #000 !important;
    }

    .wcet-gwc-body:not(.wcet-gwc-body--open) {
        display: block !important;
    }

    .gift-wrap-loading-item {
        display: none !important;
    }
}
