/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #8e8e93;
    --text-muted: #6e6e73;
    --accent-orange: #ff9f0a;
    --accent-green: #30d158;
    --border-color: #2c2c2e;
    --surface: #1c1c1e;
    --error: #ff3b30;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== App Header ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 12px 0;
    margin-bottom: 16px;
    position: relative;
}

.app-header-left,
.app-header-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.app-header-left {
    justify-content: flex-start;
}

.app-header-right {
    justify-content: flex-end;
}

.main-title {
    font-size: 42px;
    font-weight: 400;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.5px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.app-header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    background: var(--accent-orange);
    border: none;
    border-radius: 20px;
    color: var(--bg-primary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    text-decoration: none;
}

.app-header-btn.secondary {
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.app-header-btn.secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.app-header-btn:hover {
    background: #ffb340;
    transform: translateY(-1px);
}

.app-header-btn:active {
    transform: translateY(0);
}

/* ===== Year Section ===== */
.year-section {
    text-align: center;
    margin-bottom: 20px;
    padding-top: 4px;
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 16px;
}

.year-slider-container {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 4px;
}

.year-slider {
    /* 防止任何形式的输入 */
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #1C1C1E;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-bottom: 20px;
    padding: 0;
    cursor: pointer;
}

.year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FF9F0A;
    border: 2px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: -8px;
    box-shadow: 0 2px 8px rgba(255, 159, 10, 0.4), 0 0 0 0 rgba(255, 159, 10, 0.1);
}

.year-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(255, 159, 10, 0.5), 0 0 0 4px rgba(255, 159, 10, 0.1);
}

.year-slider::-webkit-slider-thumb:active {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(255, 159, 10, 0.4), 0 0 0 3px rgba(255, 159, 10, 0.15);
}

.year-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FF9F0A;
    border: 2px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 159, 10, 0.4), 0 0 0 0 rgba(255, 159, 10, 0.1);
}

.year-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(255, 159, 10, 0.5), 0 0 0 4px rgba(255, 159, 10, 0.1);
}

.year-slider::-moz-range-thumb:active {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(255, 159, 10, 0.4), 0 0 0 3px rgba(255, 159, 10, 0.15);
}

.year-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #8E8E93;
    padding: 0 2px;
    position: relative;
    margin-top: 4px;
}

.year-label {
    font-weight: 500;
    transition: color 0.2s ease;
}

.year-label.highlight-year {
    color: #FF9F0A;
    font-weight: 600;
}

