/* Asset 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 asset dropdown has lower z-index than currency dropdown on mobile */
.form-group:has(#asset-dropdown-trigger) .custom-dropdown-wrapper {
    z-index: 999998 !important;
}

@media (max-width: 767px) {
    .form-group:has(#asset-dropdown-trigger) .custom-dropdown-wrapper {
        z-index: 999998 !important;
    }
}

/* --- ASSET DROPDOWN TRIGGER --- */
.asset-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 */
.asset-dropdown-trigger:focus {
    outline: none !important;
    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;
}


.asset-dropdown-trigger:hover {
    border-color: rgba(255,255,255,0.15);
    background-color: rgba(0,0,0,0.25);
}

.asset-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-asset-display {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    justify-content: space-between;
}

.asset-name {
    font-weight: 600;
    color: #e0e0e0;
}

.asset-category {
    font-size: 11px;
    background-color: rgba(40,235,207,0.2);
    color: #28ebcf;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* Category-specific colors for the asset category in the dropdown trigger */
.asset-category.forex {
    background-color: rgba(52,152,219,0.15);
    color: #3498db;
    border: 1px solid rgba(52,152,219,0.3);
}

.asset-category.stocks {
    background-color: rgba(46,204,113,0.15);
    color: #2ecc71;
    border: 1px solid rgba(46,204,113,0.3);
}

.asset-category.etf {
    background-color: rgba(232,67,147,0.15);
    color: #e84393;
    border: 1px solid rgba(232,67,147,0.3);
}

.asset-category.indices {
    background-color: rgba(155,89,182,0.15);
    color: #9b59b6;
    border: 1px solid rgba(155,89,182,0.3);
}

.asset-category.commodities {
    background-color: rgba(230,126,34,0.15);
    color: #e67e22;
    border: 1px solid rgba(230,126,34,0.3);
}

.asset-category.crypto {
    background-color: rgba(241,196,15,0.15);
    color: #f1c40f;
    border: 1px solid rgba(241,196,15,0.3);
}

.dropdown-arrow {
    color: #888;
    transition: transform 0.2s ease;
    font-size: 12px;
    flex-shrink: 0;
}

.asset-dropdown-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Disabled state for asset dropdown */
.asset-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);
}

.asset-dropdown-trigger.disabled:hover {
    background-color: rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

.asset-dropdown-trigger.disabled .dropdown-arrow {
    opacity: 0.5;
}

/* --- ASSET DROPDOWN MENU --- */
.asset-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 asset dropdown menu has lower z-index on mobile */
@media (max-width: 767px) {
    .asset-dropdown-menu {
        z-index: 999990 !important;
    }
}

.asset-dropdown-menu.active {
    max-height: 700px;
    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: 999999 !important; /* Lowered z-index to be below currency dropdown */
    transform: translateZ(0); /* Fix potential rendering issues */
    will-change: transform, opacity;
    isolation: isolate;
    display: flex;
    flex-direction: column;
}

/* Ensure active asset dropdown menu has lower z-index on mobile */
@media (max-width: 767px) {
    .asset-dropdown-menu.active {
        z-index: 999990 !important; /* Lowered z-index to be below currency dropdown on mobile */
    }
}

/* When dropdown is active, disable pointer events on calculator outputs */
body .calculator-outputs {
    transition: pointer-events 0s;
}

body .asset-dropdown-menu.active ~ .calculator-outputs,
body .calc-module-container:has(.asset-dropdown-menu.active) .calculator-outputs,
.asset-dropdown-menu.active ~ .calculator-outputs,
.calc-module-container:has(.asset-dropdown-menu.active) .calculator-outputs {
    pointer-events: none !important;
}

/* Re-enable pointer events for the dropdown itself */
.asset-dropdown-menu.active {
    pointer-events: auto !important;
}

.asset-dropdown-menu.active::-webkit-scrollbar { width: 6px; }
.asset-dropdown-menu.active::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 3px; }
.asset-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); }
.asset-dropdown-menu.active::-webkit-scrollbar-thumb:hover { background-color: rgba(40,235,207,0.6); }

/* --- ASSET FILTERS --- */
.asset-filters {
    display: flex;
    padding: 18px;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-wrap: wrap;
    background-color: #1e1e1e !important;
}

.filter-btn {
    padding: 6px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #b0b0b0;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.filter-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #e0e0e0;
    outline: none !important;
}

.filter-btn:focus {
    border: 1px solid rgba(255,255,255,0.1);
}

