/* Currency Dropdown Styles for Calculators */

/* --- CUSTOM DROPDOWN WRAPPER --- */
.custom-dropdown-wrapper {
    position: relative;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 999999 !important; /* Extremely high z-index to match dropdown menu */
    /* Force the dropdown wrapper to create a new stacking context */
    transform: translateZ(0);
    will-change: transform;
}

/* Ensure currency dropdown has higher z-index than asset dropdown on mobile */
.form-group:has(#currency-dropdown-trigger) .custom-dropdown-wrapper {
    z-index: 1000000 !important;
}

@media (max-width: 767px) {
    .form-group:has(#currency-dropdown-trigger) .custom-dropdown-wrapper {
        z-index: 1000000 !important;
    }
}

/* --- CURRENCY DROPDOWN TRIGGER --- */
.currency-dropdown-trigger {
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    background-color: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: #e0e0e0;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.25s ease;
    min-height: 50px !important;
    height: 50px !important;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
    position: relative;
}

/* Style for keyboard focus - matches the active state styling */
.currency-dropdown-trigger:focus {
    outline: none !important;
    border-color: #28ebcf;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
    background-color: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.currency-dropdown-trigger:hover {
    border-color: rgba(255,255,255,0.15);
    background-color: rgba(0,0,0,0.25);
}

.currency-dropdown-trigger.active {
    border-color: #28ebcf;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3), 0 0 8px rgba(40,235,207,0.3);
    background-color: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.selected-currency-display {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    justify-content: flex-start;
}

.currency-name {
    font-weight: 600;
    color: #e0e0e0;
}

.currency-symbol-display {
    font-size: 14px;
    background-color: rgba(40,235,207,0.2);
    color: #28ebcf;
    padding: 0;
    margin: 0;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    border: none;
    width: 0;
    height: 0;
    overflow: hidden;
}

.dropdown-arrow {
    color: #888;
    transition: transform 0.2s ease;
    font-size: 12px;
    flex-shrink: 0;
}

.currency-dropdown-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Disabled state for currency dropdown */
.currency-dropdown-trigger.disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

.currency-dropdown-trigger.disabled:hover {
    background-color: rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

.currency-dropdown-trigger.disabled .dropdown-arrow {
    opacity: 0.5;
}

/* Ensure disabled state overrides active state */
.currency-dropdown-trigger.active.disabled,
.currency-dropdown-trigger.disabled.active {
    opacity: 0.7;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

/* --- CURRENCY DROPDOWN MENU --- */
.currency-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a) !important;
    border: 1px solid rgba(40, 235, 207, 0.3);
    border-radius: 8px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out, visibility 0.3s ease-out;
    opacity: 0;
    visibility: hidden;
    z-index: 999999 !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.8), 0 0 0 1px rgba(40,235,207,0.1);
    margin-top: 2px;
    /* Ensure the background is fully opaque */
    background-color: #1e1e1e !important;
}

/* Ensure currency dropdown menu has higher z-index on mobile */
@media (max-width: 767px) {
    .currency-dropdown-menu {
        z-index: 1000000 !important;
    }
}

.currency-dropdown-menu.active {
    max-height: 500px;
    max-height: 80vh; /* Limit to 80% of viewport height */
    opacity: 1 !important;
    visibility: visible;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a) !important;
    background-color: #1e1e1e !important;
    overflow-y: auto;
    scrollbar-width: auto;
    scrollbar-color: rgba(40,235,207,0.4) rgba(0,0,0,0.1);
    /* Enhanced visibility properties */
    z-index: 9999999 !important;
    transform: translateZ(9999px);
    transform: translateZ(0); /* Fix potential rendering issues */
    will-change: transform, opacity;
    isolation: isolate;
    display: flex;
    flex-direction: column;
}

/* Ensure active currency dropdown menu has higher z-index on mobile */
@media (max-width: 767px) {
    .currency-dropdown-menu.active {
        z-index: 10000000 !important;
    }
}

/* When dropdown is active, disable pointer events on calculator outputs */
body .calculator-outputs {
    transition: pointer-events 0s;
}

body .currency-dropdown-menu.active ~ .calculator-outputs,
body .calc-module-container:has(.currency-dropdown-menu.active) .calculator-outputs,
.currency-dropdown-menu.active ~ .calculator-outputs,
.calc-module-container:has(.currency-dropdown-menu.active) .calculator-outputs {
    pointer-events: none !important;
}

/* Re-enable pointer events for the dropdown itself */
.currency-dropdown-menu.active {
    pointer-events: auto !important;
}

