/* ==========================================================================
   Danje address book — My Account "آدرس‌های من" + Checkout picker
   ========================================================================== */

.danje-addressbook__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	margin-bottom: 24px;
}

.danje-addressbook__desc {
	margin: 0;
	color: var(--text-secondary);
	font-size: 13.5px;
}

.danje-addressbook__add-btn,
.danje-checkout-addresses__add-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 20px;
	border: none;
	border-radius: 999px;
	background: var(--gold);
	color: #fff;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.4s cubic-bezier(0.22,1,0.36,1), transform 0.4s cubic-bezier(0.22,1,0.36,1);
}

.danje-addressbook__add-btn:hover,
.danje-checkout-addresses__add-btn:hover {
	background: var(--gold-dark);
	transform: translateY(-1px);
}

.danje-addressbook__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 48px 20px;
	color: var(--text-muted);
	border: 1px dashed var(--gold-border);
	border-radius: var(--radius-md);
}

.danje-addressbook__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 16px;
}

.danje-address-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 20px;
	border-radius: var(--radius-md);
	border: 1px solid var(--gold-border);
	background: var(--bg-surface);
	transition: box-shadow 0.5s cubic-bezier(0.22,1,0.36,1), transform 0.5s cubic-bezier(0.22,1,0.36,1);
}

.danje-address-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 14px 30px -20px rgba(0,0,0,0.3);
}

.danje-address-card.is-default {
	border-color: var(--gold);
	background: var(--gold-muted);
}

.danje-address-card__badge {
	position: absolute;
	top: 14px;
	inset-inline-end: 14px;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--gold);
	color: #fff;
	font-size: 10.5px;
	font-weight: 700;
}

.danje-address-card__icon {
	color: var(--gold);
}

.danje-address-card__title {
	font-size: 15px;
	color: var(--text-primary);
}

.danje-address-card__line {
	margin: 0;
	font-size: 13px;
	color: var(--text-secondary);
	line-height: 1.8;
}

.danje-address-card__meta {
	margin: 0;
	font-size: 11.5px;
	color: var(--text-muted);
}

.danje-address-card__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
	padding-top: 12px;
	border-top: 1px solid var(--gold-border);
}

.danje-address-card__action {
	padding: 6px 12px;
	border: 1px solid var(--gold-border);
	border-radius: 999px;
	background: transparent;
	color: var(--gold-dark);
	font-size: 11.5px;
	cursor: pointer;
	transition: background 0.35s cubic-bezier(0.22,1,0.36,1);
}

.danje-address-card__action:hover {
	background: var(--gold-muted);
}

.danje-address-card__action--danger {
	color: #c62828;
	border-color: rgba(198,40,40,0.3);
}

.danje-address-card__action--danger:hover {
	background: rgba(198,40,40,0.08);
}

/* ---- Modal ---- */

.danje-address-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

/* Critical: without this, the [hidden] attribute loses to the class's
   own `display: flex` (equal specificity, author rule wins the tie),
   leaving an invisible full-viewport layer permanently intercepting
   every click on the page — even the header menu and footer. */
.danje-address-modal[hidden] {
	display: none !important;
}

.danje-address-modal__backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15,13,10,0.55);
	backdrop-filter: blur(3px);
	opacity: 0;
	transition: opacity 0.35s ease;
}

.danje-address-modal.is-open .danje-address-modal__backdrop {
	opacity: 1;
}

.danje-address-modal__panel {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: 88vh;
	overflow-y: auto;
	background: var(--bg-surface);
	border-radius: 18px;
	padding: 20px;
	transform: translateY(24px) scale(0.98);
	opacity: 0;
	transition: transform 0.4s cubic-bezier(0.22,1,0.36,1), opacity 0.4s cubic-bezier(0.22,1,0.36,1);
}

