/**
 * Delivery Checkout Styles
 * Beautiful delivery fields with map and calendar integration
 */

/* ===== intl-tel-input (phone field) ===== */
#billing_phone_field .iti {
    display: block !important;
    width: 100% !important;
}
#billing_phone_field .iti input,
#billing_phone_field .iti input[type="tel"] {
    width: 100% !important;
    box-sizing: border-box !important;
    padding-left: 105px !important; /* space for flag + dial code */
    height: 44px !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-family: 'Noto Sans Armenian', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    background-color: rgba(255, 255, 255, 0.6) !important;
}
#billing_phone_field .iti input::placeholder {
    color: rgba(0, 0, 0, 0.35) !important;
    opacity: 1 !important;
}
#billing_phone_field .iti input:focus {
    border-color: #233E2A !important;
    outline: none !important;
    background-color: rgba(255, 255, 255, 0.85) !important;
}
/* The flag + dial-code dropdown button */
#billing_phone_field .iti__flag-container {
    left: 0;
}
#billing_phone_field .iti__selected-flag {
    padding: 0 10px 0 10px !important;
    border-right: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 6px 0 0 6px;
    height: 100%;
    /* Remove theme's extra arrow */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: none !important;
}
/* Hide THEME's extra pseudo-element arrow on the flag button */
#billing_phone_field .iti__selected-flag::after,
#billing_phone_field .iti__selected-flag::before,
#billing_phone_field .iti__flag-container::after,
#billing_phone_field .iti__flag-container::before {
    display: none !important;
    content: none !important;
}

/* Armenian Font */
.delivery-map-container,
.delivery-calendar-container,
.delivery-info-box,
.delivery-time-slot {
	font-family: 'Noto Sans Armenian', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Hide standard WooCommerce address fields that duplicate custom delivery fields */
#billing_country_field.hidden-field,
#billing_address_1_field.hidden-field,
#billing_address_2_field.hidden-field,
#billing_city_field.hidden-field,
#billing_state_field.hidden-field,
#billing_postcode_field.hidden-field,
.woocommerce-billing-fields__field-wrapper .hidden-field,
.woocommerce-billing-fields .hidden-field {
	display: none !important;
	visibility: hidden !important;
	height: 0 !important;
	overflow: hidden !important;
	margin: 0 !important;
	padding: 0 !important;
}

/* Delivery Fields Container */
#billing_delivery_city_field,
#billing_delivery_district_field,
#billing_intercom_code_field,
#billing_delivery_address_field,
#billing_delivery_date_field {
	margin-bottom: 20px !important;
}

/* Hide delivery time field - it's handled by calendar */
#billing_delivery_time_field {
	display: none !important;
	visibility: hidden !important;
	height: 0 !important;
	overflow: hidden !important;
	margin: 0 !important;
	padding: 0 !important;
}

#billing_delivery_district_field {
	display: none; /* Hidden until city is selected */
}

/* Fix text display in delivery inputs */
#billing_delivery_city_field input,
#billing_delivery_city_field select,
#billing_delivery_district_field input,
#billing_delivery_district_field select,
#billing_intercom_code_field input,
#billing_delivery_address_field input,
#billing_delivery_address_field textarea {
	width: 100% !important;
	padding: 12px 14px !important;
	border: 2px solid #e0e0e0 !important;
	border-radius: 6px !important;
	font-size: 14px !important;
	line-height: 1.5 !important;
	min-height: 44px !important;
	height: auto !important;
	overflow: visible !important;
	text-overflow: clip !important;
	white-space: normal !important;
	word-wrap: break-word !important;
	font-family: 'Noto Sans Armenian', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
	box-sizing: border-box !important;
}

#billing_delivery_city_field select,
#billing_delivery_district_field select {
	height: 44px !important;
	min-height: 44px !important;
	appearance: auto !important;
	-webkit-appearance: menulist !important;
	-moz-appearance: menulist !important;
}

#billing_delivery_address_field textarea {
	min-height: 100px !important;
	resize: vertical !important;
	overflow-y: auto !important;
}

/* Map Container */
.delivery-map-container {
	margin-top: 15px;
	margin-bottom: 20px;
	border-radius: 8px;
	border: 2px solid #e0e0e0;
	height: 400px;
	position: relative;
	overflow: hidden;
	z-index: 100 !important; /* Make sure map container sits above other fields */
}

/* Ensure yandex map search results don't get cut off */
.ymaps-2-1-79-searchbox {
    margin-top: 10px !important;
}

#delivery-map {
	width: 100%;
	height: 100%;
}

.delivery-map-info {
	position: absolute;
	top: 10px;
	left: 10px;
	background: rgba(255, 255, 255, 0.95);
	padding: 10px 15px;
	border-radius: 6px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	z-index: 1000;
	font-size: 13px;
	font-weight: 600;
	color: #333;
}

