/**
 * Custom WC Address Book - Styles
 *
 * @package Custom_WC_Address_Book
 * @author  紀凱傑、Gemini
 */

/* ==========================================================================
   1. My Account Address Book
   ========================================================================== */

.cwb-address-book-wrapper {
	margin-bottom: 2em;
	font-family: inherit;
}

.cwb-header-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1.5em;
	padding-bottom: 0.8em;
	border-bottom: 2px solid #eee;
}

.cwb-count-info {
	font-size: 1.05em;
	font-weight: 600;
	color: #333;
}

.cwb-count-badge {
	background: #0073aa;
	color: #fff;
	padding: 3px 10px;
	border-radius: 12px;
	font-size: 0.85em;
	margin-left: 6px;
	display: inline-block;
}

.cwb-btn-add {
	padding: 8px 16px;
	font-size: 0.95em;
	border-radius: 4px;
	text-decoration: none !important;
}

.cwb-cards-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 1.5em;
	margin-top: 1em;
}

.cwb-card {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
	padding: 1.4em;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	transition: all 0.2s ease-in-out;
}

.cwb-card:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	border-color: #cbd5e1;
}

.cwb-card.cwb-is-default {
	border-color: #0073aa;
	background-color: #f8fafc;
}

.cwb-card-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 0.8em;
	padding-bottom: 0.5em;
	border-bottom: 1px solid #f1f5f9;
}

.cwb-card-title {
	font-size: 1.25em;
	color: #1e293b;
	font-weight: 700;
}

.cwb-badges {
	display: flex;
	flex-direction: column;
	gap: 4px;
	align-items: flex-end;
}

.cwb-badge {
	font-size: 0.78em;
	font-weight: 700;
	text-transform: uppercase;
	padding: 3px 8px;
	border-radius: 4px;
	letter-spacing: 0.5px;
}

.cwb-badge-billing {
	background: #e0f2fe;
	color: #0369a1;
	border: 1px solid #bae6fd;
}

.cwb-badge-shipping {
	background: #f0fdf4;
	color: #15803d;
	border: 1px solid #bbf7d0;
}

.cwb-card-body {
	font-size: 1.05rem;
	line-height: 1.6;
	color: #334155;
	margin-bottom: 1.2em;
	flex-grow: 1;
}

.cwb-card-body p {
	margin: 0 0 0.5em;
}

.cwb-recipient strong {
	color: #0f172a;
	font-size: 1.18rem;
}

.cwb-company {
	color: #64748b;
	font-size: 1rem;
}

.cwb-address-lines {
	font-size: 1.05rem;
	line-height: 1.6;
	color: #334155;
	margin-bottom: 0 !important;
}

/* ==========================================================================
   Contact Information (Phone & Email) - Natural Address Flow
   ========================================================================== */

.cwb-card-contacts {
	margin-top: 0;
	padding: 0;
	background: transparent !important;
	border: none !important;
	border-radius: 0 !important;
	display: flex;
	flex-direction: column;
	gap: 0;
	box-shadow: none !important;
}

.cwb-contact-item {
	display: flex;
	align-items: baseline;
	gap: 6px;
	line-height: 1.6;
	flex-wrap: wrap;
	font-size: 1.05rem;
	color: #334155;
}

.cwb-contact-label {
	font-size: 1.05rem;
	font-weight: 600;
	color: #475569;
	min-width: unset;
	flex-shrink: 0;
}

.cwb-contact-val {
	font-size: 1.05rem;
	font-weight: 400;
	color: #334155;
	word-break: break-all;
}

.cwb-contact-phone .cwb-contact-val {
	color: #334155;
	font-family: inherit;
}

.cwb-contact-email .cwb-contact-val {
	color: #334155;
	font-weight: 400;
}

/* Selected Modal Card variation */
.cwb-modal-card.cwb-card-selected .cwb-card-contacts {
	background: transparent !important;
	border: none !important;
}

.cwb-preview-contacts {
	margin-top: 0;
}

.cwb-card-actions {
	border-top: 1px solid #f1f5f9;
	padding-top: 0.8em;
	display: flex;
	flex-direction: column;
	gap: 0.6em;
}