/* ===== Input Area ===== */
.input-area {
    margin-bottom: 24px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.amount-input {
    width: 140px;
    padding: 20px 24px;
    font-size: 32px;
    font-weight: 400;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    text-align: center;
    font-family: inherit;
    transition: border-color 0.2s;
}

.amount-input:focus {
    outline: none;
    border-color: var(--accent-orange);
}

.amount-input::placeholder {
    color: var(--text-muted);
}

.currency-select-wrapper {
    flex: 1;
    position: relative;
    min-width: 200px;
    max-width: 400px;
}

.currency-select {
    width: 100%;
    padding: 20px 48px 20px 24px;
    font-size: 24px;
    font-weight: 400;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
}

.custom-token-search-btn {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 159, 10, 0.1);
    border: 1px solid rgba(255, 159, 10, 0.3);
    border-radius: 8px;
    color: var(--accent-orange);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.custom-token-search-btn:hover {
    background: rgba(255, 159, 10, 0.2);
    border-color: var(--accent-orange);
    transform: translateY(-50%) scale(1.05);
}

.custom-token-search-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.currency-select optgroup {
    font-size: 14px;
}

.currency-select option {
    font-size: 20px;
    padding: 8px;
}

.currency-select option[value="CUSTOM"] {
    font-size: 16px;
    color: var(--text-secondary);
}

.currency-select:focus {
    outline: none;
    border-color: var(--accent-orange);
}

/* ===== Results Container ===== */
.results-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.etf-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.etf-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.etf-card-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.etf-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.etf-title-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.etf-symbol {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.etf-name {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
}

.etf-price {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== Share Badge ===== */
.share-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 14px 20px;
    margin-bottom: 28px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.shares-label {
    font-size: 12px;
    color: #8E8E93;
    font-weight: 400;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    line-height: 1.2;
}

.shares-value {
    font-size: 32px;
    font-weight: 700;
    color: #FF9F0A;
    line-height: 1.1;
    letter-spacing: -0.8px;
}

/* ===== Projection Row ===== */
.projection-grid {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 32px;
    align-items: start;
    padding-top: 4px;
}

.projection-divider {
    width: 1px;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        var(--border-color) 10%, 
        var(--border-color) 90%, 
        transparent 100%);
    align-self: stretch;
    opacity: 0.6;
}

/* ===== Projection Left (10 Year Projection) ===== */
.projection-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
}

.projection-title {
    font-size: 13px;
    color: #8E8E93;
    margin-bottom: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.projection-main {
    font-size: 40px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.15;
    letter-spacing: -1.2px;
}

.projection-gain {
    font-size: 18px;
    color: var(--accent-green);
    font-weight: 600;
    line-height: 1.5;
}

/* ===== Equivalent Right (Equivalent Items) ===== */
.equivalent-right {
    display: flex;
    flex-direction: column;
}

.equivalent-title-small {
    font-size: 13px;
    color: #8E8E93;
    margin-bottom: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.equivalent-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.equivalent-item-small {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    min-height: 32px;
}

.equivalent-icon {
    font-size: 24px;
    flex-shrink: 0;
    margin-right: 12px;
    line-height: 1;
}

.equivalent-name-small {
    flex: 1;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    text-align: left;
}

.equivalent-count-small {
    color: var(--accent-orange);
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    margin-left: 16px;
    letter-spacing: 0.1px;
}


/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    padding: 16px 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-text {
    font-size: 16px;
    color: var(--text-primary);
}

/* ===== Modal ===== */
.modal {
    display: none; /* 默认隐藏，JavaScript会设置为flex */
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    animation: fadeIn 0.3s ease-out;
    align-items: center; /* 垂直居中 */
    justify-content: center; /* 水平居中 */
}

.modal-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    margin: 0; /* 移除 margin，因为父容器已经居中 */
    padding: 0;
    max-width: 90%;
    max-height: 90vh;
    border-radius: 20px;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    z-index: 10001;
}

.image-modal-content {
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 90%; /* 限制最大宽度 */
    width: fit-content; /* 根据内容自适应宽度 */
    margin: 0 auto; /* 居中显示 */
}

.modal-preview-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center; /* 垂直居中 */
    padding: 40px;
    max-height: calc(90vh - 120px);
    overflow: hidden; /* 改为 hidden，防止滚动条 */
    background: var(--bg-primary);
}

.modal-preview-container img {
    max-width: 100%; /* 图片占满容器宽度 */
    max-height: calc(90vh - 200px); /* 限制最大高度，确保在预览窗口内完整显示 */
    width: auto;
    height: auto;
    display: block;
    border-radius: 12px;
    object-fit: contain; /* 确保完整显示图片，等比例缩放 */
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    color: var(--text-primary);
    font-size: 36px;
    font-weight: 300;
    cursor: pointer;
    z-index: 10002;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    transition: all 0.2s;
    border: none;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-actions {
    display: flex;
    gap: 12px;
    padding: 24px;
    justify-content: center;
    border-top: 1px solid var(--border-color);
}

.modal-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 400;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.modal-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

.modal-btn.primary {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    color: var(--bg-primary);
    font-weight: 500;
}

.modal-btn.primary:hover {
    background: #ffb340;
    border-color: #ffb340;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== Custom Token Modal ===== */
.token-modal-content {
    max-width: 540px;
    width: 90%;
    padding: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.modal-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-body {
    padding: 24px;
}

.modal-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.search-container {
    position: relative;
}

.token-search-input {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    margin-bottom: 16px;
}

.token-search-input:focus {
    outline: none;
    border-color: var(--accent-orange);
}

.loading-indicator {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
}

.search-results {
    max-height: 450px;
    overflow-y: auto;
    margin-top: 8px;
}

/* 滚动条样式 */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.token-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.token-result:hover {
    background: var(--surface);
}

.token-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.token-content {
    flex: 1;
}

.token-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.token-symbol {
    font-size: 14px;
    color: var(--text-secondary);
}

.no-results {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .main-title {
        font-size: 32px;
    }
    
    .subtitle {
        font-size: 14px;
    }
    
    .amount-input {
        font-size: 28px;
        padding: 16px 20px;
        width: 120px;
    }
    
    .currency-select-wrapper {
        min-width: 160px;
        max-width: 280px;
    }
    
    .currency-select {
        font-size: 20px;
        padding: 16px 40px 16px 20px;
        background-position: right 12px center;
        background-size: 16px;
    }
    
    .custom-token-search-btn {
        right: 40px;
        width: 28px;
        height: 28px;
    }
    
    .custom-token-search-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .currency-select option[value="CUSTOM"] {
        font-size: 14px;
    }
    
    .results-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .etf-card {
        padding: 20px;
    }
    
    .etf-symbol {
        font-size: 24px;
    }
    
    .projection-main {
        font-size: 26px;
    }
    
    .projection-gain {
        font-size: 16px;
    }
    
    .main-title {
        font-size: 32px;
        position: static;
        transform: none;
        order: -1;
        flex-basis: 100%;
        text-align: center;
        margin-bottom: 8px;
    }
    
    .app-header {
        flex-wrap: wrap;
        gap: 12px;
        padding: 8px 0 12px 0;
    }
    
    .app-header-left,
    .app-header-right {
        flex: 1;
    }
    
    .app-header-right {
        justify-content: flex-end;
    }
    
    
    .app-header-btn {
        padding: 7px 14px;
        font-size: 13px;
    }
    
    .app-header-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .modal-content {
        margin: 20px auto;
        max-width: 95%;
    }
    
    .token-modal-content {
        width: 95%;
        max-width: 95%;
    }
    
    .modal-header {
        padding: 20px 20px 12px 20px;
    }
    
    .modal-header h3 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .search-results {
        max-height: 350px;
    }
    
    .modal-preview-container {
        padding: 24px 16px;
        max-height: calc(90vh - 100px);
    }
    
    .modal-preview-container img {
        max-height: calc(90vh - 160px); /* 移动端也限制高度，等比例缩小 */
    }
    
    .modal-actions {
        flex-direction: column;
        padding: 20px;
    }
    
    .modal-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }
    
    .container {
        padding: 0 12px;
    }
    
    .main-title {
        font-size: 28px;
    }
    
    .subtitle {
        font-size: 14px;
    }
    
    .amount-input {
        font-size: 24px;
        padding: 14px 16px;
        width: 100px;
    }
    
    .currency-select-wrapper {
        min-width: 140px;
        max-width: 220px;
    }
    
    .currency-select {
        font-size: 18px;
        padding: 14px 36px 14px 16px;
        background-position: right 10px center;
        background-size: 14px;
    }
    
    .custom-token-search-btn {
        right: 36px;
        width: 24px;
        height: 24px;
    }
    
    .custom-token-search-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .currency-select option[value="CUSTOM"] {
        font-size: 13px;
    }
    
    .etf-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .etf-shares {
        text-align: left;
    }
    
    .share-badge {
        padding: 12px 18px;
        margin-bottom: 24px;
    }
    
    .shares-label {
        font-size: 11px;
        margin-bottom: 5px;
    }
    
    .shares-value {
        font-size: 26px;
    }
    
    .projection-grid {
        grid-template-columns: 1fr;
        gap: 24px;
        padding-top: 0;
    }
    
    .projection-divider {
        display: none;
    }
    
    .projection-main {
        font-size: 32px;
    }
    
    .projection-gain {
        font-size: 16px;
    }
    
    .equivalent-icon {
        font-size: 22px;
        margin-right: 10px;
    }
    
    .equivalent-name-small,
    .equivalent-count-small {
        font-size: 15px;
    }
}

