/* ==========================================================================
   04 — Components: buttons, fields, badges, qty, overlay, drawer, modal, toast, prose
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn, .button, button.button, a.button, input.button, .wp-element-button {
	--h: 48px;
	position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
	min-height: var(--h); padding: 0 22px; border-radius: var(--r-pill); border: 1.5px solid transparent;
	font-weight: 700; font-size: var(--fs-md); line-height: 1.2; white-space: nowrap; cursor: pointer;
	background: var(--green); color: #fff; text-decoration: none;
	transition: background var(--t), color var(--t), border-color var(--t), transform .18s var(--ease), box-shadow var(--t);
	-webkit-tap-highlight-color: transparent;
}
.btn:active, .button:active { transform: scale(.97); }
.btn:hover, .button:hover { background: var(--green-deep); }
.btn .ico { width: 20px; height: 20px; transition: transform var(--t) var(--ease); }
.btn:hover .ico:last-child:not(:only-child) { transform: translateX(-4px); }

.btn--gold, .button.alt, .checkout-button, #place_order, .single_add_to_cart_button {
	background: var(--gold); color: var(--green-deep); box-shadow: 0 10px 22px -12px rgba(201, 154, 39, .8);
}
.btn--gold:hover, .button.alt:hover, .checkout-button:hover, #place_order:hover, .single_add_to_cart_button:hover { background: var(--gold-light); color: var(--green-deep); }
.btn--line { background: transparent; color: var(--green); border-color: var(--line-2); }
.btn--line:hover { background: var(--white); border-color: var(--green); color: var(--green); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--cream-2); color: var(--green); }
.btn--light { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); }
.btn--light:hover { background: #fff; color: var(--green-deep); }
.btn--sm { --h: 40px; padding: 0 16px; font-size: var(--fs-sm); }
.btn--lg { --h: 56px; padding: 0 30px; font-size: var(--fs-lg); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: var(--h); }

.btn[disabled], .button.disabled, .button:disabled { opacity: .5; pointer-events: none; }
.btn.is-loading, .button.loading { pointer-events: none; color: transparent !important; }
.btn.is-loading > *, .button.loading > * { opacity: 0; }
.btn.is-loading::after, .button.loading::after {
	content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
	border: 2.5px solid #fff; border-top-color: transparent; animation: spin .7s linear infinite;
}
.btn--gold.is-loading::after, .single_add_to_cart_button.loading::after { border-color: var(--green-deep); border-top-color: transparent; }
.btn--line.is-loading::after { border-color: var(--green); border-top-color: transparent; }

.link { color: var(--green); font-weight: 700; text-decoration: underline; text-decoration-color: rgba(201,154,39,.5); text-underline-offset: 5px; text-decoration-thickness: 1.5px; }
.link:hover { text-decoration-color: var(--gold); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 800; line-height: 1.6; }
.badge--sale { background: var(--date); color: #fff; }
.badge--out { background: var(--ink); color: #fff; }
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--gold { background: var(--gold-soft); color: var(--brown); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.input, .field input:not([type="checkbox"]):not([type="radio"]), .field textarea, .field select,
.woocommerce form .input-text, .woocommerce form select, .woocommerce-input-wrapper input, .woocommerce-input-wrapper textarea, .comment-form input[type="text"], .comment-form input[type="email"], .comment-form textarea {
	width: 100%; min-height: 50px; padding: 12px 16px; border-radius: var(--r-sm);
	border: 1.5px solid var(--line); background: var(--white); outline: 0;
	transition: border-color var(--t), box-shadow var(--t);
}
textarea.input, .field textarea, .comment-form textarea { min-height: 130px; resize: vertical; line-height: 1.8; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus, .woocommerce form .input-text:focus, .woocommerce form select:focus, .comment-form input:focus, .comment-form textarea:focus {
	border-color: var(--green); box-shadow: 0 0 0 4px rgba(7, 85, 43, .1);
}
.field.has-error input, .field.has-error textarea { border-color: var(--err); background: var(--err-soft); }
.field__err { font-size: var(--fs-xs); color: var(--err); font-weight: 600; }
.field__err:empty { display: none; }
input[dir="ltr"], .ltr { text-align: left; direction: ltr; }

/* ---------- Quantity ---------- */
.quantity { display: inline-flex; align-items: center; height: 50px; border: 1.5px solid var(--line); border-radius: var(--r-pill); background: var(--white); overflow: hidden; }
.quantity .qty { width: 46px; height: 100%; border: 0; text-align: center; font-weight: 800; background: transparent; -moz-appearance: textfield; outline: 0; }
.quantity .qty::-webkit-outer-spin-button, .quantity .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-btn { width: 44px; height: 100%; font-size: 1.3rem; font-weight: 700; color: var(--green); transition: background var(--t); }
.qty-btn:hover { background: var(--cream-2); }
.quantity--sm { height: 38px; }
.quantity--sm .qty-btn { width: 34px; font-size: 1.1rem; }
.quantity--sm .qty { width: 34px; font-size: var(--fs-sm); }

/* ---------- Overlay / Drawer / Modal ---------- */
.overlay { position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: rgba(6, 30, 17, .45); backdrop-filter: blur(3px); opacity: 0; visibility: hidden; transition: opacity var(--t), visibility var(--t); }
.overlay.is-on { opacity: 1; visibility: visible; }