.danje-address-modal.is-open .danje-address-modal__panel {
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* Checkout uses this same component inline (no popup) — the customer
   fills the address right on the page, in normal document flow. */
.danje-address-modal.is-inline {
	position: static;
	z-index: auto;
	display: block;
	padding: 0;
	margin-top: 16px;
}

.danje-address-modal.is-inline .danje-address-modal__backdrop {
	display: none;
}

.danje-address-modal.is-inline .danje-address-modal__panel {
	max-width: none;
	max-height: none;
	overflow: visible;
	border: 1px solid var(--gold-border);
	border-radius: 16px;
	box-shadow: none;
}

.danje-address-modal.is-inline.is-open .danje-address-modal__panel,
.danje-address-modal.is-inline .danje-address-modal__panel {
	transform: none;
	opacity: 1;
}

.danje-address-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}

.danje-address-modal__header h3 {
	margin: 0;
	font-size: 17px;
	color: var(--text-primary);
}

.danje-address-modal__close {
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 50%;
	background: var(--bg-card);
	color: var(--text-secondary);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

/* Small pin icon on the "آدرس کامل" label — opens a compact inline map
   instead of a separate big step. */
.danje-addr-line__map-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	margin-inline-start: 4px;
	border: none;
	border-radius: 50%;
	background: var(--gold-muted);
	color: var(--gold-dark);
	cursor: pointer;
	vertical-align: middle;
	transition: background 0.3s ease, color 0.3s ease;
}

.danje-addr-line__map-btn:hover,
.danje-addr-line__map-btn.is-active {
	background: var(--gold);
	color: #fff;
}

.danje-address-map-step {
	margin-top: 8px;
}

.danje-address-map-step[hidden] {
	display: none !important;
}

.danje-address-map {
	position: relative;
	height: 160px;
	margin-bottom: 4px;
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid var(--gold-border);
}

.danje-address-map__canvas {
	width: 100%;
	height: 100%;
}

.danje-address-map__pin {
	position: absolute;
	top: 50%;
	inset-inline-start: 50%;
	transform: translate(-50%, -100%);
	z-index: 500;
	pointer-events: none;
	filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
}

.danje-address-map__locate {
	position: absolute;
	top: 8px;
	/* Physical right, not logical inset-inline-end — Leaflet's own
	   zoom control always renders at the physical top-left regardless
	   of page direction, so this button must stay on the opposite
	   (physical right) side to avoid sitting on top of it. */
	right: 8px;
	z-index: 500;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: 50%;
	background: rgba(255,255,255,0.95);
	color: var(--gold-dark);
	box-shadow: 0 3px 10px rgba(0,0,0,0.2);
	cursor: pointer;
	transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
}

.danje-address-map__locate:hover {
	transform: scale(1.1);
}

.danje-address-map__locate.is-loading svg {
	animation: danje-map-locate-spin 1s linear infinite;
}

@keyframes danje-map-locate-spin {
	to { transform: rotate(360deg); }
}

.danje-address-map__hint {
	margin: 4px 0 0;
	font-size: 10.5px;
	color: var(--text-muted);
	text-align: center;
}

.danje-address-form__row {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
	margin-bottom: 10px;
}

.danje-address-form__field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 10px;
}

.danje-address-form__row .danje-address-form__field {
	margin-bottom: 0;
}

.danje-address-form__field label {
	font-size: 12.5px;
	color: var(--text-secondary);
}

.danje-address-form__field label .req {
	color: #c62828;
}

.danje-address-form__field input,
.danje-address-form__field textarea {
	padding: 10px 14px;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: var(--bg-input);
	color: var(--text-primary);
	font-family: 'Vazirmatn', sans-serif;
	font-size: 13.5px;
}

.danje-address-form__field input:focus,
.danje-address-form__field textarea:focus {
	outline: none;
	border-color: var(--gold);
	box-shadow: 0 0 0 3px var(--gold-glow);
}

.danje-address-form__checkbox {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--text-secondary);
	margin-bottom: 10px;
	cursor: pointer;
}

.danje-address-form__msg {
	min-height: 16px;
	font-size: 12.5px;
	color: #c62828;
	margin: 0 0 8px;
}

.danje-address-form__submit {
	width: 100%;
	padding: 13px;
	border: none;
	border-radius: 999px;
	background: var(--gold);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.4s cubic-bezier(0.22,1,0.36,1);
}

.danje-address-form__submit:hover {
	background: var(--gold-dark);
}

