/**
 * Avfarma Express Frontend Styles
 *
 * Custom cart layout: two-column flexbox with integrated shipping calculator.
 *
 * @package Avfarma_Express
 * @since 1.3.0
 */

/* ========================================
   Select2 Dropdown (used by fallback selects)
   ======================================== */

.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: #796D64;
	transition: all 0.15s ease;
}

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

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

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

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

/* ========================================
   Avfarma Cart Layout (v1.3)
   Two-column flexbox: products left, summary right
   ======================================== */

/* Override theme grid on .woocommerce when our cart is present */
.woocommerce:has(.avfarma-cart-wrapper) {
	display: block !important;
}

/* Main wrapper - full width flexbox layout */
.avfarma-cart-wrapper {
	display: flex;
	gap: 30px;
	align-items: flex-start;
	width: 100%;
	box-sizing: border-box;
}

/* Left column: Products - takes all remaining space */
.avfarma-cart-products {
	flex: 1;
	min-width: 0;
	background: transparent !important;
}

/* Override WooCommerce form constraints inside products column */
.avfarma-cart-products .woocommerce-cart-form {
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	background: transparent !important;
	border: none !important;
	box-shadow: none !important;
	padding: 0 !important;
}

/* Right column: Summary */
.avfarma-cart-summary {
	width: 380px;
	flex-shrink: 0;
	position: sticky;
	top: 30px;
	
}

/* Override WooCommerce/theme cart-collaterals constraints */
.avfarma-cart-summary .cart-collaterals {
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	margin: 0 !important;
}

/* Override WooCommerce cart_totals constraints */
.avfarma-cart-summary .cart_totals,
.avfarma-cart-summary .avfarma-cart-totals {
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	border: 2px solid #999;
}

/* ========================================
   Cart Table (CSS Grid for perfect alignment)
   ======================================== */

/* Shared grid template for header and items */
.avfarma-cart-header,
.avfarma-cart-item {
	display: grid;
	grid-template-columns: 32px 1fr 110px 130px 110px;
	gap: 12px;
	align-items: center;
	font-family: "Poppins", Sans-serif;
}

/* Header row */
.avfarma-cart-header {
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	color: #796D64;
	padding: 8px 0;
}

.avfarma-cart-header .avfarma-col-price,
.avfarma-cart-header .avfarma-col-qty {
	text-align: center;
}

.avfarma-cart-header .avfarma-col-total {
	text-align: right;
}

/* Divider */
.avfarma-cart-divider {
	border: none;
	border-top: 1px solid #e0e0e0;
	margin: 0;
}

/* Items container */
.avfarma-cart-items {
	display: flex;
	flex-direction: column;
}

/* Item row */
.avfarma-cart-item {
	padding: 14px 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
	background: transparent !important;
}

.avfarma-cart-item:last-child {
	border-bottom: none;
}

/* Col 1: Remove button (×) */
.avfarma-item-remove {
	justify-self: center;
}

.avfarma-item-remove .remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	color: #bbb;
	font-size: 18px;
	text-decoration: none;
	transition: all 0.2s ease;
}

.avfarma-item-remove .remove:hover {
	background: #f8d7da;
	color: #721c24;
}