.delivery-map-info span {
	color: #233E2A;
	margin-left: 5px;
}

/* Select on Map Button - Beautiful and Visible */
.select-on-map-button,
#select-on-map-btn {
	width: 100% !important;
	margin-top: 15px !important;
	padding: 14px 20px !important;
	background: linear-gradient(135deg, #B30A08 0%, #c91e2d 100%) !important;
	color: white !important;
	border: none !important;
	border-radius: 8px !important;
	font-size: 16px !important;
	font-weight: 600 !important;
	font-family: 'Noto Sans Armenian', sans-serif !important;
	cursor: pointer !important;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
	box-shadow: 0 4px 12px rgba(231, 38, 55, 0.3) !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	text-align: center !important;
	position: relative !important;
	overflow: hidden !important;
}

.select-on-map-button::before,
#select-on-map-btn::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
	transition: left 0.5s;
}

.select-on-map-button:hover::before,
#select-on-map-btn:hover::before {
	left: 100%;
}

.select-on-map-button:hover,
#select-on-map-btn:hover {
	background: linear-gradient(135deg, #c91e2d 0%, #a0171f 100%) !important;
	transform: translateY(-2px) !important;
	box-shadow: 0 6px 16px rgba(231, 38, 55, 0.4) !important;
}

.select-on-map-button:active,
#select-on-map-btn:active {
	transform: translateY(0) !important;
	box-shadow: 0 2px 8px rgba(231, 38, 55, 0.3) !important;
}

.select-on-map-button.active,
#select-on-map-btn.active {
	background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%) !important;
	box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4) !important;
	animation: pulse 2s infinite;
}

@keyframes pulse {
	0%, 100% {
		box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
	}
	50% {
		box-shadow: 0 4px 20px rgba(76, 175, 80, 0.6);
	}
}

.select-on-map-button svg,
#select-on-map-btn svg {
	flex-shrink: 0;
	vertical-align: middle;
}

@keyframes spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

/* Calendar Container */
.delivery-calendar-container {
	margin-top: 15px;
	margin-bottom: 20px;
	border: 2px solid #e0e0e0;
	border-radius: 8px;
	overflow: visible;
	background: #fff;
}

.delivery-calendar-wrapper {
	display: flex;
	flex-direction: row;
	min-height: 400px;
	overflow: visible;
	position: relative;
}

.delivery-calendar-side {
	flex: 1;
	padding: 15px;
	border-right: 1px solid #e0e0e0;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	overflow: visible !important;
}

.flatpickr-calendar.inline {
	overflow: visible !important;
	box-shadow: none !important;
	position: relative !important;
	padding-top: 20px !important;
}

.delivery-time-slots-side {
	width: 250px;
	padding: 20px;
	background: #f9f9f9;
	overflow-y: auto;
	max-height: 400px;
	display: flex;
	flex-direction: column;
}

.delivery-time-slots-title {
	font-size: 16px;
	font-weight: 700;
	margin-bottom: 15px;
	color: #333;
	padding-bottom: 10px;
	border-bottom: 2px solid #233E2A;
}

.delivery-time-slots-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 8px;
}

.delivery-time-slot {
	padding: 12px 16px;
	background: #fff;
	border: 2px solid #e0e0e0;
	border-radius: 8px;
	cursor: pointer;
	text-align: center;
	font-weight: 600;
	font-size: 14px;
	transition: all 0.2s ease;
	color: #333;
	width: 100%;
	font-family: 'Noto Sans Armenian', sans-serif;
}

.delivery-time-slot:hover:not(.disabled) {
	border-color: #233E2A;
	background: #fff5f5;
	transform: translateY(-1px);
	box-shadow: 0 2px 4px rgba(255, 107, 107, 0.2);
}

