/* =========================================================================
 * Toyana Custom Cart — slide-in drawer (mini-cart)
 * متغیرهای --ttc-* مشترک با cart.css هستند و اینجا هم تعریف می‌شوند تا کشو
 * مستقل از صفحهٔ شورتکد روی کل سایت کار کند.
 * Shares the --ttc-* variable system with cart.css; redeclared here so the drawer
 * is self-sufficient on any page (cart.css is only loaded on the shortcode page).
 * ========================================================================= */

:root {
	--ttc-primary: #16394D;
	--ttc-primary-hover: #0f2a39;
	--ttc-discount: #1E9E5A;
	--ttc-star: #F5A623;
	--ttc-trash: #E04F4F;
	--ttc-border: #E5E7EB;
	--ttc-summary-bg: #F6F7F8;
	--ttc-text: #1A1A1A;
	--ttc-text-muted: #6B7280;
	--ttc-strike: #9CA3AF;
	--ttc-pill-bg: #EDEFF2;
	--ttc-pill-text: #4B5563;
	--ttc-card-bg: #FFFFFF;
	--ttc-radius: 16px;
	--ttc-radius-sm: 12px;
	--ttc-font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	--ttc-drawer-width: 400px;
}

/* ---------- Root container / overlay ---------- */
.ttc-drawer-root {
	position: fixed;
	inset: 0;
	z-index: 100000;
	visibility: hidden;
	pointer-events: none;
}

.ttc-drawer-root.is-open {
	visibility: visible;
	pointer-events: auto;
}

.ttc-drawer__overlay {
	position: absolute;
	inset: 0;
	background: rgba(17, 24, 39, 0.5);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.ttc-drawer__overlay[hidden] {
	display: none;
}

.ttc-drawer-root.is-open .ttc-drawer__overlay {
	opacity: 1;
}

/* ---------- Panel ---------- */
.ttc-drawer__panel {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	width: var(--ttc-drawer-width);
	max-width: 100%;
	background: var(--ttc-card-bg);
	box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
	font-family: var(--ttc-font);
	color: var(--ttc-text);
	will-change: transform;
}

.ttc-drawer-root.is-open .ttc-drawer__panel {
	transform: translateX(0);
}

.ttc-drawer__panel * {
	box-sizing: border-box;
}

/* ---------- Header ---------- */
.ttc-drawer__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 20px;
	border-bottom: 1px solid var(--ttc-border);
	flex-shrink: 0;
}

.ttc-drawer__title {
	font-size: 1.25rem;
	font-weight: 700;
	margin: 0;
	color: var(--ttc-text);
}

.ttc-drawer__viewcart {
	margin-left: auto;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--ttc-primary);
	text-decoration: none;
}

.ttc-drawer__viewcart:hover {
	text-decoration: underline;
}

.ttc-drawer__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: none;
	background: var(--ttc-summary-bg);
	border-radius: 50%;
	color: var(--ttc-text);
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.ttc-drawer__close:hover {
	background: var(--ttc-border);
}

.ttc-drawer__close:focus-visible {
	outline: 2px solid var(--ttc-primary);
	outline-offset: 2px;
}

/* ---------- Contents (fragment target) ---------- */
.ttc-drawer__contents {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0; /* allow inner scroll */
}

/* ---------- Item list (scrollable) ---------- */
.ttc-drawer__items {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 8px 20px;
}

.ttc-drawer-item {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr) auto;
	gap: 14px;
	align-items: start;
	padding: 16px 0;
	border-bottom: 1px solid var(--ttc-border);
}

.ttc-drawer-item:last-child {
	border-bottom: 0;
}

.ttc-drawer-item__media {
	width: 72px;
	height: 72px;
	background: var(--ttc-summary-bg);
	border-radius: var(--ttc-radius-sm);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ttc-drawer-item__media img,
.ttc-drawer-item__img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	mix-blend-mode: multiply;
}

.ttc-drawer-item__body {
	min-width: 0;
}