.cwb-default-toggles {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.cwb-default-toggles button,
.cwb-btn-set-default {
	font-size: 0.9em !important;
	padding: 6px 14px !important;
	background: #f1f5f9 !important;
	color: #334155 !important;
	border: 1px solid #cbd5e1 !important;
	border-radius: 6px !important;
	cursor: pointer !important;
	font-weight: 500 !important;
	line-height: 1.3 !important;
	transition: all 0.15s ease !important;
}

.cwb-default-toggles button:hover,
.cwb-btn-set-default:hover {
	background: #e2e8f0 !important;
	color: #0f172a !important;
	border-color: #94a3b8 !important;
}

.cwb-default-toggles button:disabled,
.cwb-btn-set-default:disabled {
	opacity: 0.6 !important;
	cursor: not-allowed !important;
}

.cwb-manage-buttons {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

.cwb-btn-edit,
.cwb-btn-delete {
	font-size: 0.82em !important;
	padding: 5px 12px !important;
	border-radius: 4px !important;
}

.cwb-btn-delete {
	background-color: #fee2e2 !important;
	color: #b91c1c !important;
	border: 1px solid #fecaca !important;
}

.cwb-btn-delete:hover:not(:disabled) {
	background-color: #fca5a5 !important;
}

.cwb-btn-delete:disabled,
.cwb-btn-delete.disabled {
	opacity: 0.5;
	cursor: not-allowed !important;
	background-color: #f1f5f9 !important;
	color: #94a3b8 !important;
	border-color: #e2e8f0 !important;
}

/* ==========================================================================
   2. Add/Edit Form
   ========================================================================== */

.cwb-form-container {
	max-width: 650px;
	background: #fff;
	padding: 2em;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
	margin-bottom: 2em;
}

.cwb-form-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1.5em;
	border-bottom: 1px solid #e2e8f0;
	padding-bottom: 0.8em;
}

.cwb-form-header h3 {
	margin: 0;
	font-size: 1.3em;
}

.cwb-back-link {
	font-size: 0.9em;
	color: #0073aa;
	text-decoration: none;
}

.cwb-form-row {
	margin-bottom: 1.2em;
}

.cwb-form-row-group {
	display: flex;
	gap: 1em;
	margin-bottom: 1.2em;
}

.cwb-form-col {
	flex: 1;
}

.cwb-form-row label,
.cwb-form-col label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.3em;
	font-size: 0.9em;
	color: #334155;
}

.cwb-form-row input[type="text"],
.cwb-form-row input[type="email"],
.cwb-form-row input[type="tel"],
.cwb-form-row select,
.cwb-form-col input[type="text"],
.cwb-form-col input[type="tel"],
.cwb-form-col select {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid #cbd5e1;
	border-radius: 4px;
	box-sizing: border-box;
	font-size: 0.95em;
}

.cwb-address-2 {
	margin-top: 8px;
}

.cwb-form-checkboxes {
	margin: 1.5em 0;
	display: flex;
	flex-direction: column;
	gap: 0.6em;
}

.cwb-checkbox-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.95em;
	color: #334155;
	cursor: pointer;
}

.cwb-form-actions {
	display: flex;
	gap: 1em;
	align-items: center;
	margin-top: 1.5em;
	padding-top: 1em;
	border-top: 1px solid #f1f5f9;
}

.cwb-btn-cancel {
	background: #f1f5f9 !important;
	color: #475569 !important;
	border: 1px solid #cbd5e1 !important;
}

/* ==========================================================================
   3. Checkout Integration Styles (BMS 3-Step & Native)
   ========================================================================== */

/* Choose Address Button in BMS 3-Step Header */
.cwb-btn-choose-address {
	background-color: #16a34a !important;
	border: 1px solid #16a34a !important;
	color: #ffffff !important;
	font-size: 0.88em !important;
	font-weight: 600 !important;
	line-height: 1.2 !important;
	padding: 7px 16px !important;
	border-radius: 6px !important;
	cursor: pointer !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	text-align: center !important;
	margin-right: 8px !important;
	transition: all 0.15s ease !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
	vertical-align: middle !important;
}

