/**
 * RTL-specific overrides for Tan Agah theme
 * This file contains custom CSS rules to ensure proper RTL layout
 * 
 * WHY RTL IS FORCED:
 * This theme is specifically designed for Persian/Farsi content and audiences.
 * RTL (Right-to-Left) layout is mandatory because:
 * 1. Persian/Farsi script naturally flows from right to left
 * 2. UI/UX patterns must align with RTL reading patterns for better usability
 * 3. Bootstrap RTL CSS requires consistent RTL direction across all elements
 * 4. Mixed LTR/RTL layouts create visual inconsistencies and break user experience
 * 5. Form inputs, navigation, and interactive elements must follow RTL conventions
 * 
 * These overrides ensure that even if WordPress or plugins try to inject LTR styles,
 * the RTL layout remains consistent throughout the site.
 */

/* General RTL adjustments */
body.rtl {
    direction: rtl;
    text-align: right;
}

/* Adjust margins and paddings for RTL */
.rtl .me-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}

.rtl .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* Navigation adjustments */
.rtl .navbar-nav {
    padding-right: 0;
    padding-left: 0;
}

.rtl .navbar-nav .nav-link {
    text-align: right;
}

.rtl .dropdown-menu {
    text-align: right;
}

/* Form elements */
.rtl input,
.rtl textarea,
.rtl select {
    direction: rtl;
    text-align: right;
}

.rtl .form-label {
    text-align: right;
}

/* Button groups */
.rtl .btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.rtl .btn-group > .btn:last-child:not(:first-child),
.rtl .btn-group > .dropdown-toggle:not(:first-child) {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Card components */
.rtl .card {
    text-align: right;
}

/* List groups */
.rtl .list-group-item {
    text-align: right;
}

/* Breadcrumb */
.rtl .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-left: 0.5rem;
    padding-right: 0;
    content: "/";
}

