/**
 * Currency Display Styles
 * Ensures consistent currency formatting across all pages
 */

/* Currency symbol styling */
.currency-symbol {
    font-weight: 600;
    color: var(--primary-color);
}

/* Price display styling */
.price, .price-display, .item-price, .cart-item-price, .total-amount, .stat-value {
    font-weight: 600;
    color: var(--primary-color);
}

/* Input group text for currency symbols */
.input-group-text {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border: 1px solid var(--primary-color);
}

/* Currency in labels */
label:has(.currency-symbol),
.form-label:has(.currency-symbol) {
    font-weight: 500;
}

/* Currency in forms */
.form-control[data-currency] {
    text-align: right;
    font-weight: 600;
}

/* Currency in tables */
.table .currency-cell {
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

/* Currency in cards */
.card .currency-display {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Currency in buttons */
.btn .currency-symbol {
    font-size: 0.9em;
    margin-right: 0.25rem;
}

/* Currency in modals */
.modal .currency-display {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    padding: 1rem;
    background: rgba(var(--primary-color-rgb), 0.1);
    border-radius: 8px;
    margin: 1rem 0;
}

/* Currency in charts */
.chart-currency {
    font-weight: 600;
    color: var(--primary-color);
}

/* RTL support for currency */
[dir="rtl"] .price,
[dir="rtl"] .price-display,
[dir="rtl"] .item-price {
    direction: ltr;
    text-align: right;
}

/* Currency animation */
.currency-update {
    animation: currencyPulse 0.3s ease-in-out;
}

@keyframes currencyPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Currency preview styling */
.currency-preview {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1rem 0;
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb), 0.3);
}

/* Currency settings modal */
.currency-settings-container .form-group {
    margin-bottom: 1.5rem;
}

.currency-settings-container .form-label {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.currency-settings-container .form-control {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    transition: border-color 0.3s ease;
}

.currency-settings-container .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-color-rgb), 0.25);
}

/* Currency option styling */
.currency-option {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--card-bg);
    margin-bottom: 0.5rem;
}

.currency-option:hover {
    border-color: var(--primary-color);
    background: var(--hover-bg);
    transform: translateY(-2px);
}

.currency-option.selected {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.currency-option .currency-flag {
    width: 24px;
    height: 24px;
    font-size: 1.2rem;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.currency-option .currency-info {
    flex: 1;
}

.currency-option .currency-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.currency-option .currency-code {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Responsive currency display */
@media (max-width: 768px) {
    .currency-preview {
        font-size: 1.2rem;
        padding: 1rem;
    }
    
    .currency-option {
        padding: 0.5rem;
    }
    
    .currency-option .currency-flag {
        width: 20px;
        height: 20px;
        font-size: 1rem;
    }
}

/* Currency icon styling (for SAR SVG) */
.currency-icon {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    display: inline-block;
    margin: 0 0.1em;
}

/* SAR: primary display uses <img src=".../Saudi_Riyal_Symbol.svg">; mask fallback below */
.sar-symbol-img {
    width: 1em;
    height: 1.15em;
    min-width: 1em;
    min-height: 1em;
    vertical-align: -0.12em;
    display: inline-block;
    object-fit: contain;
    flex-shrink: 0;
}

/* SAR currency symbol - CSS mask backup (same Saudi_Riyal_Symbol.svg file) */
.sar-symbol {
    display: inline-block;
    width: 1em;
    height: 1.15em;
    min-width: 1em;
    min-height: 1em;
    vertical-align: -0.12em;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask-image: url('../icons/Saudi_Riyal_Symbol.svg');
    mask-image: url('../icons/Saudi_Riyal_Symbol.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

/* OMR currency symbol - same CSS mask approach as SAR */
.omr-symbol {
    background-color: currentColor;
    -webkit-mask-image: url('../icons/Omani_Riyal_Symbol.svg');
    mask-image: url('../icons/Omani_Riyal_Symbol.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

/* Ensure currency icon aligns properly with text */
.price .currency-icon,
.price-display .currency-icon,
.item-price .currency-icon,
.cart-item-price .currency-icon,
.total-amount .currency-icon,
.stat-value .currency-icon {
    width: 1em;
    height: 1em;
    vertical-align: baseline;
    margin: 0 0.15em;
}

/* RTL support for currency icon */
[dir="rtl"] .currency-icon {
    margin-left: 0.15em;
    margin-right: 0;
}

/* Price + amount: mobile-safe (iOS Safari, Android WebView) */
.price-ltr-wrap,
span.price-ltr-wrap,
bdi.price-ltr-wrap {
    display: inline-block;
    direction: ltr;
    unicode-bidi: isolate;
    white-space: nowrap;
    vertical-align: baseline;
    max-width: 100%;
}
.price-amount,
span.price-amount,
bdi.price-amount {
    display: inline;
    direction: ltr;
    unicode-bidi: isolate;
    font-variant-numeric: tabular-nums;
    -webkit-text-fill-color: currentColor;
    color: inherit;
}
.price-gap {
    display: inline;
}
[dir="rtl"] .price-ltr-wrap,
[dir="rtl"] span.price-ltr-wrap,
[dir="rtl"] bdi.price-ltr-wrap,
[dir="rtl"] .cart-item-price,
[dir="rtl"] .cart-subtotal-excl-vat,
[dir="rtl"] .cart-vat-amount,
[dir="rtl"] .cart-total-value {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
}
