/**
 * VCAC – Vietnam Checkout Address Converter
 * Checkout form styles
 */

/* -----------------------------------------------------------------------
   Section wrapper
   --------------------------------------------------------------------- */
.woocommerce-billing-fields__field-wrapper{overflow: hidden;}
#vcac-address-wrapper {
    margin-top: 0;
}

.vcac-section {
    margin: 16px 0 0;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.vcac-section-title {
    margin: 0 0 16px;
    font-size: 1em;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
}

/* Tiêu đề section cũ (3 cấp) phân biệt bằng màu */
.vcac-section-title--old {
    color: #666;
}

/* Badge "Tự động cập nhật từ địa chỉ cũ" trên tiêu đề 2-cap */
.vcac-auto-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.75em;
    font-weight: 400;
    color: #2e7d32;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 12px;
    vertical-align: middle;
}

.vcac-section-3cap {
    background: #fff8f0;
    border-color: #ffe0b2;
}

.vcac-section-help {
    margin: -8px 0 14px;
    font-size: 0.875em;
    color: #888;
    font-style: italic;
}

/* -----------------------------------------------------------------------
   Hybrid mode: tab switcher + flow order
   --------------------------------------------------------------------- */
.vcac-hybrid-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.vcac-tab {
    padding: 10px 16px;
    font-size: 0.9em;
    font-weight: 500;
    color: #666;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    margin-bottom: -1px;
    border-radius: 4px 4px 0 0;
}

.vcac-tab:hover {
    color: #333;
    background: #f0f0f0;
}

.vcac-tab.vcac-tab--active {
    color: #2271b1;
    border-bottom-color: #2271b1;
    background: #f8f9fa;
}

.vcac-hybrid-sections {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.vcac-hybrid-sections .vcac-section {
    flex: 0 0 auto;
}

.vcac-flow-old-first #vcac-section-3cap { order: 1; }
.vcac-flow-old-first #vcac-section-2cap { order: 2; }

.vcac-flow-new-first #vcac-section-2cap { order: 1; }
.vcac-flow-new-first #vcac-section-3cap { order: 2; }

.vcac-badge-from-new {
    margin: -8px 0 14px;
    font-size: 0.875em;
}

/* -----------------------------------------------------------------------
   Fields layout
   --------------------------------------------------------------------- */
.vcac-fields {
    margin: 0;
}

.vcac-fields .form-row {
    margin-bottom: 12px;
}

@media (min-width: 768px) {
    .vcac-section-3cap .vcac-fields {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0 12px;
        align-items: start;
    }

    .vcac-section-3cap .vcac-fields .vcac-col-1-3 {
        min-width: 0; /* tránh overflow trong grid cell */
    }

    .vcac-section-2cap .vcac-fields {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 12px;
        align-items: start;
    }

    .vcac-fields .form-row,
    .vcac-fields .form-row-first,
    .vcac-fields .form-row-last {
        float: none;
        width: 100%;
        clear: none;
        margin-right: 0;
    }

    .vcac-fields .vcac-col-full {
        grid-column: 1 / -1;
    }
}

/* -----------------------------------------------------------------------
   Select2 / SelectWoo overrides
   --------------------------------------------------------------------- */
.vcac-select .select2-container,
.vcac-select .select2-container--default {
    width: 100% !important;
}

.vcac-select .select2-selection--single {
    height: 40px;
    border-color: #ccc;
    border-radius: 4px;
}

.vcac-select .select2-selection__rendered {
    line-height: 40px;
    color: #333;
}

.vcac-select .select2-selection__arrow {
    height: 38px;
}

/* -----------------------------------------------------------------------
   Admin – order detail display (inline style trong PHP làm chính,
   CSS này chỉ là fallback)
   --------------------------------------------------------------------- */
.vcac-old-address-admin {
    margin-top: 10px;
    padding: 10px;
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    border-radius: 3px;
    font-size: 0.9em;
}

/* -----------------------------------------------------------------------
   Order received – customer address block
   --------------------------------------------------------------------- */
.woocommerce-order .woocommerce-customer-details address {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px 16px;
}

.woocommerce-order .woocommerce-customer-details address p {
    margin: 0 0 8px;
    line-height: 1.5;
}

.woocommerce-order .woocommerce-customer-details address p:last-child {
    margin-bottom: 0;
}

.woocommerce-order .woocommerce-customer-details address .customer-name,
.woocommerce-order .woocommerce-customer-details address .woocommerce-customer-details--phone,
.woocommerce-order .woocommerce-customer-details address .woocommerce-customer-details--email {
    padding-bottom: 8px;
    border-bottom: 1px dashed #d9d9d9;
}

.woocommerce-order .woocommerce-customer-details address .customer-old-address {
    margin-top: 10px;
    padding: 8px 10px;
    background: #fff3e0;
    border-left: 3px solid #ff9800;
    border-radius: 4px;
}

.woocommerce-order .woocommerce-customer-details address .customer-new-address {
    padding: 8px 10px;
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
    border-radius: 4px;
}

.woocommerce-order .woocommerce-customer-details address a {
    color: #2271b1;
    text-decoration: none;
}

.woocommerce-order .woocommerce-customer-details address a:hover {
    text-decoration: underline;
}

/* -----------------------------------------------------------------------
   Saved address card on checkout (logged-in, has orders + saved address)
   --------------------------------------------------------------------- */
.vcac-saved-address-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.vcac-saved-address-card__content {
    flex: 1;
    min-width: 0;
}

.vcac-saved-address-card__row {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
}

.vcac-saved-address-card__row:last-child {
    margin-bottom: 0;
}

.vcac-saved-address-card__row strong {
    font-weight: 600;
    color: #111827;
    margin-right: 4px;
}

/* Edit button – icon bút góc phải, hover nhẹ */
.vcac-saved-address-card__edit {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.vcac-saved-address-card__edit:hover {
    color: #2271b1;
    background: #f0f6fc;
    border-color: #2271b1;
    transform: scale(1.05);
}

.vcac-saved-address-card__edit .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Ẩn form billing khi đang hiển thị card (JS toggle) */
.vcac-form-hidden {
    display: none !important;
}

/* Mobile: card full width, đảm bảo touch target cho icon */
@media (max-width: 767px) {
    .vcac-saved-address-card {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .vcac-saved-address-card__edit {
        position: absolute;
        top: 12px;
        right: 12px;
    }

    .vcac-saved-address-card {
        position: relative;
        padding-top: 48px;
    }

    .vcac-saved-address-card__content {
        width: 100%;
    }
}