.drawer {
	position: fixed; top: 0; bottom: 0; z-index: var(--z-drawer); width: min(92vw, 420px);
	display: flex; flex-direction: column; background: var(--cream); box-shadow: var(--sh-3);
	transition: transform .45s var(--ease), visibility .45s; visibility: hidden;
}
.drawer--right { right: 0; transform: translateX(105%); }
.drawer--left { left: 0; transform: translateX(-105%); }
.drawer.is-open { transform: none; visibility: visible; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--white); }
.drawer__title { font-size: var(--fs-lg); font-weight: 800; color: var(--green-deep); display: flex; align-items: center; gap: 8px; }
.drawer__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; }
.drawer__foot { padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--white); }
.x-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); transition: background var(--t); }
.x-btn:hover { background: var(--cream-2); }

.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: flex-end; justify-content: center; visibility: hidden; }
.modal.is-open { visibility: visible; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(6, 30, 17, .5); backdrop-filter: blur(4px); opacity: 0; transition: opacity var(--t); }
.modal.is-open .modal__backdrop { opacity: 1; }
.modal__box {
	position: relative; width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto;
	background: var(--cream); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--sh-3);
	transform: translateY(100%); transition: transform .45s var(--ease);
}
.modal.is-open .modal__box { transform: none; }
.modal__close { position: absolute; top: 12px; left: 12px; z-index: 2; }
@media (min-width: 640px) {
	.modal { align-items: center; padding: 20px; }
	.modal__box { border-radius: var(--r-lg); transform: translateY(24px) scale(.97); opacity: 0; transition: transform .4s var(--ease), opacity .3s; }
	.modal.is-open .modal__box { transform: none; opacity: 1; }
}

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; z-index: var(--z-toast); left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 1024px) { .toast-wrap { bottom: 24px; left: 24px; transform: none; } }
.toast {
	display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r);
	background: var(--green-deep); color: #fff; box-shadow: var(--sh-3); font-size: var(--fs-sm); font-weight: 600;
	pointer-events: auto; animation: toastIn .45s var(--ease) both;
}
.toast.is-out { animation: toastOut .3s var(--ease) both; }
.toast img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #fff; }
.toast__txt { flex: 1; min-width: 0; }
.toast__txt small { display: block; color: rgba(255,255,255,.7); font-weight: 400; }
.toast a { color: var(--gold-light); font-weight: 800; white-space: nowrap; }
.toast--err { background: #5b1a12; }
.toast .ico { color: var(--gold-light); }

/* ---------- Prose (محتوای ویرایشگر) ---------- */
.prose { font-size: 1.05rem; line-height: 2.05; color: var(--ink); }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: var(--fs-xl); margin-top: 1.8em; padding-right: 14px; border-right: 4px solid var(--gold); }
.prose h3 { font-size: var(--fs-lg); margin-top: 1.5em; color: var(--green); }
.prose a { color: var(--green); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; }
.prose ul, .prose ol { padding-right: 1.4em; }
.prose ul { list-style: none; padding-right: 0; }
.prose ul li { position: relative; padding-right: 24px; }
.prose ul li::before { content: ""; position: absolute; right: 2px; top: .8em; width: 9px; height: 13px; border-radius: 50%; background: var(--date); transform: rotate(25deg); }
.prose ol { list-style: persian; }
.prose li + li { margin-top: .4em; }
.prose blockquote { margin: 1.6em 0; padding: 18px 22px; border-radius: var(--r); background: var(--gold-soft); border-right: 4px solid var(--gold); color: var(--brown); font-weight: 600; }
.prose img, .prose figure { border-radius: var(--r); }
.prose figcaption { text-align: center; font-size: var(--fs-sm); color: var(--muted); margin-top: 8px; }
.prose table { font-size: var(--fs-sm); }
.prose th, .prose td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.prose th { background: var(--cream-2); }
.prose strong { color: var(--green-deep); }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2em 0; }

/* ---------- Social ---------- */
.social { display: flex; gap: 8px; }
.social__a { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; border: 1px solid currentColor; opacity: .8; transition: opacity var(--t), background var(--t), color var(--t); }
.social__a:hover { opacity: 1; background: var(--gold); border-color: var(--gold); color: var(--green-deep); }
.social__a .ico { width: 20px; height: 20px; }

/* ---------- WooCommerce notices ---------- */
.woocommerce-message, .woocommerce-info, .woocommerce-error, .woocommerce-notice, .wc-block-components-notice-banner {
	display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; list-style: none;
	margin: 0 0 20px; padding: 14px 18px; border-radius: var(--r); background: var(--green-soft); color: var(--green-deep); border: 1px solid rgba(7,85,43,.15); font-size: var(--fs-sm);
}
.woocommerce-error { background: var(--err-soft); color: var(--err); border-color: rgba(180,35,24,.2); flex-direction: column; align-items: flex-start; }
.woocommerce-info { background: var(--gold-soft); color: var(--brown); border-color: rgba(201,154,39,.3); }
.woocommerce-message .button, .woocommerce-info .button { --h: 38px; margin-inline-start: auto; order: 2; font-size: var(--fs-sm); }
.woocommerce-notices-wrapper:empty { display: none; }