.delivery-time-slot.selected {
	background: #233E2A;
	color: #fff;
	border-color: #233E2A;
	box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.delivery-time-slot.disabled {
	opacity: 0.4;
	cursor: not-allowed;
	background: #f5f5f5;
}

/* Distance and Time Info */
.delivery-info-box {
	margin-top: 15px;
	padding: 15px;
	background: linear-gradient(135deg, #E8F5E9 0%, #F1F8E9 100%);
	border: 2px solid #4CAF50;
	border-radius: 8px;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 15px;
}

.delivery-info-item {
	text-align: center;
}

.delivery-info-item strong {
	display: block;
	font-size: 18px;
	color: #2E7D32;
	margin-bottom: 5px;
}

.delivery-info-item span {
	font-size: 13px;
	color: #666;
}

/* Custom Calendar Styling */
.uniform-cal {
	width: 100%;
	max-width: 350px;
	margin: 0 auto;
	font-family: 'Noto Sans Armenian', sans-serif;
	background: #fff;
	border-radius: 8px;
	padding: 10px;
}
.uniform-cal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}
.uniform-cal-prev, .uniform-cal-next {
	background: none;
	border: none;
	font-size: 20px;
	cursor: pointer;
	color: #333;
	padding: 5px 15px;
	border-radius: 4px;
	transition: background 0.2s;
}
.uniform-cal-prev:hover, .uniform-cal-next:hover {
	background: #f0f0f0;
}
.uniform-cal-prev.disabled {
	color: #ccc;
	cursor: not-allowed;
	background: none;
}
.uniform-cal-title {
	font-weight: 600;
	font-size: 16px;
	color: #333;
	display: flex;
	align-items: center;
	gap: 10px;
}
.uniform-cal-month-select {
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 5px 10px;
	font-size: 14px;
	font-family: inherit;
	cursor: pointer;
	outline: none;
	background: #fff;
}
.uniform-cal-year {
	font-size: 15px;
}
.uniform-cal-weekdays {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	text-align: center;
	font-weight: 600;
	color: #666;
	font-size: 13px;
	margin-bottom: 10px;
}
.uniform-cal-days {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 5px;
}
.uniform-cal-day {
	aspect-ratio: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	font-size: 14px;
	cursor: pointer;
	color: #333;
	transition: all 0.2s;
	border: 1px solid transparent;
}
.uniform-cal-day:hover:not(.empty):not(.disabled) {
	background: #fff5f5;
	border-color: #fca5a5;
}
.uniform-cal-day.empty {
	cursor: default;
}
.uniform-cal-day.disabled {
	color: #ccc;
	cursor: not-allowed;
	background: transparent;
}
.uniform-cal-day.today {
	border-color: #233E2A;
	font-weight: bold;
}
.uniform-cal-day.selected {
	background: #233E2A;
	color: #fff;
	border-color: #233E2A;
	box-shadow: 0 2px 6px rgba(255,107,107,0.4);
}

/* Integration with checkout styles */

.custom-checkout-page #billing_delivery_city_field label,
.custom-checkout-page #billing_delivery_district_field label,
.custom-checkout-page #billing_intercom_code_field label,
.custom-checkout-page #billing_delivery_address_field label,
.custom-checkout-page #billing_delivery_date_field label {
	font-weight: 600 !important;
	color: #333 !important;
	font-size: 14px !important;
}

.custom-checkout-page #billing_delivery_city_field select,
.custom-checkout-page #billing_delivery_district_field select,
.custom-checkout-page #billing_intercom_code_field input,
.custom-checkout-page #billing_delivery_address_field textarea {
	border: 2px solid #e0e0e0 !important;
	border-radius: 6px !important;
	padding: 12px 14px !important;
	font-size: 14px !important;
	line-height: 1.5 !important;
	min-height: 44px !important;
	height: auto !important;
	transition: border-color 0.2s ease !important;
	overflow: visible !important;
	text-overflow: clip !important;
	white-space: normal !important;
	word-wrap: break-word !important;
	font-family: 'Noto Sans Armenian', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.custom-checkout-page #billing_delivery_city_field input[type="text"],
.custom-checkout-page #billing_delivery_district_field input[type="text"],
.custom-checkout-page #billing_intercom_code_field input[type="text"],
.custom-checkout-page #billing_delivery_address_field input[type="text"] {
	border: 2px solid #e0e0e0 !important;
	border-radius: 6px !important;
	padding: 12px 14px !important;
	font-size: 14px !important;
	line-height: 1.5 !important;
	min-height: 44px !important;
	height: auto !important;
	transition: border-color 0.2s ease !important;
	overflow: visible !important;
	text-overflow: clip !important;
	white-space: normal !important;
	word-wrap: break-word !important;
	font-family: 'Noto Sans Armenian', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.custom-checkout-page #billing_delivery_city_field select:focus,
.custom-checkout-page #billing_delivery_district_field select:focus,
.custom-checkout-page #billing_intercom_code_field input:focus,
.custom-checkout-page #billing_delivery_address_field textarea:focus {
	border-color: #233E2A !important;
	outline: none !important;
}

/* Responsive */
@media (max-width: 992px) {
	.delivery-calendar-wrapper {
		flex-direction: column !important;
	}

	.delivery-time-slots-side {
		width: 100%;
		border-right: none;
		border-top: 1px solid #e0e0e0;
		max-height: 200px;
	}

	.delivery-map-container {
		height: 300px;
	}

	.delivery-info-box {
		grid-template-columns: 1fr;
	}
}

