/**
 * Avfarma Express Frontend Styles
 *
 * Harmonizado com o tema do site:
 * - Fonte: Poppins, Sans-serif
 * - Cor principal: var(--e-global-color-accent) #84BC00
 * - Cor de texto: var(--e-global-color-text) #796D64
 * - Bordas: 2px solid #999 ou 2px dotted #d0d0d0
 * - Background: #f5f5f5
 * - Border-radius: 3px (minimalista)
 * - Botões: border-radius 50px com box-shadow sutil
 *
 * @package Avfarma_Express
 * @since 1.0.0
 */

/* Neighborhood Selector Row */
.avfarma-express-selector-row td {
	padding: 15px 0 !important;
}

/* Neighborhood Selector Wrapper */
.avfarma-express-selector-wrapper {
	margin: 0;
	padding: 30px;
	background: #f5f5f5;
	border: 2px solid #999;
	border-radius: 4px;
}

/* Note: Standalone Neighborhood Selector styles removed - component deprecated (Requirements 1.1, 1.3)
   Neighborhood selection is now handled exclusively by the modal */

/* Shipping method label styling */
.woocommerce-shipping-methods label[for*="avfarma-express"] {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 5px;
}

/* Note: Additional standalone selector styles removed - see modal CSS for current styles */

/* Neighborhood Selector Container */
.avfarma-express-neighborhood-selector {
	margin: 0;
	padding: 30px;
	background: #f5f5f5;
	border: 2px solid #999;
	border-radius: 4px;
	position: relative;
}