.danje-address-form__submit:disabled {
	opacity: 0.6;
	cursor: default;
}

/* ---- Searchable combobox ---- */

.danje-combobox {
	position: relative;
}

.danje-combobox__input:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.danje-combobox__list {
	position: absolute;
	z-index: 10;
	top: calc(100% + 6px);
	inset-inline: 0;
	max-height: 220px;
	overflow-y: auto;
	background: var(--bg-surface);
	border: 1px solid var(--gold-border);
	border-radius: 12px;
	box-shadow: 0 16px 34px -18px rgba(0,0,0,0.35);
}

.danje-combobox__item {
	padding: 9px 14px;
	font-size: 13px;
	color: var(--text-primary);
	cursor: pointer;
}

.danje-combobox__item:hover {
	background: var(--gold-muted);
}

@media (max-width: 640px) {
	.danje-address-form__row {
		grid-template-columns: 1fr;
	}

	.danje-address-modal__panel {
		padding: 20px;
		border-radius: 16px;
	}

	/* Address tabs: let the two pills wrap and each take a full row if
	   the viewport is too narrow to fit them side by side, so neither
	   pill's Persian label gets clipped. */
	.danje-checkout-addresses__tabs {
		flex-wrap: wrap;
	}

	.danje-checkout-addresses__tab {
		flex: 1 1 auto;
		text-align: center;
	}

	.danje-address-dropdown__trigger {
		font-size: 12px;
	}
}

/* ==========================================================================
   Checkout address picker
   ========================================================================== */

.danje-checkout-addresses {
	margin-bottom: 24px;
}

.danje-checkout-addresses__title {
	font-size: 15px;
	margin: 0 0 14px;
	color: var(--text-primary);
}

.danje-checkout-addresses__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 12px;
}

.danje-checkout-address-card {
	position: relative;
	display: block;
	padding: 16px;
	border-radius: var(--radius-md);
	border: 2px solid var(--gold-border);
	background: var(--bg-surface);
	cursor: pointer;
	transition: border-color 0.35s cubic-bezier(0.22,1,0.36,1), background 0.35s cubic-bezier(0.22,1,0.36,1);
}

.danje-checkout-address-card input[type="radio"] {
	position: absolute;
	inset-inline-end: 14px;
	top: 14px;
}

.danje-checkout-address-card:has(input:checked) {
	border-color: var(--gold);
	background: var(--gold-muted);
}

.danje-checkout-address-card strong {
	display: block;
	margin-inline-end: 24px;
	font-size: 13.5px;
	color: var(--text-primary);
}

.danje-checkout-address-card p {
	margin: 4px 24px 0 0;
	font-size: 12px;
	color: var(--text-secondary);
	line-height: 1.7;
}

.danje-checkout-address-card__badge {
	display: inline-block;
	margin-bottom: 6px;
	padding: 2px 9px;
	border-radius: 999px;
	background: var(--gold);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
}

.danje-checkout-addresses__add-btn {
	align-self: stretch;
	justify-content: center;
	border: 2px dashed var(--gold-border);
	background: transparent;
	color: var(--gold-dark);
}

.danje-checkout-addresses__add-btn:hover {
	background: var(--gold-muted);
}

/* ---- Tabs (existing addresses vs. add new) + modern dropdown ---- */

.danje-checkout-addresses__tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

.danje-checkout-addresses__tab {
	padding: 8px 16px;
	border: none;
	border-radius: 999px;
	background: var(--bg-card);
	color: var(--text-secondary);
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.3s ease, color 0.3s ease;
}

.danje-checkout-addresses__tab.is-active {
	background: var(--gold);
	color: #fff;
}

.danje-checkout-addresses__add-btn-solo {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 20px;
	border: 2px dashed var(--gold-border);
	border-radius: 999px;
	background: transparent;
	color: var(--gold-dark);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.3s ease;
}

.danje-checkout-addresses__add-btn-solo:hover {
	background: var(--gold-muted);
}

