/* Enhanced Token Modal Styles - 1inch inspired design */

.token-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, visibility;
}

.fas {
    line-height: 0 !important;
}

.token-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
}

/* Smooth closing state: keep displayed while fading/sliding out */
.token-modal.closing {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.token-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Highlight effect for popular token selection */
.token-item.highlighted {
    background: linear-gradient(135deg, 
        rgba(44, 94, 255, 0.2) 0%, 
        rgba(13, 180, 165, 0.15) 100%);
    border-color: var(--oneinch-blue);
    box-shadow: 0 2px 12px rgba(44, 94, 255, 0.3);
    transform: scale(1.02);
    transition: all 0.3s ease;
}

.token-modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    margin: 1rem;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.15) 0%, 
        rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 8px 32px rgba(44, 94, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.token-modal.active .token-modal-content {
    transform: translateY(0) scale(1);
}

/* Apply reverse transform during closing */
.token-modal.closing .token-modal-content {
    transform: translateY(20px) scale(0.95);
}

/* Header */
.token-modal-header {
    padding: 1.5rem 1.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, 
        rgba(44, 94, 255, 0.1) 0%, 
        rgba(13, 180, 165, 0.05) 100%);
}

.token-modal-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.token-modal-title i {
    color: var(--oneinch-blue);
    font-size: 1.1rem;
}

.token-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.token-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Body */
.token-modal-body {
    padding: 0;
    overflow-y: auto;
    max-height: calc(85vh - 140px);
}

/* Scrollbar styles are unified in bitflow/css/modal.css */

/* Search Section */
.token-search-container {
    padding: 1.5rem 1.75rem 0;
    margin-bottom: 1.5rem;
}

.token-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    z-index: 2;
}

.token-search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 2.75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.token-search-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--oneinch-blue);
    box-shadow: 0 0 0 3px rgba(44, 94, 255, 0.15);
}

.token-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-clear {
    position: absolute;
    right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
}

.search-clear:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.popular-tokens-section {
    transition: all 0.3s ease;
}

/* Section Headers */
.popular-tokens-section .section-header,
.tokens-display-section .section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    justify-content: space-between;
    padding: 0 2rem;
}

.popular-tokens-section .section-header i {
    color: var(--oneinch-blue);
    font-size: 0.9rem;
}

.section-header h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.section-header h4 i {
    color: var(--oneinch-blue);
    font-size: 0.8rem;
}

.token-count-badge {
    background: linear-gradient(135deg, var(--oneinch-blue), #4facfe);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    margin-left: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: 0 2px 4px rgba(79, 172, 254, 0.3);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(79, 172, 254, 0.3);
    }
    50% {
        box-shadow: 0 2px 8px rgba(79, 172, 254, 0.5);
    }
}

.tokens-count {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Popular Tokens Grid */
.popular-tokens-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 0 1.75rem;
}

.popular-token-card:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--oneinch-blue);
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.2),
        0 4px 15px rgba(44, 94, 255, 0.15);
}

.popular-token-card:active {
    transform: translateY(0);
}

.token-icon-container {
    position: relative;
}

.popular-token-card .token-icon {
    width: 40px;
    height: auto;
    border-radius: 50%;
    object-fit: cover;
    transition: all 0.2s ease;
}

.popular-token-card:hover .token-icon {
    border-color: var(--oneinch-blue);
    box-shadow: 0 0 20px rgba(44, 94, 255, 0.3);
}

.popular-token-card .token-details {
    text-align: center;
}

.popular-token-card .token-symbol {
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 700;
    /* margin-bottom: 0.5rem; */
    display: block;
}

.popular-token-card .token-network-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(98, 126, 234, 0.15);
    border-radius: 10px;
    border: 1px solid rgba(98, 126, 234, 0.2);
    margin-top: 4px;
}

.popular-token-card .token-network-container .network-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.popular-token-card .token-network-container .token-network {
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.02em;
}

.popular-token-card .token-name {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.125rem;
    display: block;
}

/* All Tokens List */
.all-tokens-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
}

.token-list-container {
    padding: 0 1rem;
}

.token-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.token-list-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.token-list-item:active {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--oneinch-blue);
}

.token-icon-wrapper {
    position: relative;
    flex-shrink: 0;
}