/* Col 2: Product (thumbnail + name) */
.avfarma-col-product {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

.avfarma-item-thumbnail {
	width: 60px;
	flex-shrink: 0;
}

.avfarma-item-thumbnail img {
	width: 100%;
	height: auto;
	border-radius: 4px;
	display: block;
}

.avfarma-item-name {
	font-size: 14px;
	font-weight: 500;
	color: #796D64;
	line-height: 1.3;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.avfarma-item-name a {
	text-decoration: none;
	color: inherit;
}

/* Col 3: Price */
.avfarma-col-price {
	text-align: center;
	font-size: 14px;
	color: #796D64;
}

/* Col 4: Quantity */
.avfarma-col-qty {
	text-align: center;
}

.avfarma-qty-control {
	display: inline-flex;
	align-items: center;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 24px;
	background: rgba(0, 0, 0, 0.02);
	padding: 0px;
	gap: 0;
}

.avfarma-qty-input {
	height: 28px;
	padding: 0;
	text-align: center;
	border: none !important;
	border-radius: 0;
	font-family: "Poppins", Sans-serif;
	font-size: 14px;
	font-weight: 600;
	background: transparent !important;
	color: #796D64 !important;
	outline: none;
	-moz-appearance: textfield;
	appearance: textfield;
}

.avfarma-qty-input::-webkit-inner-spin-button,
.avfarma-qty-input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Sold individually — no buttons, clean look */
.avfarma-qty-input[readonly] {
	width: auto;
	font-weight: 600;
}

.avfarma-qty-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none !important;
	border-radius: 50%;
	background: transparent !important;
	color: #aaa !important;
	font-size: 15px;
	cursor: pointer;
	user-select: none;
	transition: all 0.2s ease;
	font-family: "Poppins", Sans-serif;
	line-height: 1;
}

.avfarma-qty-btn:hover {
	background: rgba(132, 188, 0, 0.12);
	color: #84BC00;
}

/* Col 5: Total */
.avfarma-col-total {
	text-align: right;
	font-weight: 600;
	font-size: 14px;
	color: #796D64;
}

/* Cart Actions (coupon + update) */
.avfarma-cart-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid #e0e0e0;
	flex-wrap: wrap;
}

.avfarma-cart-actions .coupon {
	display: flex;
	gap: 8px;
	flex: 1;
}

.avfarma-cart-actions .coupon input {
	flex: 1;
	min-width: 120px;
}

/* ========================================
   Cart Totals / Summary
   ======================================== */

.avfarma-cart-totals {
	background: transparent;
	border: none;
	border-radius: 8px;
	padding: 24px;
	font-family: "Poppins", Sans-serif;
}

/* Loading state — fades the summary while updating */
.avfarma-cart-totals.avfarma-loading {
	position: relative;
	pointer-events: none;
}

.avfarma-cart-totals.avfarma-loading::after {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.15);
	backdrop-filter: blur(1px);
	border-radius: 8px;
	z-index: 10;
	animation: avfarma-fade-in 0.15s ease;
}

@keyframes avfarma-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* CEP Section */
.avfarma-cep-section {
	margin-bottom: 10px;
}

.avfarma-cep-title {
	font-family: "Poppins", Sans-serif;
	font-size: 16px;
	font-weight: 700;
	margin: 0 0 4px 0;
	text-transform: uppercase;
	color: #796D64;
}

.avfarma-cep-subtitle {
	font-family: "Poppins", Sans-serif;
	font-size: 14px;
	color: #aaa;
	margin: 0 0 12px 0;
}

.avfarma-cep-calculator {
	display: flex;
	gap: 8px;
}

.avfarma-cep-calculator input{
	border-color: #ddd !important;
}

.avfarma-cep-field {
	flex: 1;
	padding: 10px 12px;
	border: 1px solid rgba(128, 128, 128, 0.3);
	border-radius: 6px;
	font-family: "Poppins", Sans-serif;
	font-size: 16px;
	background: transparent;
	color: inherit;
}

.avfarma-cep-field::placeholder {
	color: #aaa;
	opacity: 1;
}

.avfarma-cep-field:focus {
	border-color: #84BC00;
	outline: none;
}

.avfarma-cep-button {
	padding: 10px 20px !important;
	background: #84BC00 !important;
	color: #fff !important;
	border: 2px solid #84BC00 !important;
	border-radius: 6px;
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: opacity 0.2s;
}

.avfarma-cep-button:hover {
	opacity: 0.9;
}

.avfarma-cep-button:disabled,
.avfarma-cep-button.loading {
	opacity: 0.6;
	cursor: not-allowed;
}