.filter-btn:active,
.filter-btn:focus-visible,
.filter-btn:focus-within,
.filter-btn:target {
    border: 1px solid rgba(255,255,255,0.1) !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.filter-btn.active:focus {
    border-color: #28ebcf !important;
}

.filter-btn.active:active,
.filter-btn.active:focus-visible,
.filter-btn.active:focus-within {
    box-shadow: none !important;
    border-color: inherit !important;
}

/* ALL filter button (default/turquoise) */
.filter-btn.active {
    background: linear-gradient(145deg, #28ebcf, #20c7af);
    color: #0e0e0e;
    border: 1px solid #28ebcf !important;
    font-weight: 700;
    outline: none !important;
    box-shadow: none !important;
}

/* FOREX filter button (blue) */
.filter-btn[data-filter="forex"].active {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: #ffffff;
    border: 1px solid #3498db !important;
    font-weight: 700;
    outline: none !important;
    box-shadow: none !important;
}

.filter-btn[data-filter="forex"]:hover:not(.active) {
    background: rgba(52,152,219,0.15);
    color: #3498db;
    border-color: rgba(52,152,219,0.3);
    outline: none !important;
}

/* STOCKS filter button (green) */
.filter-btn[data-filter="stocks"].active {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    color: #ffffff;
    border: 1px solid #2ecc71 !important;
    font-weight: 700;
    outline: none !important;
    box-shadow: none !important;
}

.filter-btn[data-filter="stocks"]:hover:not(.active) {
    background: rgba(46,204,113,0.15);
    color: #2ecc71;
    border-color: rgba(46,204,113,0.3);
    outline: none !important;
}

/* INDICES filter button (purple) */
.filter-btn[data-filter="indices"].active {
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
    color: #ffffff;
    border: 1px solid #9b59b6 !important;
    font-weight: 700;
    outline: none !important;
    box-shadow: none !important;
}

.filter-btn[data-filter="indices"]:hover:not(.active) {
    background: rgba(155,89,182,0.15);
    color: #9b59b6;
    border-color: rgba(155,89,182,0.3);
    outline: none !important;
}

/* COMMODITIES filter button (orange) */
.filter-btn[data-filter="commodities"].active {
    background: linear-gradient(145deg, #e67e22, #d35400);
    color: #ffffff;
    border: 1px solid #e67e22 !important;
    font-weight: 700;
    outline: none !important;
    box-shadow: none !important;
}

.filter-btn[data-filter="commodities"]:hover:not(.active) {
    background: rgba(230,126,34,0.15);
    color: #e67e22;
    border-color: rgba(230,126,34,0.3);
    outline: none !important;
}

/* CRYPTO filter button (yellow/gold) */
.filter-btn[data-filter="crypto"].active {
    background: linear-gradient(145deg, #f1c40f, #f39c12);
    color: #2c3e50;
    border: 1px solid #f1c40f !important;
    font-weight: 700;
    outline: none !important;
    box-shadow: none !important;
}

/* --- ASSET LIST --- */
.asset-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 0;
    position: relative;
    z-index: 9999;
    scrollbar-width: thin;
    scrollbar-color: rgba(40,235,207,0.4) rgba(0,0,0,0.1);
}

.asset-list::-webkit-scrollbar { width: 6px; }
.asset-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 3px; }
.asset-list::-webkit-scrollbar-thumb { background-color: rgba(40,235,207,0.4); border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.asset-list::-webkit-scrollbar-thumb:hover { background-color: rgba(40,235,207,0.6); }

.filter-btn[data-filter="crypto"]:hover:not(.active) {
    background: rgba(241,196,15,0.15);
    color: #f1c40f;
    border-color: rgba(241,196,15,0.3);
    outline: none !important;
}

/* --- ASSET SEARCH --- */
.asset-search {
    padding: 10px 18px;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background-color: rgba(0,0,0,0.1);
}

#asset-search-input {
    width: 100%;
    padding: 10px 15px 10px 35px;
    background-color: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: all 0.25s ease;
}

#asset-search-input:focus {
    border-color: rgba(40,235,207,0.3);
    box-shadow: 0 0 0 1px rgba(40,235,207,0.1);
}

.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;
}

/* --- CATEGORY FILTERS --- */
.asset-category-filters {
    display: flex;
    padding: 12px 18px;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-wrap: wrap;
    background-color: #1e1e1e !important;
}

.category-filter {
    padding: 6px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #b0b0b0;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    outline: none !important;
}

.category-filter:hover {
    background: rgba(255,255,255,0.1);
    color: #e0e0e0;
}

