/* Currency Converter Specific Styles */
.currency-input-container {
    position: relative;
}

.globe-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    color: var(--primary-color);
    z-index: 10;
    font-size: 16px;
    width: 16px;
    height: 30px;
    text-align: center;
    line-height: 30px;
}

#from-flag,
#to-flag {
    position: absolute;
    left: 12px;
    top: 50%;
    z-index: 10;
    width: 24px;
    height: 30px;
    display: none;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

#from-currency,
#to-currency {
    padding-right: 0.75rem;
    padding-left: 45px;
}

.result {
    margin-top: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-dark);
    text-align: center;
    
    /* Hide by default, show only when there are results */
    display: none;

    /* Modern styling enhancements */
    background: gray;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

/* Show result box when it has content */
.result:not(:empty) {
    display: block;
}

.result:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.result .conversion-line {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 1.5rem;
    margin: 0.75rem 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.result .conversion-line:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.result .currency-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 1.1rem;
    margin: 0 0.3rem;
}

.result .currency-code {
    font-weight: 700;
    color: #667eea;
    font-size: 1rem;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    margin: 0 0.3rem;
}

.result .currency-symbol {
    font-weight: 700;
    color: #48bb78;
    font-size: 1.4rem;
    margin: 0 0.2rem;
}

.result .value {
    font-weight: 700;
    color: #2d3748;
    font-size: 1.5rem;
    margin: 0 0.3rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.error-message {
    color: var(--danger-color);
    background-color: #fff5f5;
    padding: 0.8rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    border-left: 4px solid var(--danger-color);
}

/* Awesomplete dropdown styling */
.awesomplete {
    width: 100%;
}

.awesomplete>ul {
    right: 0 !important;
    left: auto !important;
    text-align: right;
}

.awesomplete li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

.awesomplete li:hover,
.awesomplete li[aria-selected="true"] {
    background-color: var(--primary-color);
    color: white;
}

/* Updated for new flag-icons structure using .fi classes */
.currency-input-container .fi {
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

/* Adjust position based on text direction */
html[dir="rtl"] .currency-input-container .form-control {
    padding-right: 50px;
    /* Make space for the icon on the left in RTL */
    padding-left: 12px;
    /* Reset right padding to default Bootstrap */
}



/* Autocomplete styles */
.awesomplete>ul {
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    max-height: 300px;
    overflow-y: auto;
    text-align: right;
    direction: rtl;
    z-index: 1000;
}

.awesomplete>ul>li {
    padding: 8px 12px;
    display: block;
    /* keep li as block; inner .currency-option will manage layout */
    border-bottom: 1px solid #eee;
    cursor: pointer;
    line-height: 1.2;
    /* normalize item line-height to reduce extra top/bottom space */
}

.awesomplete>ul>li:hover {
    background-color: #f5f5f5;
}

.awesomplete>ul>li[aria-selected="true"] {
    background-color: #e9ecef;
}

/* Updated flag styles for new .fi structure */
.awesomplete>ul>li .fi {
    margin: 0;
    /* spacing controlled by grid gap */
    width: 20px;
    height: 15px;
    border: none;
    /* remove border to avoid visual misalignment */
    flex-shrink: 0;
    display: inline-block;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    vertical-align: middle;
}

/* Space the globe icon similarly when a flag is not available in the dropdown */
.awesomplete>ul>li .fa-globe {
    margin: 0;
    /* spacing controlled by grid gap */
    font-size: 18px;
    width: 20px;
    height: 15px;
    line-height: 15px;
    /* match flag height for baseline alignment */
    display: inline-block;
    text-align: center;
}

/* RTL adjustments for dropdown icons spacing */
/* No extra margins in RTL; spacing is handled uniformly by grid gap */

.currency-option {
    display: flex;
    align-items: center;
    /* default vertical centering */
    gap: 8px;
    /* default spacing */
    width: 100%;
    box-sizing: border-box;
}

/* Use an explicit grid inside dropdown list items for perfect alignment */
.awesomplete>ul>li .currency-option {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    /* keep contents on a single line */
}

/* Remove grid column mappings - using flex */

/* Ensure icon cell aligns perfectly in the grid */
.awesomplete>ul>li .currency-option>.fi,
.awesomplete>ul>li .currency-option>.fa-globe {
    width: 20px;
    height: 15px;
    display: block;
    /* avoid baseline/inline quirks */
    align-self: center;
    /* flex vertical centering */
    flex: 0 0 20px;
    /* keep fixed icon width */
    transform: translateY(-2px);
    /* slightly stronger upward nudge for baseline alignment */
}

/* Ensure globe icon in dropdown visually matches flag size */
.awesomplete>ul>li .currency-option>.fa-globe {
    font-size: 16px;
    line-height: 15px;
}

/* Normalize text elements inside dropdown for better vertical centering */
.awesomplete>ul>li .currency-option>.currency-code,
.awesomplete>ul>li .currency-option>.currency-name {
    line-height: 1.2;
    /* match li line-height */
    display: block;
    align-self: center;
    /* flex vertical centering */
}

/* Prevent overlap by fixing flex-basis for icon and code */
.currency-option>.fi,
.currency-option>.fa-globe {
    flex: 0 0 20px;
    /* fixed width for icon */
    display: block;
    /* ensure it occupies its own box in the flex row */
}

.currency-option>.currency-code {
    flex: 0 0 64px;
    /* fixed width for 3-letter code */
    white-space: nowrap;
    display: block;
    /* ensure fixed box, prevents overlap */
}

.currency-option>.currency-name {
    flex: 1 1 auto;
    /* take remaining space */
    min-width: 0;
    /* allow flex child to shrink and ellipsize */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Normalize margins and alignment for dropdown-specific text */
.awesomplete>ul>li .currency-code {
    margin: 0;
    /* override any global margins */
    direction: ltr;
    text-align: left;
}

.awesomplete>ul>li .currency-name {
    margin: 0;
    /* override any global margins */
}

/* No extra manual margins here; spacing is handled by gap above */

/* Remove enforced inline-flex on children to prevent unexpected width calculations */

/* Normalize line-height for list items to help vertical centering */

.awesomplete {
    display: block;
}

.awesomplete>ul>li {
    line-height: 1.1;
}

.currency-code {
    font-weight: bold;
    margin: 0;
    min-width: 0;
    /* allow grid to manage width */
    text-align: left;
    direction: ltr;
}

.currency-name {
    color: #666;
    flex-grow: 1;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove old adornment styles that created visual split borders */
.input-group-text {
    background-color: transparent;
}

/* Restore normal borders/padding for full-width inputs */
.currency-input-container .form-control {
    border-left: 1px solid #ced4da;
    padding-left: 0.75rem;
}

.form-control:focus {
    border-color: #ced4da;
    box-shadow: none;
}

/* Ensure proper spacing for the input group */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

/* Ensure currency inputs span full width like the amount input */
.currency-input-container .input-group {
    width: 100%;
}

.currency-input-container .form-control {
    flex: 1 1 auto;
    width: 100%;
}

/* The add-on is only used to host absolutely-positioned icons; don't reserve space */
.currency-input-container .input-group-text {
    width: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

/* Style for the flag container */
.flag-container {
    display: flex;
    align-items: center;
    padding: 0 10px;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-right: none;
    border-radius: 0.25rem 0 0 0.25rem;
}

/* RTL specific styles */
html[dir="rtl"] .input-group>.form-control:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

html[dir="rtl"] .input-group>.input-group-text:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}


/* Style for flags in the result div */
.result .fi {
    vertical-align: middle;
    margin-left: 5px;
    /* Add some space between flag and text */
    width: 20px;
    height: 15px;
    display: inline-block;
}

html[dir="rtl"] .result .fi {
    margin-right: 5px;
    margin-left: 0;
}

.result .separator {
    margin: 1.5rem 0;
    font-size: 2rem;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result .exchange-rate-summary {
    font-size: 0.9em;
    color: #ffffff;
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    text-align: center;
    direction: ltr;
    font-weight: 500;
}