/* 
 * RTL-specific styles for Invoice Generator
 * Enhanced for Boqash Branding
 */

/* Ensure proper RTL display */
.boqash-invoice-generator {
    direction: rtl;
    text-align: right;
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
}

/* Header RTL Layout */
.invoice-header {
    direction: rtl;
}

.logo-container {
    order: 2; /* Logo on left side in RTL */
}

.invoice-title {
    order: 1;
    text-align: center;
}

.invoice-number {
    text-align: center;
}

/* Info sections RTL */
.invoice-info {
    direction: rtl;
}

.company-info, .invoice-dates {
    text-align: right;
}

.company-info h3, .invoice-dates h3, .client-info-header {
    text-align: right;
    border-bottom: 2px solid var(--boqash-primary);
}

/* Date inputs RTL fix */
.date-row {
    direction: rtl;
    justify-content: space-between;
}

.date-label {
    margin-right: 0;
    margin-left: 0;
    text-align: right;
}

.date-input {
    direction: ltr; /* Keep date format LTR */
    text-align: left;
}

/* Table RTL Layout */
.invoice-items-header {
    direction: rtl;
}

.invoice-item {
    direction: rtl;
}

.item-description {
    text-align: right;
}

.item-quantity, .item-rate {
    text-align: center;
}

.item-amount {
    text-align: center;
    direction: ltr; /* Keep numbers LTR for readability */
}

.amount-text {
    direction: ltr;
    text-align: center;
}

/* Input fields RTL */
.item-input {
    text-align: right;
}

.quantity-input, .rate-input {
    text-align: center;
    direction: ltr; /* Numbers should be LTR */
}

/* Button icons RTL */
.add-icon {
    margin-right: 0;
    margin-left: 8px;
}

.button-icon {
    margin-right: 0;
    margin-left: 8px;
}

/* Totals section RTL */
.invoice-totals {
    margin-left: 0;
    margin-right: auto;
    text-align: right;
    direction: rtl;
}

.totals-row {
    direction: rtl;
    justify-content: space-between;
}

.totals-amount {
    direction: ltr;
    text-align: left;
}

/* Notes and Terms RTL */
.notes-content, .terms-content {
    text-align: right;
    direction: rtl;
}

.notes-label, .terms-label {
    text-align: right;
}

/* Editable content RTL */
[contenteditable="true"] {
    text-align: right;
    direction: rtl;
}

/* Client info RTL */
.client-info {
    direction: rtl;
    text-align: right;
}

.client-name {
    text-align: right;
}

/* Action buttons */
.invoice-actions {
    direction: rtl;
}

/* Form elements RTL fixes */
input:not(.quantity-input):not(.rate-input):not(.date-input), 
textarea, 
[contenteditable="true"]:not(.amount-text) {
    text-align: right;
    direction: rtl;
}

/* Number inputs and currency should be LTR */
.quantity-input, 
.rate-input, 
.amount-text,
.totals-amount,
.date-input {
    direction: ltr;
    text-align: center;
}

/* RTL animations and transitions */
.remove-item:hover {
    transform: scale(1.1) rotateY(180deg);
}

.action-button:hover {
    transform: translateY(-2px);
}

/* Enhanced RTL for mobile */
@media (max-width: 768px) {
    .invoice-header {
        direction: rtl;
        text-align: center;
    }
    
    .logo-container {
        order: 1;
        margin-bottom: 20px;
    }
    
    .invoice-title {
        order: 2;
    }
    
    .invoice-info {
        direction: rtl;
    }
    
    .invoice-items-header,
    .invoice-item {
        direction: rtl;
    }
    
    .item-description {
        text-align: right;
    }
}

/* Arabic text optimization */
.boqash-invoice-generator * {
    font-feature-settings: "liga" 1, "calt" 1;
}

/* Enhanced Arabic typography */
.invoice-title h1,
.company-name,
.client-name,
.notes-label,
.terms-label {
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Ensure proper text flow */
p, div, span {
    unicode-bidi: embed;
}

/* Fix for mixed content (Arabic + English) */
.mixed-content {
    direction: rtl;
    text-align: right;
}

.mixed-content .ltr {
    direction: ltr;
    display: inline-block;
}