/* ALL filter (default/turquoise) */
.category-filter.active {
    background: linear-gradient(145deg, #28ebcf, #20c7af);
    color: #0e0e0e;
    border: 1px solid #28ebcf !important;
    font-weight: 700;
}

/* FOREX filter (blue) */
.category-filter[data-category="forex"].active {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: #ffffff;
    border: 1px solid #3498db !important;
}

.category-filter[data-category="forex"]:hover:not(.active) {
    background: rgba(52,152,219,0.15);
    color: #3498db;
    border-color: rgba(52,152,219,0.3);
}

/* STOCKS filter (green) */
.category-filter[data-category="stocks"].active {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    color: #ffffff;
    border: 1px solid #2ecc71 !important;
}

.category-filter[data-category="stocks"]:hover:not(.active) {
    background: rgba(46,204,113,0.15);
    color: #2ecc71;
    border-color: rgba(46,204,113,0.3);
}

/* ETF filter (pink/magenta) */
.category-filter[data-category="etf"].active {
    background: linear-gradient(145deg, #e84393, #d63031);
    color: #ffffff;
    border: 1px solid #e84393 !important;
}

.category-filter[data-category="etf"]:hover:not(.active) {
    background: rgba(232,67,147,0.15);
    color: #e84393;
    border-color: rgba(232,67,147,0.3);
}

/* INDICES filter (purple) */
.category-filter[data-category="indices"].active {
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
    color: #ffffff;
    border: 1px solid #9b59b6 !important;
}

.category-filter[data-category="indices"]:hover:not(.active) {
    background: rgba(155,89,182,0.15);
    color: #9b59b6;
    border-color: rgba(155,89,182,0.3);
}

/* COMMODITIES filter (orange) */
.category-filter[data-category="commodities"].active {
    background: linear-gradient(145deg, #e67e22, #d35400);
    color: #ffffff;
    border: 1px solid #e67e22 !important;
}

.category-filter[data-category="commodities"]:hover:not(.active) {
    background: rgba(230,126,34,0.15);
    color: #e67e22;
    border-color: rgba(230,126,34,0.3);
}

/* CRYPTO filter (yellow/gold) */
.category-filter[data-category="crypto"].active {
    background: linear-gradient(145deg, #f1c40f, #f39c12);
    color: #2c3e50;
    border: 1px solid #f1c40f !important;
}

.category-filter[data-category="crypto"]:hover:not(.active) {
    background: rgba(241,196,15,0.15);
    color: #f1c40f;
    border-color: rgba(241,196,15,0.3);
}

/* --- ASSET SEARCH --- */
.asset-search {
    position: relative;
    padding: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background-color: #1e1e1e !important;
    display: flex;
    align-items: center;
}

.asset-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;
}

.asset-search input::placeholder {
    color: rgba(255,255,255,0.4);
    font-size: 13px;
}

.asset-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;
}

/* --- ASSET LIST --- */
.asset-list {
    max-height: 700px;
    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;
}

.asset-list::-webkit-scrollbar { width: 6px; }
.asset-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 3px; }
.asset-list::-webkit-scrollbar-thumb { background-color: rgba(40,235,207,0.4); border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.asset-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;
}

.asset-type-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    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;
}

/* Category-specific badge colors */
.asset-type-badge.forex {
    background-color: rgba(52,152,219,0.15);
    color: #3498db;
    border: 1px solid rgba(52,152,219,0.3);
}

.asset-type-badge.stocks {
    background-color: rgba(46,204,113,0.15);
    color: #2ecc71;
    border: 1px solid rgba(46,204,113,0.3);
}

.asset-type-badge.etf {
    background-color: rgba(232,67,147,0.15);
    color: #e84393;
    border: 1px solid rgba(232,67,147,0.3);
}

.asset-type-badge.indices {
    background-color: rgba(155,89,182,0.15);
    color: #9b59b6;
    border: 1px solid rgba(155,89,182,0.3);
}

.asset-type-badge.commodities {
    background-color: rgba(230,126,34,0.15);
    color: #e67e22;
    border: 1px solid rgba(230,126,34,0.3);
}

.asset-type-badge.crypto {
    background-color: rgba(241,196,15,0.15);
    color: #f1c40f;
    border: 1px solid rgba(241,196,15,0.3);
}

.no-assets-found {
    padding: 15px 20px;
    text-align: center;
    color: #888;
    font-style: italic;
    font-size: 13px;
    margin: 0 !important;
}

/* Style for the "Looking for something else?" prompt */
.asset-search-prompt {
    padding: 15px 20px;
    text-align: center;
    color: #888;
    font-size: 13px;
    margin: 10px 0 5px !important;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-style: italic;
}

/* Style for the clickable "search box" link */
.search-box-link {
    color: #28ebcf;
    text-decoration: underline;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.search-box-link:hover {
    color: #20c7af;
    text-decoration: none;
}

/*
 * Asset Dropdown Fixes for Fibonacci Calculator
 *
 * This file fixes styling issues with the asset dropdown in the fibonacci calculator
 * to make it match the trading journal implementation.
 */

/* Fix for double scrollbar issue - remove overflow from dropdown menu */
.asset-dropdown-menu.active {
    overflow-y: hidden !important; /* Override the auto overflow to prevent double scrollbars */
}

/* Add proper padding to asset list to match trading journal */
.asset-list {
    padding: 5px 0 !important; /* Match trading journal padding */
}

/* Ensure the asset list has the correct max-height and scrolling behavior */
.asset-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-asset-display {
    justify-content: flex-start !important; /* Override space-between to ensure proper spacing */
}

/* Ensure asset category (bubble) has proper spacing */
.asset-category {
    margin-left: 8px !important; /* Ensure consistent spacing */
}

/* Make the asset 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 */
.asset-dropdown-menu {
    position: absolute !important;
    z-index: 999999 !important; /* Lowered z-index to be below currency dropdown */
    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 asset dropdown menu has lower z-index on mobile at the bottom of the file */
@media (max-width: 767px) {
    .asset-dropdown-menu {
        z-index: 999990 !important; /* Lowered z-index to be below currency dropdown on mobile */
    }
}


/* Hide asset category bubble when empty (no category selected) */
.selected-asset-display .asset-category:empty {
    display: none !important;
}