/* Explicit [hidden] override: this button sets its own `display`, whose
   class specificity ties the UA `[hidden]{display:none}` rule — and
   author CSS wins ties by source order, so without this the button
   stays visible even with the `hidden` attribute set. It's kept in the
   DOM (JS clicks it to auto-open the add-address form when the customer
   has no saved addresses yet) but must never actually show. */
.danje-checkout-addresses__add-btn-solo[hidden] {
	display: none !important;
}

.danje-address-dropdown {
	position: relative;
}

.danje-address-dropdown__trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	padding: 12px 16px;
	border: 2px solid var(--gold-border);
	border-radius: var(--radius-md);
	background: var(--bg-surface);
	color: var(--text-primary);
	font-size: 13px;
	font-family: 'Vazirmatn', sans-serif;
	cursor: pointer;
	text-align: right;
	transition: border-color 0.3s ease;
}

.danje-address-dropdown__trigger:hover {
	border-color: var(--gold);
}

.danje-address-dropdown__summary {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.danje-address-dropdown__chevron {
	flex-shrink: 0;
	transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
}

.danje-address-dropdown__trigger.is-open .danje-address-dropdown__chevron {
	transform: rotate(180deg);
}

.danje-address-dropdown__list {
	position: absolute;
	z-index: 20;
	top: calc(100% + 6px);
	inset-inline: 0;
	max-height: 280px;
	overflow-y: auto;
	background: var(--bg-surface);
	border: 1px solid var(--gold-border);
	border-radius: var(--radius-md);
	box-shadow: 0 16px 34px -18px rgba(0,0,0,0.35);
	padding: 6px;
}

.danje-address-dropdown__item {
	position: relative;
	display: block;
	padding: 10px 34px 10px 12px;
	border-radius: 10px;
	cursor: pointer;
	transition: background 0.2s ease;
}

.danje-address-dropdown__item:hover {
	background: var(--gold-muted);
}

.danje-address-dropdown__item input[type="radio"] {
	position: absolute;
	inset-inline-end: 12px;
	top: 12px;
}

.danje-address-dropdown__item-text {
	display: block;
	font-size: 12.5px;
	color: var(--text-secondary);
	line-height: 1.7;
}

.danje-address-dropdown__item-text strong {
	display: block;
	font-size: 13px;
	color: var(--text-primary);
	margin-bottom: 2px;
}

.danje-address-dropdown__badge {
	display: inline-block;
	margin-top: 4px;
	padding: 2px 9px;
	border-radius: 999px;
	background: var(--gold);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
}

/* WooCommerce's native billing/shipping address fields stay in the DOM
   (so core validation + order creation work unmodified) but are
   visually hidden — filled via JS from the selected address card
   above. Email (and any custom checkout field a plugin adds) is left
   fully visible and editable, since it isn't part of the address book. */
body.woocommerce-checkout.logged-in #billing_first_name_field,
body.woocommerce-checkout.logged-in #billing_last_name_field,
body.woocommerce-checkout.logged-in #billing_address_1_field,
body.woocommerce-checkout.logged-in #billing_address_2_field,
body.woocommerce-checkout.logged-in #billing_city_field,
body.woocommerce-checkout.logged-in #billing_state_field,
body.woocommerce-checkout.logged-in #billing_postcode_field,
body.woocommerce-checkout.logged-in #billing_country_field,
body.woocommerce-checkout.logged-in #billing_phone_field,
body.woocommerce-checkout.logged-in #shipping_first_name_field,
body.woocommerce-checkout.logged-in #shipping_last_name_field,
body.woocommerce-checkout.logged-in #shipping_address_1_field,
body.woocommerce-checkout.logged-in #shipping_address_2_field,
body.woocommerce-checkout.logged-in #shipping_city_field,
body.woocommerce-checkout.logged-in #shipping_state_field,
body.woocommerce-checkout.logged-in #shipping_postcode_field,
body.woocommerce-checkout.logged-in #shipping_country_field,
body.woocommerce-checkout.logged-in #shipping_phone_field {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
	margin: 0;
	padding: 0;
}

/* One unified address, not a separate billing/shipping pair — hide the
   whole "ship to a different address?" section entirely. */
body.woocommerce-checkout.logged-in .woocommerce-shipping-fields {
	display: none;
}