.avfarma-cep-message {
	margin-top: 8px;
	padding: 8px 12px;
	border-radius: 6px;
	font-family: "Poppins", Sans-serif;
	font-size: 13px;
}

.avfarma-cep-message.error {
	background: rgba(220, 53, 69, 0.12);
	color: #f8d7da;
	border: 1px solid rgba(220, 53, 69, 0.25);
}

.avfarma-cep-message.success {
	background: rgba(132, 188, 0, 0.12);
	color: #c3e6cb;
	border: 1px solid rgba(132, 188, 0, 0.25);
}

/* Address Display */
.avfarma-address-display {
	font-family: "Poppins", Sans-serif;
	font-size: 13px;
	color: #796D64;
	padding: 10px 14px;
	margin: 12px 0 0 0;
	background: rgba(132, 188, 0, 0.08);
	border: 1px solid rgba(132, 188, 0, 0.2);
	border-radius: 6px;
}

.avfarma-address-display .avfarma-address-label {
	font-weight: 700;
	font-size: 11px;
	text-transform: uppercase;
	color: #aaa;
	display: block;
	margin-bottom: 2px;
}

.avfarma-address-display .avfarma-address-text {
	font-weight: 600;
}

/* Section Dividers */
.avfarma-section-divider {
	border: none;
	border-top: 1px solid rgba(128, 128, 128, 0.2);
	margin: 16px 0;
}

/* Shipping Sections */
.avfarma-shipping-section {
	margin-bottom: 10px;
	margin-top: 10px;

}

.avfarma-section-title {
	font-family: "Poppins", Sans-serif;
	font-size: 13px;
	font-weight: 700;
	margin: 0 0 8px 0;
	text-transform: uppercase;
	color: #796D64;
}

/* ========================================
   Shipping Method Cards
   ======================================== */

.avfarma-methods-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.avfarma-method-card {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	background: #eee;
	gap: 12px;
}

.avfarma-method-card:hover {
	background: #ddd;
}

/* Selected state — highlighted + expanded details */
.avfarma-method-card.selected {
	background: #eee;
	border-color: #ddd;
}

/* Checkbox indicator */
.avfarma-method-check {
	width: 18px;
	height: 18px;
	min-width: 18px;
	border: 2px solid #aaa;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.avfarma-method-card.selected .avfarma-method-check {
	border-color: #84BC00;
	background: #84BC00;
}

.avfarma-method-card.selected .avfarma-method-check::after {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #fff;
}

.avfarma-method-info {
	flex: 1;
	min-width: 0;
}

.avfarma-method-name {
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	font-size: 14px;
	color: #796D64;
}

/* Delivery info — always visible */
.avfarma-method-delivery {
	font-family: "Poppins", Sans-serif;
	font-size: 12px;
	color: #aaa;
	margin-top: 2px;
}

.avfarma-method-price {
	font-family: "Poppins", Sans-serif;
	font-weight: 700;
	font-size: 14px;
	color: #796D64;
	white-space: nowrap;
	margin-left: 12px;
}

/* ========================================
   Fallback Select inside method card
   ======================================== */

.avfarma-method-card--fallback {
	cursor: default;
	flex-wrap: wrap;
}

.avfarma-method-card--fallback .avfarma-method-delivery {
	display: block;
}

/* Edit selection button (pencil icon) */
.avfarma-edit-selection {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border: none !important;
	border-radius: 50%;
	background: transparent !important;
	color: #aaa !important;
	cursor: pointer;
	transition: all 0.2s ease;
	flex-shrink: 0;
	padding: 0;
}

.avfarma-edit-selection:hover {
	background: rgba(0, 0, 0, 0.06);
	color: #796D64;
}

.avfarma-edit-selection svg {
	width: 15px;
	height: 15px;
}

.avfarma-fallback-select {
	width: 100%;
	margin-top: 8px;
}

.avfarma-fallback-select .select2-container {
	width: 100% !important;
}

/* ========================================
   Totals Section
   ======================================== */