/* Pagination */
.rtl .page-item:first-child .page-link {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.rtl .page-item:last-child .page-link {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Modal */
.rtl .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

/* Offcanvas */
.rtl .offcanvas-start {
    top: 0;
    right: 0;
    left: auto;
    border-left: 1px solid rgba(0, 0, 0, 0.175);
    border-right: 0;
    transform: translateX(100%);
}

.rtl .offcanvas-start.show {
    transform: none;
}

.rtl .offcanvas-end {
    top: 0;
    left: 0;
    right: auto;
    border-right: 1px solid rgba(0, 0, 0, 0.175);
    border-left: 0;
    transform: translateX(-100%);
}

.rtl .offcanvas-end.show {
    transform: none;
}

/* Toast */
.rtl .toast-header .btn-close {
    margin-right: auto;
    margin-left: -0.25rem;
}

/* Custom theme-specific RTL adjustments */
.rtl .tan-agah-gradient {
    /* Ensure gradients work correctly in RTL */
    background: linear-gradient(to left, var(--gradient-start), var(--gradient-end));
}

/* Fix any float issues */
.rtl .float-start {
    float: right !important;
}

.rtl .float-end {
    float: left !important;
}

/* Text alignment utilities */
.rtl .text-start {
    text-align: right !important;
}

.rtl .text-end {
    text-align: left !important;
}

/* Border radius utilities */
.rtl .rounded-start {
    border-top-right-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.rtl .rounded-end {
    border-top-left-radius: 0.375rem !important;
    border-bottom-left-radius: 0.375rem !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* Additional custom overrides can be added below */

/* Hero Section RTL Fixes */
.rtl .hero-gradient {
    background: linear-gradient(135deg, #6B7652 0%, #8B9467 20%, #C5D5B4 40%, #f093fb 60%, #764ba2 80%, #667eea 100%);
    background-position: right top;
}

.rtl .hero-gradient::before {
    background: rgba(255, 255, 255, 0.1);
}

/* Navbar Brand Hover Effect - Reverse Direction */
.rtl .navbar-brand:hover {
    transform: translateX(-5px);
}

/* Nav Link Underline Animation */
.rtl .nav-link::after {
    right: 50%;
    left: auto;
    transform: translateX(50%);
}

/* Gradient Text RTL Fix */
.rtl .gradient-text,
.rtl .text-gradient {
    direction: rtl;
}

/* Blob Animations RTL Positions */
.rtl .blob-1 {
    left: auto;
    right: -200px;
}

.rtl .blob-2 {
    right: auto;
    left: -150px;
}

/* Animated Border RTL */
.rtl .animated-border::before {
    right: -2px;
    left: -2px;
}

/* Form Control Icons/Addons RTL */
.rtl .input-group > .form-control:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.rtl .input-group > .form-control:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* Newsletter Gradient RTL */
.rtl .newsletter-gradient {
    background: linear-gradient(135deg, #8B9467 0%, #764ba2 50%, #667eea 100%);
}

/* Section Gradients RTL */
.rtl .section-gradient-1,
.rtl .section-gradient-2,
.rtl .section-gradient-3 {
    background-position: right center;
}

/* Gradient Overlay RTL */
.rtl .gradient-overlay::before {
    background: linear-gradient(135deg, rgba(107, 118, 82, 0.8) 0%, rgba(139, 148, 103, 0.9) 100%);
}

/* Glass Card Hover Transform */
.rtl .glass-card:hover,
.rtl .hover-lift:hover {
    transform: translateY(-10px);
}

/* Custom Scrollbar RTL */
.rtl ::-webkit-scrollbar {
    position: absolute;
    left: 0;
    right: auto;
}

/* Animation Adjustments for RTL */
@keyframes rtl-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rtl .animate-fadeInUp {
    animation: rtl-fadeInUp 0.6s ease-out;
}

/* Margin/Padding Swaps for Custom Classes */
.rtl .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

.rtl .me-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}

.rtl .ms-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
.rtl .ms-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }
.rtl .ms-3 { margin-left: 0 !important; margin-right: 1rem !important; }
.rtl .ms-4 { margin-left: 0 !important; margin-right: 1.5rem !important; }
.rtl .ms-5 { margin-left: 0 !important; margin-right: 3rem !important; }

.rtl .me-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
.rtl .me-2 { margin-right: 0 !important; margin-left: 0.5rem !important; }
.rtl .me-3 { margin-right: 0 !important; margin-left: 1rem !important; }
.rtl .me-4 { margin-right: 0 !important; margin-left: 1.5rem !important; }
.rtl .me-5 { margin-right: 0 !important; margin-left: 3rem !important; }

.rtl .ps-1 { padding-left: 0 !important; padding-right: 0.25rem !important; }
.rtl .ps-2 { padding-left: 0 !important; padding-right: 0.5rem !important; }
.rtl .ps-3 { padding-left: 0 !important; padding-right: 1rem !important; }
.rtl .ps-4 { padding-left: 0 !important; padding-right: 1.5rem !important; }
.rtl .ps-5 { padding-left: 0 !important; padding-right: 3rem !important; }

.rtl .pe-1 { padding-right: 0 !important; padding-left: 0.25rem !important; }
.rtl .pe-2 { padding-right: 0 !important; padding-left: 0.5rem !important; }
.rtl .pe-3 { padding-right: 0 !important; padding-left: 1rem !important; }
.rtl .pe-4 { padding-right: 0 !important; padding-left: 1.5rem !important; }
.rtl .pe-5 { padding-right: 0 !important; padding-left: 3rem !important; }

/* Modal and Offcanvas Close Button RTL */
.rtl .modal-header .btn-close,
.rtl .offcanvas-header .btn-close {
    margin: -0.5rem -0.5rem -0.5rem auto;
}

/* Dropdown Menu RTL Positioning */
.rtl .dropdown-menu-end {
    right: auto !important;
    left: 0 !important;
}

.rtl .dropdown-menu-start {
    left: auto !important;
    right: 0 !important;
}

/* Bootstrap Icons RTL Fixes */
.rtl .bi-chevron-right::before {
    content: "\f285"; /* chevron-left */
}

.rtl .bi-chevron-left::before {
    content: "\f282"; /* chevron-right */
}

.rtl .bi-arrow-right::before {
    content: "\f12f"; /* arrow-left */
}

.rtl .bi-arrow-left::before {
    content: "\f130"; /* arrow-right */
}

/* Responsive RTL Adjustments */
@media (max-width: 768px) {
    .rtl .navbar-nav {
        text-align: right;
    }
    
    .rtl .navbar-collapse {
        text-align: right;
    }
    
    .rtl .d-flex {
        flex-direction: row-reverse;
    }
}