.avfarma-express-neighborhood-selector label {
	display: block;
	margin-bottom: 10px;
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	font-size: 15px;
	color: var(--e-global-color-text, #796D64);
	letter-spacing: 0.3px;
}

/* Select2 Field Styling */
.avfarma-express-neighborhood-selector .select2-container {
	display: block;
	width: 100% !important;
}

.avfarma-express-neighborhood-selector .select2-container .select2-selection--single {
	height: 48px;
	border: none;
	border-radius: 3px;
	padding: 8px 15px;
	background: rgba(0, 0, 0, 0);
	box-shadow: none;
	transition: all 0.3s ease;
}

.avfarma-express-neighborhood-selector .select2-container .select2-selection--single:hover {
	background: rgba(0, 0, 0, 0.02);
}

.avfarma-express-neighborhood-selector .select2-container .select2-selection--single .select2-selection__rendered {
	line-height: 30px;
	padding-left: 0;
	color: var(--e-global-color-text, #796D64);
	font-family: "Poppins", Sans-serif;
	font-size: 15px;
	font-weight: 500;
}

.avfarma-express-neighborhood-selector .select2-container .select2-selection--single .select2-selection__arrow {
	height: 46px;
	right: 8px;
}

.avfarma-express-neighborhood-selector .select2-container--default .select2-selection--single .select2-selection__placeholder {
	color: #999;
	font-size: 15px;
}

/* Select2 Dropdown */
.select2-container--default .select2-dropdown {
	border: none;
	border-radius: 3px;
	box-shadow: 0 8px 18px rgba(56, 51, 117, 0.1);
	background: #ffffff;
	margin-top: 4px;
}

.select2-container--default .select2-search--dropdown {
	padding: 10px;
	background: #ffffff;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
	border: none;
	border-radius: 3px;
	padding: 10px 15px;
	font-family: "Poppins", Sans-serif;
	font-size: 15px;
	background: rgba(0, 0, 0, 0);
	box-shadow: none;
	outline: none;
	transition: all 0.3s ease;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
	background: rgba(0, 0, 0, 0.02);
	outline: none;
	box-shadow: none;
}

.select2-container--default .select2-results__option {
	padding: 12px 15px;
	font-family: "Poppins", Sans-serif;
	font-size: 15px;
	font-weight: 500;
	color: var(--e-global-color-text, #796D64);
	transition: all 0.15s ease;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
	background-color: rgba(0, 0, 0, 0.03);
	color: var(--e-global-color-text, #796D64);
}

.select2-container--default .select2-results__option[aria-selected=true] {
	background-color: rgba(0, 0, 0, 0.05);
	color: var(--e-global-color-text, #796D64);
	font-weight: 600;
}

/* Loading State */
.avfarma-express-neighborhood-selector.avfarma-loading {
	opacity: 0.6;
	pointer-events: none;
}

.avfarma-express-neighborhood-selector .avfarma-spinner {
	position: absolute;
	top: 50%;
	right: 15px;
	width: 20px;
	height: 20px;
	margin-top: -10px;
	border: 2px solid #f3f3f3;
	border-top: 2px solid var(--e-global-color-accent, #84BC00);
	border-radius: 50%;
	animation: avfarma-spin 1s linear infinite;
}

@keyframes avfarma-spin {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(360deg);
	}
}

/* Error Messages */
.avfarma-express-neighborhood-selector .avfarma-error {
	display: block;
	margin-top: 10px;
	padding: 10px 15px;
	background-color: #f8d7da;
	border: 1px solid #f5c6cb;
	border-radius: 3px;
	color: #721c24;
	font-family: "Poppins", Sans-serif;
	font-size: 14px;
	font-weight: 500;
}

/* Shipping Description */
.avfarma-shipping-description {
	margin-top: 5px;
	color: var(--e-global-color-text, #796D64);
	font-family: "Poppins", Sans-serif;
	font-size: 15px;
	font-weight: 500;
	font-style: italic;
}

.avfarma-shipping-description small {
	display: block;
	line-height: 1.4;
}

/* Responsive Styles for Mobile */
@media screen and (max-width: 768px) {
	.avfarma-express-neighborhood-selector {
		margin: 10px 0;
	}

	.avfarma-express-neighborhood-selector label {
		font-size: 14px;
	}

	.avfarma-express-neighborhood-selector .select2-container .select2-selection--single {
		height: 44px;
		font-size: 16px;
		/* Prevents zoom on iOS */
	}

	.avfarma-express-neighborhood-selector .select2-container .select2-selection--single .select2-selection__rendered {
		line-height: 32px;
	}

	.avfarma-express-neighborhood-selector .select2-container .select2-selection--single .select2-selection__arrow {
		height: 42px;
	}

	.avfarma-express-neighborhood-selector .avfarma-error {
		font-size: 13px;
		padding: 8px 12px;
	}
}

/* WooCommerce Theme Compatibility */
.woocommerce .avfarma-express-neighborhood-selector,
.woocommerce-page .avfarma-express-neighborhood-selector {
	clear: both;
}

/* Cart Page Specific Styles */
.woocommerce-cart .avfarma-express-neighborhood-selector {
	margin: 20px 0;
}

/* Checkout Page Specific Styles */
.woocommerce-checkout .avfarma-express-neighborhood-selector {
	margin: 15px 0 20px;
}

/* Focus States for Accessibility */
.avfarma-express-neighborhood-selector .select2-container--default.select2-container--focus .select2-selection--single,
.avfarma-express-neighborhood-selector .select2-container--default.select2-container--open .select2-selection--single {
	border-color: #0073aa;
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* Disabled State */
.avfarma-express-neighborhood-selector .select2-container--disabled .select2-selection--single {
	background-color: #f5f5f5;
	cursor: not-allowed;
	opacity: 0.6;
}

/* Select2 Clear Button */
.select2-container--default .select2-selection--single .select2-selection__clear {
	color: #999;
	font-size: 20px;
	font-weight: 400;
	margin-right: 10px;
	transition: color 0.2s ease;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
	color: #d9534f;
}

/* No Results Message */
.select2-container--default .select2-results__option.select2-results__message {
	color: #999;
	font-style: italic;
	padding: 15px;
	text-align: center;
}

/* Loading Results */
.select2-container--default .select2-results__option.loading-results {
	color: #999;
	padding: 15px;
	text-align: center;
}

/* Dropdown Arrow Animation */
.select2-container--default.select2-container--open .select2-selection__arrow b {
	border-color: transparent transparent #0073aa transparent;
	border-width: 0 5px 5px 5px;
}

/* Results Container */
.select2-container--default .select2-results>.select2-results__options {
	max-height: 300px;
	overflow-y: auto;
	padding: 5px 0;
}

/* Custom Scrollbar for Dropdown */
.select2-container--default .select2-results>.select2-results__options::-webkit-scrollbar {
	width: 8px;
}

.select2-container--default .select2-results>.select2-results__options::-webkit-scrollbar-track {
	background: #f5f5f5;
	border-radius: 4px;
}

.select2-container--default .select2-results>.select2-results__options::-webkit-scrollbar-thumb {
	background: #d0d0d0;
	border-radius: 4px;
}

.select2-container--default .select2-results>.select2-results__options::-webkit-scrollbar-thumb:hover {
	background: #b0b0b0;
}

/* Selected Neighborhood Display */
.avfarma-selected-display {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 15px;
	background: rgba(0, 0, 0, 0.02);
	border: 2px solid var(--e-global-color-accent, #84BC00);
	border-radius: 3px;
	margin-top: 10px;
	transition: all 0.3s ease;
}

.avfarma-selected-display:hover {
	background: rgba(0, 0, 0, 0.03);
	box-shadow: 0 8px 18px rgba(56, 51, 117, 0.1);
}

.avfarma-selected-text {
	flex: 1;
	color: var(--e-global-color-text, #796D64);
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	font-size: 15px;
}

.avfarma-clear-btn {
	background: #ffffff;
	border: 2px solid var(--e-global-color-accent, #84BC00);
	border-radius: 50px;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
	color: var(--e-global-color-accent, #84BC00);
	transition: all 0.2s ease;
	padding: 0;
	margin-left: 10px;
}

.avfarma-clear-btn:hover {
	background: var(--e-global-color-accent, #84BC00);
	border-color: var(--e-global-color-accent, #84BC00);
	color: #ffffff;
	box-shadow: 0 8px 18px rgba(56, 51, 117, 0.1);
	transform: scale(1.05);
}

.avfarma-clear-btn:active {
	transform: scale(0.95);
}

/* ========================================
   Shipping Type Selector Styles
   ======================================== */

/* Shipping Type Selector Container - Clean, no background or borders */
.avfarma-shipping-type-selector {
	margin: 0;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 0;
	clear: both;
	display: block;
	width: 100%;
}

.avfarma-shipping-type-selector h3,
.avfarma-type-selector-title {
	margin: 0 0 12px 0;
	padding: 0;
	font-family: "Poppins", Sans-serif;
	font-size: 16px;
	font-weight: 600;
	color: var(--e-global-color-text, #796D64);
	text-align: start !important;
}

/* Type Options Container - Horizontal layout */
.avfarma-type-options {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	align-items: center;
}

/* Remove margin from labels inside type options */
.avfarma-type-options .woocommerce-page label,
.avfarma-type-options label {
	margin-bottom: 0 !important;
}

/* Individual Type Option - Simple label with checkbox */
.avfarma-type-option {
	display: flex;
	align-items: center;
	padding: 0;
	background: transparent;
	border: none;
	cursor: pointer;
	margin: 0 20px 0 0;
}

.avfarma-type-option:last-child {
	margin-right: 0;
}

/* Radio Button Styling */
.avfarma-type-option input[type="radio"] {
	margin: 0 8px 0 0;
	cursor: pointer;
}

/* Label Text - Simple, bold when checked */
.avfarma-type-option span {
	font-family: "Poppins", Sans-serif;
	font-size: 15px;
	font-weight: 500;
	color: var(--e-global-color-text, #796D64);
	cursor: pointer;
	user-select: none;
}

/* Selected State - Just bold text */
.avfarma-type-option input[type="radio"]:checked+span {
	font-weight: 600;
}

/* ========================================
   Visibility Control Classes
   Requirements 3.5: Hide CEP calculator when in neighborhood mode
   Requirements 4.2, 4.5: Show CEP calculator when in CEP mode
   ======================================== */

/* Hide shipping destination and CEP form when in neighborhood mode */
body.calc-type-neighborhood .woocommerce-shipping-destination {
	display: none !important;
}

body.calc-type-neighborhood .shipping-calculator-form {
	display: none !important;
}

body.calc-type-neighborhood .shipping-calculator-button {
	display: none !important;
}

/* Hide ALL CEP calculator elements when in neighborhood mode */
body.calc-type-neighborhood .woocommerce-shipping-calculator {
	display: none !important;
}

body.calc-type-neighborhood a.shipping-calculator-button {
	display: none !important;
}

body.calc-type-neighborhood form.woocommerce-shipping-calculator {
	display: none !important;
}

body.calc-type-neighborhood .cart_totals .shipping-calculator-button {
	display: none !important;
}

body.calc-type-neighborhood .cart_totals a[href*="shipping-calculator"] {
	display: none !important;
}

/* Hide the "Calculate shipping" link text */
body.calc-type-neighborhood .cart_totals .woocommerce-shipping-calculator {
	display: none !important;
}

/* Hide CEP input field and update button */
body.calc-type-neighborhood #calc_shipping_postcode {
	display: none !important;
}

body.calc-type-neighborhood .shipping-calculator-form p {
	display: none !important;
}

body.calc-type-neighborhood button[name="calc_shipping"] {
	display: none !important;
}

/* Show shipping destination and CEP form when in CEP mode */
body.calc-type-cep .woocommerce-shipping-destination {
	display: block !important;
}

body.calc-type-cep .shipping-calculator-form {
	display: block !important;
}

body.calc-type-cep .shipping-calculator-button {
	display: inline-block !important;
}

body.calc-type-cep .woocommerce-shipping-calculator {
	display: block !important;
}

body.calc-type-cep a.shipping-calculator-button {
	display: inline-block !important;
}

body.calc-type-cep form.woocommerce-shipping-calculator {
	display: block !important;
}

body.calc-type-cep .cart_totals .shipping-calculator-button {
	display: inline-block !important;
}

body.calc-type-cep #calc_shipping_postcode {
	display: block !important;
}

body.calc-type-cep button[name="calc_shipping"] {
	display: inline-block !important;
}

/* Positioning: Type selector appears between subtotal and shipping */
.avfarma-shipping-type-selector {
	border-top: none;
	padding-top: 0;
	margin-top: 0;
	/* Force type selector to appear FIRST visually */
	order: -2;
}

/* Note: Standalone selector positioning styles removed - component deprecated (Requirements 1.1, 1.3) */

/* Force correct visual order in shipping section */
.woocommerce-shipping-calculator {
	display: flex;
	flex-direction: column;
}

/* Ensure shipping methods appear last */
.woocommerce-shipping-methods {
	order: 1;
}

/* CEP calculator form */
.shipping-calculator-form {
	order: 0;
}

/* ========================================
   Smooth Transitions
   ======================================== */

/* Smooth transitions for showing/hiding elements */
.woocommerce-shipping-calculator {
	transition: opacity 0.3s ease;
}

/* Shipping methods transition - smoother and faster */
.woocommerce-shipping-methods li {
	transition: opacity 0.2s ease;
}

/* Ensure smooth visibility changes */
.woocommerce-shipping-methods li[id*="avfarma-express"],
.woocommerce-shipping-methods li:not([id*="avfarma-express"]) {
	transition: opacity 0.2s ease;
}

/* ========================================
   Loading and Disabled States
   ======================================== */

/* Loading state for type selector */
.avfarma-shipping-type-selector.loading {
	opacity: 0.6;
	pointer-events: none;
	position: relative;
}

.avfarma-shipping-type-selector.loading::after {
	content: '';
	position: absolute;
	top: 50%;
	right: 15px;
	width: 20px;
	height: 20px;
	margin-top: -10px;
	border: 2px solid #f3f3f3;
	border-top: 2px solid var(--e-global-color-accent, #84BC00);
	border-radius: 50%;
	animation: avfarma-spin 1s linear infinite;
}

/* Disabled state */
.avfarma-type-option.disabled {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
}

/* ========================================
   Mobile Responsive Styles
   ======================================== */

@media screen and (max-width: 768px) {

	/* Shipping Type Selector */
	.avfarma-shipping-type-selector {
		margin: 0 0 15px 0;
		padding: 12px;
	}

	.avfarma-shipping-type-selector h3 {
		font-size: 14px;
		margin-bottom: 10px;
	}

	/* Type Options */
	.avfarma-type-options {
		gap: 8px;
	}

	.avfarma-type-option {
		padding: 10px 12px;
	}

	.avfarma-type-option span {
		font-size: 13px;
	}

	.avfarma-type-option input[type="radio"] {
		width: 16px;
		height: 16px;
		margin-right: 8px;
	}

	/* Reduce transition times on mobile for better performance */
	.woocommerce-shipping-calculator {
		transition: opacity 0.15s ease;
	}

	.woocommerce-shipping-methods li {
		transition: opacity 0.15s ease;
	}
}

/* Extra small devices (phones in portrait, less than 576px) */
@media screen and (max-width: 576px) {
	.avfarma-shipping-type-selector {
		padding: 10px;
		margin: 0 0 12px 0;
	}

	.avfarma-shipping-type-selector h3 {
		font-size: 13px;
		margin-bottom: 8px;
	}

	.avfarma-type-option {
		padding: 8px 10px;
	}

	.avfarma-type-option span {
		font-size: 12px;
		line-height: 1.3;
	}
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
	.avfarma-shipping-type-selector {
		border: 1px solid #000;
		box-shadow: none;
	}

	.avfarma-type-option:hover {
		transform: none;
		box-shadow: none;
	}
}

/* ========================================
   High Contrast Mode Support
   ======================================== */

@media (prefers-contrast: high) {
	.avfarma-shipping-type-selector {
		border-width: 3px;
	}

	.avfarma-type-option {
		border-width: 3px;
	}

	.avfarma-type-option.selected {
		border-width: 3px;
	}
}

/* ========================================
   Reduced Motion Support
   ======================================== */

@media (prefers-reduced-motion: reduce) {

	.avfarma-type-option,
	.woocommerce-shipping-calculator,
	.woocommerce-shipping-methods,
	.woocommerce-shipping-methods li {
		transition: none;
	}

	.avfarma-type-option:hover {
		transform: none;
	}

	.avfarma-type-option:active {
		transform: none;
	}
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
	.avfarma-shipping-type-selector {
		background: transparent;
		border-color: transparent;
	}

	.avfarma-shipping-type-selector h3 {
		color: #e0e0e0;
	}

	.avfarma-type-option {
		background: transparent;
		border-color: transparent;
	}

	.avfarma-type-option span {
		color: #d0d0d0;
	}

	.avfarma-type-option:hover {
		background: transparent;
		border-color: transparent;
	}

	.avfarma-type-option.selected {
		background: transparent;
		border-color: transparent;
	}

	.avfarma-type-option.selected span,
	.avfarma-type-option input[type="radio"]:checked+span {
		color: #6db3c8;
	}
}


/* ========================================
   Current Method Info Styles (Frontend)
   ======================================== */

/* Current Method Info Container */
.avfarma-current-method-info {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 18px 20px;
	background: #f5f5f5;
	border: 2px solid #999;
	border-radius: 3px;
	margin-bottom: 16px;
}

/* Method Summary */
.avfarma-method-summary {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	font-family: "Poppins", Sans-serif;
	font-size: 15px;
	font-weight: 500;
}

.avfarma-method-label {
	color: var(--e-global-color-text, #796D64);
}

.avfarma-method-value {
	font-weight: 600;
	color: var(--e-global-color-text, #796D64);
}

/* Change Method Link - Discrete link style */
.avfarma-change-method-link,
#avfarma-change-method-link {
	display: inline;
	font-family: "Poppins", Sans-serif;
	font-size: 13px;
	font-weight: 500;
	color: var(--e-global-color-accent, #84BC00);
	text-decoration: underline;
	cursor: pointer;
	background: transparent;
	border: none;
	padding: 0;
	margin-top: 4px;
	transition: color 0.3s ease;
}

.avfarma-change-method-link:hover,
#avfarma-change-method-link:hover {
	color: var(--e-global-color-text, #796D64);
	text-decoration: underline;
}

.avfarma-change-method-link:focus,
#avfarma-change-method-link:focus {
	outline: none;
	color: var(--e-global-color-text, #796D64);
}

/* Responsive styles for current method info */
@media screen and (max-width: 768px) {
	.avfarma-current-method-info {
		padding: 15px;
	}

	.avfarma-method-summary {
		font-size: 14px;
	}

	.avfarma-change-method-link,
	#avfarma-change-method-link {
		font-size: 12px;
	}
}

@media screen and (max-width: 480px) {
	.avfarma-current-method-info {
		padding: 12px;
	}

	.avfarma-method-summary {
		font-size: 13px;
	}

	.avfarma-change-method-link,
	#avfarma-change-method-link {
		font-size: 11px;
	}
}


/* ========================================
   Avfarma Express Shipping Method Display
   Hide price from label, show only method name
   Price is moved to the "Shipping" header by JavaScript
   ======================================== */

/* Hide the price inside the Avfarma Express label */
.woocommerce-shipping-methods label[for*="avfarma-express"] .woocommerce-Price-amount,
.woocommerce-shipping-methods label[for*="avfarma-express"] .amount,
.woocommerce-shipping-methods label[for*="avfarma_express"] .woocommerce-Price-amount,
.woocommerce-shipping-methods label[for*="avfarma_express"] .amount {
	display: none !important;
}

/* Hide colon before price in label */
.woocommerce-shipping-methods label[for*="avfarma-express"],
.woocommerce-shipping-methods label[for*="avfarma_express"] {
	font-family: "Poppins", Sans-serif;
	font-size: 14px;
	font-weight: 500;
	color: var(--e-global-color-text, #796D64);
}

/* Style the shipping row header - use flexbox for proper alignment */
.woocommerce-shipping-totals.shipping th,
tr.woocommerce-shipping-totals th,
tr.shipping th {
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	color: var(--e-global-color-text, #796D64);
	display: flex !important;
	justify-content: space-between !important;
	align-items: center !important;
	width: 100% !important;
}

/* Style the price in shipping header - aligned to the right like subtotal/total */
.avfarma-shipping-price {
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	color: var(--e-global-color-text, #796D64);
	margin-left: auto;
	text-align: right;
}

.avfarma-shipping-price .woocommerce-Price-amount,
.avfarma-shipping-price .amount {
	display: inline !important;
}

/* Avfarma Express method container styling */
.woocommerce-shipping-methods li:has(input[id*="avfarma-express"]),
.woocommerce-shipping-methods li:has(input[id*="avfarma_express"]) {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

/* Hide the radio button for single shipping method */
.woocommerce-shipping-methods li:only-child input[type="radio"],
.woocommerce-shipping-methods li:only-child input[type="hidden"] + label::before {
	display: none;
}

/* Avfarma Express description styling */
.woocommerce-shipping-methods li:has(input[id*="avfarma-express"]) .avfarma-shipping-description,
.woocommerce-shipping-methods li:has(input[id*="avfarma_express"]) .avfarma-shipping-description {
	margin-top: 4px;
	padding-left: 0;
}

.woocommerce-shipping-methods li:has(input[id*="avfarma-express"]) .avfarma-shipping-description small,
.woocommerce-shipping-methods li:has(input[id*="avfarma_express"]) .avfarma-shipping-description small {
	font-family: "Poppins", Sans-serif;
	font-size: 13px;
	font-weight: 400;
	color: var(--e-global-color-text, #796D64);
	opacity: 0.8;
}