.avfarma-totals-section {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top:10px;
}

.avfarma-totals-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-family: "Poppins", Sans-serif;
	font-size: 14px;
}

.avfarma-totals-label {
	color: #aaa;
}

.avfarma-totals-value {
	font-weight: 600;
	color: #796D64;
}

.avfarma-total-row {
	padding-top: 8px;
	border-top: 2px solid rgba(128, 128, 128, 0.3);
	font-size: 18px;
}

.avfarma-total-row .avfarma-totals-label {
	font-weight: 700;
	color: #796D64;
}

.avfarma-total-row .avfarma-totals-value {
	font-weight: 700;
	color: #796D64;
}

/* ========================================
   Update Cart Button
   ======================================== */

.avfarma-update-cart-section {
	margin-bottom: 16px;
	width: 100%;
	display: flex;
	justify-content: center;
}

.avfarma-update-cart-btn {
	display: block;
	width: 100% !important;
	padding: 10px !important;
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	font-size: 13px;
	text-align: center;
	text-transform: uppercase;
	border-radius: 6px;
	box-sizing: border-box;
	background: transparent !important;
	color: #796D64 !important;
	border: 1px solid rgba(128, 128, 128, 0.3) !important;
	cursor: pointer;
	transition: all 0.2s ease;
}

.avfarma-update-cart-btn:hover:not(:disabled) {
	background: rgba(0, 0, 0, 0.03) !important;
	border-color: rgba(128, 128, 128, 0.5) !important;
}

.avfarma-update-cart-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Spinner for loading states */
.avfarma-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(121, 109, 100, 0.3);
	border-top-color: #796D64;
	border-radius: 50%;
	animation: avfarma-spin 0.6s linear infinite;
	vertical-align: middle;
}

@keyframes avfarma-spin {
	to { transform: rotate(360deg); }
}

/* ========================================
   Checkout Section
   ======================================== */

.avfarma-checkout-section {
	margin-top: 16px;
}

/* ========================================
   Coupon Section
   ======================================== */

.avfarma-coupon-section {
	margin-top: 16px;
}

.avfarma-checkout-section .checkout-button,
.avfarma-checkout-section a.checkout-button {
	display: block;
	width: 100%;
	text-align: center;
	padding: 15px 10px !important;
	font-family: "Poppins", Sans-serif;
	font-weight: 600;
	font-size: 14px;
	text-transform: uppercase;
	border-radius: 6px;
	box-sizing: border-box;
	background: #84BC00 !important;
	color: #fff !important;
	border: none;
	cursor: pointer;
	transition: opacity 0.2s;
}

.avfarma-checkout-section .checkout-button:hover,
.avfarma-checkout-section a.checkout-button:hover {
	opacity: 0.9;
	color: #fff;
	text-decoration: none;
}

/* ========================================
   Responsive: Mobile
   ======================================== */

@media screen and (max-width: 768px) {
	.avfarma-cart-wrapper {
		flex-direction: column;
		gap: 20px;
	}

	.avfarma-cart-summary {
		width: 100%;
		position: static;
	}

	.avfarma-cart-header {
		display: none;
	}

	.avfarma-cart-item {
		display: flex;
		flex-wrap: wrap;
		gap: 8px;
		position: relative;
		padding: 12px 0 12px 36px;
	}

	.avfarma-item-remove {
		position: absolute;
		left: 0;
		top: 14px;
	}

	.avfarma-col-product {
		width: 100%;
	}

	.avfarma-col-price,
	.avfarma-col-qty,
	.avfarma-col-total {
		flex: 1;
		text-align: center;
	}

	.avfarma-cart-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.avfarma-cart-actions .coupon {
		flex-direction: column;
	}
}

@media screen and (max-width: 480px) {
	.avfarma-cart-totals {
		padding: 16px;
	}

	.avfarma-cep-calculator {
		flex-direction: column;
	}

	.avfarma-cep-button {
		width: 100%;
	}
}