.cwb-btn-choose-address:hover {
	background-color: #15803d !important;
	border-color: #15803d !important;
	color: #ffffff !important;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.cwb-btn-choose-address:active,
.cwb-btn-choose-address:focus {
	background-color: #15803d !important;
	border-color: #15803d !important;
	color: #ffffff !important;
	outline: none !important;
	box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.3) !important;
}

/* Native WC Fallback Action Wrap */
.cwb-checkout-action-wrap {
	margin: 10px 0 15px;
}

/* Modal Lock on Body */
body.cwb-modal-active {
	overflow: hidden !important;
}

/* Modal Backdrop */
.cwb-modal-backdrop {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(15, 23, 42, 0.65);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.cwb-modal-backdrop.cwb-modal-open {
	opacity: 1;
}

/* Modal Dialog */
.cwb-modal-dialog {
	background: #ffffff;
	width: 92%;
	max-width: 680px;
	max-height: 85vh;
	border-radius: 12px;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform: scale(0.96);
	transition: transform 0.2s ease;
	border: 1px solid #e2e8f0;
}

.cwb-modal-open .cwb-modal-dialog {
	transform: scale(1);
}

/* Modal Header */
.cwb-modal-header {
	padding: 16px 22px;
	border-bottom: 1px solid #f1f5f9;
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: #ffffff;
}

.cwb-modal-title {
	margin: 0;
	font-size: 1.2em;
	font-weight: 700;
	color: #0f172a;
}

.cwb-modal-close {
	background: transparent;
	border: none;
	font-size: 26px;
	line-height: 1;
	color: #64748b;
	cursor: pointer;
	padding: 2px 8px;
	border-radius: 6px;
	transition: all 0.15s ease;
}

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

/* BMS Edit Modal Clear Form Button */
.cwb-btn-modal-clear {
	background: #f1f5f9 !important;
	color: #64748b !important;
	border: 1px solid #cbd5e1 !important;
	font-size: 0.82rem !important;
	font-weight: 600 !important;
	padding: 5px 12px !important;
	border-radius: 6px !important;
	cursor: pointer !important;
	margin-left: auto !important;
	margin-right: 12px !important;
	line-height: 1.2 !important;
	transition: all 0.15s ease !important;
}

.cwb-btn-modal-clear:hover {
	background: #fee2e2 !important;
	color: #dc2626 !important;
	border-color: #fca5a5 !important;
}

/* Modal Body */
.cwb-modal-body {
	padding: 20px 22px;
	overflow-y: auto;
	flex: 1;
	max-height: calc(85vh - 135px);
	background: #f8fafc;
}

.cwb-modal-subtitle {
	margin: 0 0 16px;
	font-size: 0.9em;
	color: #64748b;
	line-height: 1.4;
}

.cwb-modal-cards-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Modal Address Card */
.cwb-modal-card {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	background: #ffffff;
	border: 2px solid #e2e8f0;
	border-radius: 8px;
	padding: 16px 18px;
	cursor: pointer;
	transition: all 0.15s ease;
	user-select: none;
}

.cwb-modal-card:hover {
	border-color: #94a3b8;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.cwb-modal-card.cwb-card-selected {
	border-color: #16a34a;
	background: #f0fdf4;
	box-shadow: 0 0 0 1px #16a34a;
}

.cwb-modal-card-radio-wrap {
	margin-top: 4px;
	display: flex;
	align-items: center;
}

.cwb-modal-card-radio-wrap input[type="radio"] {
	width: 20px;
	height: 20px;
	cursor: pointer;
	accent-color: #16a34a;
	margin: 0;
}

.cwb-modal-card-content {
	flex: 1;
}

.cwb-modal-card-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
}

.cwb-modal-card-name {
	font-weight: 700;
	font-size: 1.18rem;
	color: #0f172a;
}

.cwb-modal-card-badges {
	display: flex;
	gap: 6px;
	align-items: center;
}

.cwb-modal-card-details {
	font-size: 1.05rem;
	color: #334155;
	line-height: 1.6;
}

.cwb-modal-card-details strong {
	color: #0f172a;
	font-size: 1.15rem;
}