.currency-dropdown-menu.active::-webkit-scrollbar { width: 6px; }
.currency-dropdown-menu.active::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 3px; }
.currency-dropdown-menu.active::-webkit-scrollbar-thumb { background-color: rgba(40,235,207,0.4); border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.currency-dropdown-menu.active::-webkit-scrollbar-thumb:hover { background-color: rgba(40,235,207,0.6); }

/* --- CURRENCY SEARCH --- */
.currency-search {
    position: relative;
    padding: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background-color: #1e1e1e !important;
    display: flex;
    align-items: center;
}

.currency-search input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: 'Montserrat', sans-serif;
}

.currency-search input::placeholder {
    color: rgba(255,255,255,0.4);
    font-size: 13px;
}

.currency-search input:focus {
    border-color: #28ebcf;
    box-shadow: 0 0 8px rgba(40,235,207,0.3);
    background: rgba(0,0,0,0.4);
}

.search-icon {
    position: absolute;
    left: 33px; /* Adjusted to account for parent padding */
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 14px;
    pointer-events: none;
    z-index: 1;
}


/* --- CURRENCY LIST --- */
.currency-list {
    max-height: 500px;
    overflow-y: auto;
    margin: 0 !important;
    padding: 8px 0;
    scrollbar-width: auto;
    scrollbar-color: rgba(40,235,207,0.4) rgba(0,0,0,0.1);
    background-color: #1e1e1e !important;
}

.currency-list::-webkit-scrollbar { width: 6px; }
.currency-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 3px; }
.currency-list::-webkit-scrollbar-thumb { background-color: rgba(40,235,207,0.4); border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.currency-list::-webkit-scrollbar-thumb:hover { background-color: rgba(40,235,207,0.6); }

/* --- DROPDOWN OPTIONS --- */
.dropdown-option {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 14px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-left-color 0.2s ease;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    border-left: 3px solid transparent;
    text-align: left;
    background-color: #1e1e1e !important;
    outline: none;
}

.dropdown-option:focus {
    background-color: #1a3b38 !important;
}

.dropdown-option:hover {
    background-color: #1a3b38 !important;
    border-left-color: #28ebcf !important;
}

.dropdown-option.selected-item {
    background-color: #1a3b38 !important;
    border-left-color: #28ebcf;
}

.dropdown-option.selected-item .asset-name {
    color: #28ebcf;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.asset-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto !important;
    min-width: 0;
    margin-right: 12px;
}

.asset-name {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 14px;
}

.asset-description {
    font-size: 11px;
    color: #888;
}

.currency-symbol {
    font-size: 16px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    flex: 0 0 auto !important;
    text-align: center;
    white-space: nowrap;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    min-width: auto !important;
    max-width: 85px !important;
    margin-left: 8px;
    align-self: center;
    background-color: rgba(40,235,207,0.1);
    color: #28ebcf;
    border: 1px solid rgba(40,235,207,0.2);
}

.no-currencies-found {
    padding: 15px 20px;
    text-align: center;
    color: #888;
    font-style: italic;
    font-size: 13px;
    margin: 0 !important;
}

/* Fix for double scrollbar issue - remove overflow from dropdown menu */
.currency-dropdown-menu.active {
    overflow-y: hidden !important; /* Override the auto overflow to prevent double scrollbars */
}

/* Add proper padding to currency list to match trading journal */
.currency-list {
    padding: 5px 0 !important; /* Match trading journal padding */
}

/* Ensure the currency list has the correct max-height and scrolling behavior */
.currency-list {
    max-height: 500px !important; /* Match trading journal max-height */
    overflow-y: auto !important; /* Ensure this element has the scrollbar */
}

/* Fix for missing spacing in dropdown options */
.dropdown-option {
    padding: 12px 20px !important; /* Match trading journal padding */
}

/* Fix for asset info spacing */
.asset-info {
    gap: 2px !important; /* Match trading journal gap */
    margin-right: 10px !important; /* Match trading journal margin */
}

/* Fix for spacing/padding where the bubbles are */
.selected-currency-display {
    justify-content: flex-start !important; /* Override space-between to ensure proper spacing */
}

/* Ensure currency symbol (bubble) has proper spacing */
.currency-symbol-display {
    margin-left: 0 !important; /* Remove margin to ensure it doesn't take up space */
}

/* Make the currency menu go past the calculator window instead of adding a scrollbar */
.calc-module-container {
    overflow: visible !important; /* Allow content to extend beyond the container */
}

/* Ensure the dropdown menu can extend beyond the calculator container */
.currency-dropdown-menu {
    position: absolute !important;
    z-index: 9999999 !important; /* Extremely high z-index to ensure it appears above everything */
    margin-top: 2px; /* Keep the same spacing from the trigger */
    /* Force the dropdown to be rendered at the top layer, ignoring stacking contexts */
    transform: translateZ(0);
    will-change: transform;
}

/* Ensure currency dropdown menu has higher z-index on mobile at the bottom of the file */
@media (max-width: 767px) {
    .currency-dropdown-menu {
        z-index: 10000000 !important;
    }
}
