/**
 * COD WooCommerce RTL Styles
 *
 * RTL-specific overrides for Arabic language support
 *
 * @package COD_WooCommerce
 * @version 1.0.0
 */

/* ===== RTL Base Direction ===== */
.cod-order-form-wrapper[dir="rtl"],
.cod-order-form-wrapper.cod-form-rtl {
	direction: rtl;
	text-align: right;
}

/* ===== Section Title Bar (Reversed Position) ===== */
.cod-form-rtl .cod-section-title::before,
.cod-order-form-wrapper[dir="rtl"] .cod-section-title::before {
	margin-right: 0;
	margin-left: 0.75rem;
}

/* ===== Form Inputs Alignment ===== */
.cod-form-rtl .cod-form-label,
.cod-order-form-wrapper[dir="rtl"] .cod-form-label {
	text-align: right;
}

.cod-form-rtl .cod-required,
.cod-order-form-wrapper[dir="rtl"] .cod-required {
	margin-left: 0;
	margin-right: 0.25rem;
}

.cod-form-rtl .cod-optional,
.cod-order-form-wrapper[dir="rtl"] .cod-optional {
	margin-left: 0;
	margin-right: 0.25rem;
}

/* ===== Product Display RTL ===== */
.cod-form-rtl .cod-product-image,
.cod-order-form-wrapper[dir="rtl"] .cod-product-image {
	margin-right: 0;
	margin-left: 1rem;
}

/* ===== Price Table RTL ===== */
.cod-form-rtl .cod-price-row,
.cod-order-form-wrapper[dir="rtl"] .cod-price-row {
	flex-direction: row-reverse;
}

.cod-form-rtl .cod-price-label,
.cod-order-form-wrapper[dir="rtl"] .cod-price-label {
	text-align: right;
}

.cod-form-rtl .cod-price-value,
.cod-order-form-wrapper[dir="rtl"] .cod-price-value {
	text-align: left;
}

/* ===== Error Message RTL ===== */
.cod-form-rtl .cod-error-message,
.cod-order-form-wrapper[dir="rtl"] .cod-error-message {
	text-align: right;
}

/* ===== Character Counter RTL ===== */
.cod-form-rtl .cod-char-count,
.cod-order-form-wrapper[dir="rtl"] .cod-char-count {
	text-align: left;
}

/* ===== Loading Text RTL ===== */
.cod-form-rtl .cod-commune-loading,
.cod-order-form-wrapper[dir="rtl"] .cod-commune-loading {
	flex-direction: row-reverse;
}

.cod-form-rtl .cod-submit-loading,
.cod-order-form-wrapper[dir="rtl"] .cod-submit-loading {
	flex-direction: row-reverse;
}

/* ===== Form Actions RTL ===== */
.cod-form-rtl .cod-form-actions,
.cod-order-form-wrapper[dir="rtl"] .cod-form-actions {
	flex-direction: row;
}

