/* RTL Direction - Base Settings */
@font-face {
    font-family: 'Vazir';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v27.2.2/dist/Vazir.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v27.2.2/dist/Vazir.woff') format('woff'),
         url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v27.2.2/dist/Vazir.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Vazir';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v27.2.2/dist/Vazir-Bold.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v27.2.2/dist/Vazir-Bold.woff') format('woff'),
         url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v27.2.2/dist/Vazir-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

body {
    direction: rtl;
    text-align: right;
    font-family: 'Vazir', tahoma, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Vazir', tahoma, Arial, sans-serif;
    font-weight: bold;
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.9rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }

/* Flip positioning of elements */
.navbar-brand {
    margin-right: 0;
    margin-left: 1rem;
    font-size: 1.4rem;
    font-weight: bold;
}

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

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

/* Adjust form controls for RTL */
.form-control {
    text-align: right;
    height: 45px; /* Larger touch target for mobile */
    font-size: 1rem;
}

/* Flip padding and margins */
.mr-1, .mr-2, .mr-3, .mr-4, .mr-5 {
    margin-right: 0 !important;
    margin-left: 0.25rem !important;
}

.ml-1, .ml-2, .ml-3, .ml-4, .ml-5 {
    margin-left: 0 !important;
    margin-right: 0.25rem !important;
}

.pr-1, .pr-2, .pr-3, .pr-4, .pr-5 {
    padding-right: 0 !important;
    padding-left: 0.25rem !important;
}

.pl-1, .pl-2, .pl-3, .pl-4, .pl-5 {
    padding-left: 0 !important;
    padding-right: 0.25rem !important;
}

/* Flip table cells and their content */
.table th, .table td {
    text-align: right;
    padding: 0.5rem;
    font-size: 0.95rem;
}

.table th {
    font-weight: bold;
}

/* Buttons with proper font */
.btn {
    font-family: 'Vazir', tahoma, Arial, sans-serif;
    font-size: 0.95rem;
}

/* Mobile-friendly adjustments */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.6rem; }
    h3 { font-size: 1.4rem; }
    h4 { font-size: 1.2rem; }
    h5 { font-size: 1.1rem; }
    h6 { font-size: 1rem; }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .card-header h4 {
        font-size: 1.1rem;
    }
    
    .table th, .table td {
        padding: 0.5rem;
        white-space: nowrap; /* Prevent text wrapping */
        font-size: 0.85rem;
        padding: 0.4rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .form-control {
        height: 45px; /* Larger touch target for mobile */
        font-size: 0.95rem;
    }
    
    #barcode-input {
        font-size: 1.1rem;
    }
    
    #manual-scan {
        height: 45px;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }
    
    .table-hover tbody tr:hover {
        background-color: rgba(0, 0, 0, 0.05); /* Lighter hover effect on mobile */
    }
}

/* General styling improvements */
.badge-warning {
    background-color: #ffc107;
    color: #212529;
}

.badge-success {
    background-color: #28a745;
    color: white;
}

.badge-info {
    background-color: #17a2b8;
    color: white;
}

.table-success {
    background-color: rgba(40, 167, 69, 0.2) !important;
}

.progress {
    height: 20px;
}

.progress-bar {
    line-height: 20px;
    min-width: 2rem;
    font-size: 0.8rem;
    font-weight: bold;
}

/* Improved scanning experience */
#barcode-input:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Location badge styling */
span.badge.badge-info {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    font-family: 'Vazir', tahoma, Arial, sans-serif;
}

/* Better button spacing */
.card-body form {
    display: inline-block;
}

.camera-container {
    width: 100%;
    height: 300px;
    overflow: hidden;
    position: relative;
}

.scan-region {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        border-color: rgba(255, 0, 0, 0.5);
    }
    50% {
        border-color: rgba(255, 0, 0, 1);
    }
    100% {
        border-color: rgba(255, 0, 0, 0.5);
    }
}

/* Additional RTL fixes for Bootstrap components */
.dropdown-menu {
    right: 0;
    left: auto;
    text-align: right;
    font-size: 0.95rem;
}

.input-group > .input-group-prepend > .btn,
.input-group > .input-group-prepend > .input-group-text,
.input-group > .input-group-append:not(:last-child) > .btn,
.input-group > .input-group-append:not(:last-child) > .input-group-text,
.input-group > .input-group-append:last-child > .btn:not(:last-child):not(.dropdown-toggle),
.input-group > .input-group-append:last-child > .input-group-text:not(:last-child) {
    border-radius: 0 0.25rem 0.25rem 0;
}

.input-group > .form-control:not(:first-child),
.input-group > .custom-select:not(:first-child) {
    border-radius: 0.25rem 0 0 0.25rem;
}

/* Fix for buttons orientation */
.btn-group > .btn:not(:last-child):not(.dropdown-toggle),
.btn-group > .btn-group:not(:last-child) > .btn {
    border-radius: 0 0.25rem 0.25rem 0;
}

.btn-group > .btn:not(:first-child),
.btn-group > .btn-group:not(:first-child) > .btn {
    border-radius: 0.25rem 0 0 0.25rem;
}

/* Float adjustments for RTL */
.float-left {
    float: right !important;
}

.float-right {
    float: left !important;
}

/* Text alignment classes */
.text-left {
    text-align: right !important;
}

.text-right {
    text-align: left !important;
}

/* Card styles with proper font sizing */
.card-title {
    font-size: 1.25rem;
    font-weight: bold;
}

.card-text {
    font-size: 0.95rem;
}

/* Modal titles for Farsi */
.modal-title {
    font-size: 1.3rem;
    font-weight: bold;
}

/* Form labels */
label {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Alert messages */
.alert {
    font-size: 0.95rem;
    text-align: right;
}

/* Navigation items */
.nav-link {
    font-size: 1rem;
}

/* Container for better padding in RTL */
.container, .container-fluid {
    padding-right: 15px;
    padding-left: 15px;
}