.token-list-item .token-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.token-info-section {
    flex: 1;
    min-width: 0;
}

.token-primary-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.token-list-item .token-symbol {
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
}

.token-list-item .token-name {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-secondary-info {
    margin-top: 4px;
}

.token-list-item .token-network-container {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: rgba(98, 126, 234, 0.12);
    border-radius: 8px;
    border: 1px solid rgba(98, 126, 234, 0.18);
}

.token-list-item .token-network-container .network-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.token-list-item .token-network-container .token-network {
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.02em;
}

.token-secondary-info .token-network {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 500;
    /* background: rgba(255, 255, 255, 0.08); */
    /* padding: 0.25rem 0.5rem; */
    border-radius: 6px;
    display: inline-block;
}

.token-balance-section {
    text-align: right;
    flex-shrink: 0;
}

.token-balance {
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.token-balance-usd {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 500;
}

.token-action-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(44, 94, 255, 0.2);
    border-radius: 6px;
    opacity: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.token-list-item:hover .token-action-indicator {
    opacity: 1;
}

.token-action-indicator i {
    color: var(--oneinch-blue);
    font-size: 0.75rem;
}

/* No Tokens Found */
.no-tokens-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.no-tokens-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.no-tokens-icon i {
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
}

.no-tokens-text h5 {
    color: #ffffff;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.no-tokens-text p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    margin: 0;
}

/* Modal Footer */
.token-modal-footer {
    padding: 1rem 1.75rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.footer-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    justify-content: center;
}

.footer-info i {
    color: var(--oneinch-blue);
}

/* Responsive Design */
@media (max-width: 768px) {
    .token-modal-content {
        margin: 0.5rem;
        max-height: 90vh;
        border-radius: 20px;
    }

    .token-modal-header {
        padding: 1.25rem 1.5rem 0.75rem;
    }

    .token-modal-title {
        font-size: 1.125rem;
    }

    .token-search-container {
        padding: 1.25rem 1.5rem 0;
        margin-bottom: 1.25rem;
    }

    .popular-tokens-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 1.5rem;
    }

    .token-list-container {
        padding: 0 0.75rem;
    }

    .token-modal-footer {
        padding: 0.75rem 1.5rem 1.25rem;
    }
}

@media (max-width: 480px) {
    /* .popular-tokens-grid {
        grid-template-columns: 1fr;
    } */

    .token-primary-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .token-list-item .token-name {
        font-size: 0.8rem;
    }
}

/* Animation classes for JavaScript */
.token-modal-enter {
    opacity: 0;
    visibility: hidden;
}

.token-modal-enter-active {
    opacity: 1;
    visibility: visible;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.token-modal-leave {
    opacity: 1;
    visibility: visible;
}

.token-modal-leave-active {
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 1, 1);
}

/* Staged entrance of inner elements (iOS-like smoothness) */
.token-modal.enter-prep .token-modal-header,
.token-modal.enter-prep .token-search-container,
.token-modal.enter-prep .network-selector-container,
.token-modal.enter-prep .tokens-display-section .section-header,
.token-modal.enter-prep .tokens-display-section .tokens-container,
.token-modal.enter-prep .token-modal-footer {
    opacity: 0;
    transform: translateY(8px);
}

.token-modal.entering .token-modal-header,
.token-modal.entering .token-search-container,
.token-modal.entering .network-selector-container,
.token-modal.entering .tokens-display-section .section-header,
.token-modal.entering .tokens-display-section .tokens-container,
.token-modal.entering .token-modal-footer {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 280ms ease, transform 280ms ease;
    will-change: opacity, transform;
}

/* subtle stagger */
.token-modal.entering .token-modal-header { transition-delay: 10ms; }
.token-modal.entering .token-search-container { transition-delay: 40ms; }
.token-modal.entering .network-selector-container { transition-delay: 80ms; }
.token-modal.entering .tokens-display-section .section-header { transition-delay: 120ms; }
.token-modal.entering .tokens-display-section .tokens-container { transition-delay: 140ms; }
.token-modal.entering .token-modal-footer { transition-delay: 200ms; }

/* Reduced motion: disable staged transitions */
@media (prefers-reduced-motion: reduce) {
    .token-modal.entering .token-modal-header,
    .token-modal.entering .token-search-container,
    .token-modal.entering .network-selector-container,
    .token-modal.entering .tokens-display-section .section-header,
    .token-modal.entering .tokens-display-section .tokens-container,
    .token-modal.entering .token-modal-footer {
        transition: none;
    }
}

/* Child items staggered entrance (cards) */
.token-modal.enter-prep .tokens-display-section .tokens-container .token-item,
.token-modal.enter-prep .popular-tokens-grid .popular-token-card {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
}

.token-modal.entering .tokens-display-section .tokens-container .token-item,
.token-modal.entering .popular-tokens-grid .popular-token-card {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 220ms ease, transform 220ms ease;
}

/* Stagger for first rows to avoid heavy costs */
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(1) { transition-delay: 40ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(2) { transition-delay: 60ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(3) { transition-delay: 80ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(4) { transition-delay: 100ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(5) { transition-delay: 120ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(6) { transition-delay: 140ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(7) { transition-delay: 160ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(8) { transition-delay: 180ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(9) { transition-delay: 200ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(10) { transition-delay: 220ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(11) { transition-delay: 240ms; }
.token-modal.entering .tokens-display-section .tokens-container .token-item:nth-child(12) { transition-delay: 260ms; }

.token-modal.entering .popular-tokens-grid .popular-token-card:nth-child(1) { transition-delay: 40ms; }
.token-modal.entering .popular-tokens-grid .popular-token-card:nth-child(2) { transition-delay: 60ms; }
.token-modal.entering .popular-tokens-grid .popular-token-card:nth-child(3) { transition-delay: 80ms; }
.token-modal.entering .popular-tokens-grid .popular-token-card:nth-child(4) { transition-delay: 100ms; }
.token-modal.entering .popular-tokens-grid .popular-token-card:nth-child(5) { transition-delay: 120ms; }
.token-modal.entering .popular-tokens-grid .popular-token-card:nth-child(6) { transition-delay: 140ms; }

/* Enhanced hover effects */
.popular-token-card, 
.token-list-item {
    position: relative;
    overflow: hidden;
}

.popular-token-card::before,
.token-list-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.1), 
        transparent);
    transition: left 0.5s ease;
}

.popular-token-card:hover::before,
.token-list-item:hover::before {
    left: 100%;
}

/* Network Filter Styles */
.network-filter-container {
    margin: 1rem 0;
    padding: 0 1.5rem;
}

.network-filter-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--oneinch-text-primary);
    margin-bottom: 0.75rem;
}

.network-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.network-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: var(--oneinch-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
}

.network-tab-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.network-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--oneinch-text-primary);
}

.network-tab.active {
    background: linear-gradient(135deg, var(--oneinch-blue), var(--oneinch-accent-blue));
    border-color: var(--oneinch-blue);
    color: white;
}

.network-tab.active:hover {
    background: linear-gradient(135deg, var(--oneinch-accent-blue), var(--oneinch-blue));
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .network-filter-container {
        padding: 0 1rem;
    }
    
    .network-filter-tabs {
        gap: 0.25rem;
    }
    
    .network-tab {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        gap: 0.4rem;
    }
    
    .network-tab-icon {
        width: 14px;
        height: 14px;
    }
}

/* Popular Tokens Section */


.popular-tokens-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 8px;
    padding-bottom: 8px;
    /* height: 84px; */
    align-items: stretch;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.popular-tokens-grid::-webkit-scrollbar {
    display: none;
}

.popular-token-card {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    width: calc(20% - 4px);
    background: var(--oneinch-card-bg, #1a1a1a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 12px 8px;
    gap: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 68px;
    backdrop-filter: blur(10px);
}

.popular-token-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.popular-token-card.active {
    background: linear-gradient(135deg, 
        rgba(44, 94, 255, 0.2) 0%, 
        rgba(13, 180, 165, 0.15) 100%);
    border-color: var(--oneinch-blue);
    box-shadow: 0 2px 8px rgba(44, 94, 255, 0.3);
}

.popular-token-card .token-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    position: relative;
}

.popular-token-card .token-logo img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 460px) {
    .popular-token-card .token-logo {
        width: 30px;
        height: 30px;
    }

    .popular-token-card .token-symbol {
        font-size: 0.75rem;
    }
}