/* ===== Message Animations RTL ===== */
@keyframes slideDownRTL {
	from {
		opacity: 0;
		transform: translateX(-5px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

.cod-form-rtl .cod-error-message.show,
.cod-order-form-wrapper[dir="rtl"] .cod-error-message.show {
	animation: slideDownRTL 0.3s ease;
}

.cod-form-rtl .cod-message.show,
.cod-order-form-wrapper[dir="rtl"] .cod-message.show {
	animation: slideDownRTL 0.3s ease;
}

/* ===== Arabic Fonts ===== */
.cod-form-rtl,
.cod-order-form-wrapper[dir="rtl"] {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Droid Sans', 'Droid Sans Arabic', sans-serif;
}

.cod-form-rtl .cod-form-input,
.cod-form-rtl .cod-form-select,
.cod-form-rtl .cod-form-textarea,
.cod-order-form-wrapper[dir="rtl"] .cod-form-input,
.cod-order-form-wrapper[dir="rtl"] .cod-form-select,
.cod-order-form-wrapper[dir="rtl"] .cod-form-textarea {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Droid Sans', 'Droid Sans Arabic', sans-serif;
}

/* ===== Product Image RTL Layout ===== */
.cod-form-rtl .cod-form-group.cod-product-display,
.cod-order-form-wrapper[dir="rtl"] .cod-form-group.cod-product-display {
	flex-direction: row-reverse;
	align-items: flex-start;
}

/* ===== Mobile RTL ===== */
@media (max-width: 768px) {
	.cod-form-rtl .cod-product-image,
	.cod-order-form-wrapper[dir="rtl"] .cod-product-image {
		margin-right: 0;
		margin-left: 0;
		margin-bottom: 1rem;
	}

	.cod-form-rtl .cod-form-group.cod-product-display,
	.cod-order-form-wrapper[dir="rtl"] .cod-form-group.cod-product-display {
		flex-direction: column;
	}
}

/* ===== Select Dropdown Arrow RTL ===== */
.cod-form-rtl .cod-form-select,
.cod-order-form-wrapper[dir="rtl"] .cod-form-select {
	padding-right: 2.5rem;
	padding-left: 0.75rem;
	background-position: left 0.75rem center;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23333' d='M1 0l5 8 5-8z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-size: 12px;
}

/* ===== Accessibility - Focus States RTL ===== */
.cod-form-rtl .cod-form-input:focus,
.cod-form-rtl .cod-form-select:focus,
.cod-form-rtl .cod-form-textarea:focus,
.cod-order-form-wrapper[dir="rtl"] .cod-form-input:focus,
.cod-order-form-wrapper[dir="rtl"] .cod-form-select:focus,
.cod-order-form-wrapper[dir="rtl"] .cod-form-textarea:focus {
	box-shadow: -3px 0 0 rgba(0, 124, 186, 0.1), 3px 0 0 rgba(0, 124, 186, 0.1);
}

/* ===== Tab Navigation RTL ===== */
.cod-form-rtl [role="tablist"],
.cod-order-form-wrapper[dir="rtl"] [role="tablist"] {
	flex-direction: row-reverse;
}

/* ===== Support for Arabic Numbers (Optional) ===== */
.cod-form-rtl .cod-form-input[type="number"],
.cod-order-form-wrapper[dir="rtl"] .cod-form-input[type="number"],
.cod-form-rtl .cod-char-count,
.cod-order-form-wrapper[dir="rtl"] .cod-char-count,
.cod-form-rtl .cod-price-value,
.cod-order-form-wrapper[dir="rtl"] .cod-price-value {
	font-variant-numeric: lining-nums tabular-nums;
}

/* ===== Message Box Text Alignment RTL ===== */
.cod-form-rtl .cod-message,
.cod-order-form-wrapper[dir="rtl"] .cod-message {
	text-align: right;
	padding-right: 1rem;
	padding-left: 1rem;
}

/* ===== Input/Select Icons RTL ===== */
.cod-form-rtl .cod-form-group,
.cod-order-form-wrapper[dir="rtl"] .cod-form-group {
	flex-direction: column;
}

/* ===== Submit Button RTL ===== */
.cod-form-rtl .cod-submit-btn,
.cod-order-form-wrapper[dir="rtl"] .cod-submit-btn {
	flex-direction: row-reverse;
}

/* ===== Loading Indicator RTL ===== */
.cod-form-rtl .cod-submit-loading,
.cod-order-form-wrapper[dir="rtl"] .cod-submit-loading {
	flex-direction: row-reverse;
	gap: 0.5rem;
}

/* ===== Floating Labels Support ===== */
.cod-form-rtl .cod-form-label,
.cod-order-form-wrapper[dir="rtl"] .cod-form-label {
	direction: rtl;
	unicode-bidi: bidi-override;
}

/* ===== Ensure Proper Text Alignment in Tables ===== */
.cod-form-rtl table,
.cod-order-form-wrapper[dir="rtl"] table {
	direction: rtl;
}

.cod-form-rtl table th,
.cod-form-rtl table td,
.cod-order-form-wrapper[dir="rtl"] table th,
.cod-order-form-wrapper[dir="rtl"] table td {
	text-align: right;
}

/* ===== Padding/Margin Reversals ===== */
.cod-form-rtl .cod-form-section,
.cod-order-form-wrapper[dir="rtl"] .cod-form-section {
	padding-right: 0;
	padding-left: 0;
}