.cwb-card-company {
	color: #64748b;
	font-weight: normal;
	font-size: 1rem;
}

/* BMS Checkout Preview Cards text enhancement */
#bms-shipping-card-preview,
#bms-billing-card-preview,
#bms-summary-shipping-preview,
#bms-summary-billing-preview {
	font-size: 1.05rem !important;
	line-height: 1.6 !important;
	color: #334155 !important;
}

#bms-shipping-card-preview strong,
#bms-billing-card-preview strong,
#bms-summary-shipping-preview strong,
#bms-summary-billing-preview strong {
	font-size: 1.15rem !important;
	color: #0f172a !important;
}

/* BMS Native Contact Items formatting (Ensure Phone & Email labels are clearly displayed) */
.bms-card-contact {
	display: block !important;
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	line-height: 1.6 !important;
	color: #334155 !important;
	font-size: 1.05rem !important;
}

/* Eliminate empty line caused by <br> between block .bms-card-contact items */
.bms-card-contact + br {
	display: none !important;
}

.bms-card-contact i.bms-icon-phone {
	font-style: normal !important;
	font-weight: 600 !important;
	color: #475569 !important;
	display: inline !important;
	margin-right: 2px !important;
}

.bms-card-contact i.bms-icon-phone::before {
	content: "Phone : " !important;
}

.bms-card-contact i.bms-icon-email {
	font-style: normal !important;
	font-weight: 600 !important;
	color: #475569 !important;
	display: inline !important;
	margin-right: 2px !important;
}

.bms-card-contact i.bms-icon-email::before {
	content: "Email : " !important;
}

/* Modal Footer */
.cwb-modal-footer {
	padding: 14px 22px;
	border-top: 1px solid #e2e8f0;
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	background: #ffffff;
}

.cwb-modal-btn-cancel {
	background: #f1f5f9 !important;
	color: #475569 !important;
	border: 1px solid #cbd5e1 !important;
	border-radius: 6px !important;
	padding: 8px 16px !important;
	font-weight: 500 !important;
	cursor: pointer !important;
}

.cwb-modal-btn-cancel:hover {
	background: #e2e8f0 !important;
	color: #1e293b !important;
}

.cwb-modal-btn-apply {
	background: #16a34a !important;
	border: 1px solid #16a34a !important;
	color: #ffffff !important;
	border-radius: 6px !important;
	padding: 8px 20px !important;
	font-weight: 600 !important;
	cursor: pointer !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	text-align: center !important;
	gap: 8px !important;
	transition: all 0.15s ease !important;
}

.cwb-modal-btn-apply:hover:not(:disabled) {
	background: #15803d !important;
	border-color: #15803d !important;
}

.cwb-modal-btn-apply:disabled {
	opacity: 0.55 !important;
	cursor: not-allowed !important;
}

.cwb-btn-spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: cwb-spin 0.6s linear infinite;
}

@keyframes cwb-spin {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

/* Injected opt-in checkbox in BMS Address Modal */
.cwb-save-address-optin-wrap {
	margin: 15px 0 10px;
	padding: 10px 12px;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
}

.cwb-save-address-optin-wrap label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.9em;
	color: #334155;
	font-weight: 600;
	cursor: pointer;
	margin: 0;
}

.cwb-save-address-optin-wrap.cwb-disabled {
	opacity: 0.65;
	background: #f1f5f9;
}

.cwb-save-address-optin-wrap.cwb-disabled label {
	cursor: not-allowed;
}

.cwb-optin-limit-hint {
	font-size: 0.8em;
	color: #e11d48;
	margin-top: 4px;
	display: block;
}

@media (max-width: 600px) {
	.bms-card-header {
		flex-wrap: wrap;
		gap: 8px;
	}

	.cwb-btn-choose-address {
		margin-right: 0 !important;
		width: 100%;
		justify-content: center;
	}

	.cwb-modal-dialog {
		width: 95%;
		max-height: 92vh;
	}

	.cwb-modal-header,
	.cwb-modal-body,
	.cwb-modal-footer {
		padding: 14px 16px;
	}
}