.ttc-drawer-item__title {
	font-size: 0.92rem;
	font-weight: 500;
	line-height: 1.4;
	margin: 0 0 10px;
	color: var(--ttc-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ttc-drawer-item__title a {
	color: inherit;
	text-decoration: none;
}

.ttc-drawer-item__title a:hover {
	text-decoration: underline;
}

.ttc-drawer-item__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.ttc-drawer-item__price {
	font-size: 1rem;
	font-weight: 800;
	color: var(--ttc-text);
	white-space: nowrap;
}

/* ---------- Quantity stepper ---------- */
.ttc-qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--ttc-border);
	border-radius: 999px;
	overflow: hidden;
	background: var(--ttc-card-bg);
}

.ttc-qty__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	border: none;
	background: transparent;
	color: var(--ttc-text);
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.ttc-qty__btn:hover:not([disabled]) {
	background: var(--ttc-summary-bg);
}

.ttc-qty__btn[disabled] {
	color: var(--ttc-strike);
	cursor: not-allowed;
	opacity: 0.6;
}

.ttc-qty__btn:focus-visible {
	outline: 2px solid var(--ttc-primary);
	outline-offset: -2px;
}

.ttc-qty__value {
	min-width: 28px;
	text-align: center;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--ttc-text);
	user-select: none;
}

/* item busy (during qty AJAX) */
.ttc-drawer-item.is-busy {
	opacity: 0.6;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

/* ---------- Remove button (reuses cart trash language) ---------- */
.ttc-drawer-item__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid var(--ttc-border);
	background: var(--ttc-card-bg);
	border-radius: 50%;
	color: var(--ttc-trash);
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.ttc-drawer-item__remove:hover {
	background: #fdeaea;
	border-color: var(--ttc-trash);
}

.ttc-drawer-item__remove:active {
	transform: scale(0.94);
}

.ttc-drawer-item__remove:focus-visible {
	outline: 2px solid var(--ttc-trash);
	outline-offset: 2px;
}

/* item leaving: fade + collapse */
.ttc-drawer-item.is-leaving {
	overflow: hidden;
	pointer-events: none;
	opacity: 0;
	transform: translateX(12px);
	transition: opacity 0.28s ease, transform 0.28s ease, max-height 0.28s ease,
		padding-top 0.28s ease, padding-bottom 0.28s ease, border-width 0.28s ease;
	padding-top: 0;
	padding-bottom: 0;
	border-bottom-width: 0;
}

/* ---------- Footer ---------- */
.ttc-drawer__footer {
	flex-shrink: 0;
	padding: 18px 20px 22px;
	border-top: 1px solid var(--ttc-border);
	background: var(--ttc-card-bg);
}

.ttc-drawer__total-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.ttc-drawer__total-label {
	color: var(--ttc-text-muted);
	font-size: 0.95rem;
}

.ttc-drawer__total-value {
	font-weight: 800;
	font-size: 1.15rem;
	color: var(--ttc-text);
}

.ttc-drawer__checkout {
	display: block;
	width: 100%;
	text-align: center;
	background: var(--ttc-primary);
	color: #fff;
	font-weight: 600;
	font-size: 1rem;
	padding: 15px 16px;
	border-radius: 999px;
	text-decoration: none;
	transition: background-color 0.15s ease;
}

.ttc-drawer__checkout:hover,
.ttc-drawer__checkout:focus {
	background: var(--ttc-primary-hover);
	color: #fff;
}

/* ---------- Empty state ---------- */
.ttc-drawer__empty {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 40px 24px;
	gap: 8px;
}

.ttc-drawer__empty-icon {
	color: var(--ttc-text-muted);
	margin-bottom: 8px;
}

.ttc-drawer__empty-text {
	color: var(--ttc-text-muted);
	margin: 0 0 16px;
	font-size: 1rem;
}

.ttc-drawer__empty-btn {
	display: inline-block;
	background: var(--ttc-primary);
	color: #fff;
	font-weight: 600;
	padding: 12px 26px;
	border-radius: 999px;
	text-decoration: none;
	transition: background-color 0.15s ease;
}

.ttc-drawer__empty-btn:hover,
.ttc-drawer__empty-btn:focus {
	background: var(--ttc-primary-hover);
	color: #fff;
}

/* ---------- Body scroll lock ---------- */
body.ttc-drawer-open {
	overflow: hidden;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
	:root {
		--ttc-drawer-width: 90vw;
	}
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.ttc-drawer__panel,
	.ttc-drawer__overlay,
	.ttc-drawer-item.is-leaving {
		transition-duration: 0.01s;
	}
}
