/**
 * converter.css — 首页汇率换算器
 * 使用位置：仅首页 .fx-converter（index.php）
 * 布局：金额 + 持有/兑换 + 互换；下方展示换算结果（输入即换算）
 * 响应式：PC 横排；Pad 收紧间距；手机 <768 表单换行
 */

/* ---------- 换算器容器：牌价单纸面风格 ---------- */
.fx-converter {
    position: relative;
    z-index: 5;
    background: var(--slip);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 28px rgba(26, 16, 48, 0.06);
    animation: board-in 0.55s ease both;
    overflow: visible;
}

/* ---------- 顶行：金额 / 持有 / 互换 / 兑换 ---------- */
.fx-converter__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
}

.fx-field {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.fx-field--amount {
    flex: 0 0 7.5rem;
}

.fx-field--from,
.fx-field--to {
    flex: 1 1 11rem;
    min-width: 10rem;
}

.fx-field label,
.fx-field__label {
    font-size: 0.88rem;
    color: var(--ink-soft);
    line-height: 1.2;
}

/* 金额输入 */
.fx-amount {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-family: var(--font-data);
    font-size: 1rem;
    line-height: 1.3;
}

.fx-amount:focus {
    border-color: rgba(196, 59, 92, 0.45);
}

/* 货币选择按钮（带旗标） */
.fx-select {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    min-height: 44px;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.fx-select:hover {
    border-color: rgba(196, 59, 92, 0.4);
}

.fx-select[aria-expanded="true"] {
    border-color: var(--carmine);
    box-shadow: 0 0 0 2px rgba(196, 59, 92, 0.12);
}

/* 国旗：与货币对比页 .fx-picker__flag 同比例（22×22 contain，不裁切） */
.fx-select__flag {
    display: block;
    width: 22px;
    height: 22px;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    flex-shrink: 0;
    background: transparent;
}

.fx-select__text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 下拉箭头 */
.fx-select__caret {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--steel);
    flex-shrink: 0;
    margin-left: 0.15rem;
}

/* 货币下拉列表：盖住下方牌价表，常用币已在数据层置顶 */
.fx-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 80;
    max-height: 280px;
    overflow-y: auto;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(26, 16, 48, 0.16);
}

.fx-dropdown[hidden] {
    display: none !important;
}

.fx-dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 44px;
    padding: 0.45rem 0.75rem;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
}

.fx-dropdown__item:hover,
.fx-dropdown__item[aria-selected="true"] {
    background: rgba(196, 59, 92, 0.08);
    color: var(--carmine-deep);
}

.fx-dropdown__item img {
    display: block;
    width: 22px;
    height: 22px;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    flex-shrink: 0;
}

/* 中间互换按钮 */
.fx-swap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    margin-bottom: 2px;
    padding: 0;
    border: 1px solid rgba(196, 59, 92, 0.35);
    border-radius: 50%;
    background: rgba(196, 59, 92, 0.08);
    color: var(--carmine);
    cursor: pointer;
    transition: background 0.15s, transform 0.2s, color 0.15s;
}

.fx-swap:hover {
    background: var(--carmine);
    color: #fff;
    transform: rotate(180deg);
}

/* ---------- 结果区左 + 查询反向汇率右（原立即换算位置） ---------- */
.fx-converter__result {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-top: 1.15rem;
    padding-top: 1.05rem;
    border-top: 1px solid var(--line);
}

.fx-result-main {
    flex: 1 1 16rem;
    min-width: 0;
}

.fx-eq {
    display: inline;
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

.fx-out {
    display: inline;
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.45rem, 3.2vw, 1.85rem);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.02em;
    color: var(--carmine);
}

/* 等号左侧与结果同一行 */
.fx-result-line {
    margin: 0 0 0.65rem;
    font-size: 0.98rem;
    font-weight: 650;
    color: var(--ink);
    line-height: 1.45;
}

.fx-rate,
.fx-inverse,
.fx-updated {
    margin: 0 0 0.28rem;
    font-size: 0.82rem;
    color: var(--steel);
    line-height: 1.5;
}

.fx-updated {
    margin-top: 0.45rem;
    margin-bottom: 0;
}

/* 查询反向汇率：占原「立即换算」主按钮位 */
.fx-inverse-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 8.5rem;
    min-height: 48px;
    padding: 0.7rem 1.4rem;
    border: 0;
    border-radius: 8px;
    background: var(--carmine);
    color: #fff;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.fx-inverse-btn:hover {
    background: var(--carmine-deep);
}

.fx-inverse-btn:active {
    transform: translateY(1px);
}

/* ---------- Pad：768–1024 ---------- */
@media screen and (max-width: 1024px) {
    .fx-converter {
        padding: 1rem 1.05rem 1.1rem;
    }

    .fx-field--amount {
        flex-basis: 6.5rem;
    }
}

/* ---------- 手机：<768 金额通栏，持有/互换/兑换一行 ---------- */
@media screen and (max-width: 767px) {
    .fx-converter__row {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-areas:
            "amount amount amount"
            "from swap to";
        align-items: end;
        gap: 0.75rem 0.55rem;
    }

    .fx-field--amount {
        grid-area: amount;
        flex: none;
        min-width: 0;
    }

    .fx-field--from {
        grid-area: from;
        min-width: 0;
    }

    .fx-swap {
        grid-area: swap;
        justify-self: center;
        margin: 0 0 2px;
    }

    .fx-field--to {
        grid-area: to;
        min-width: 0;
    }

    .fx-converter__result {
        display: block; /* 手机取消 flex，避免中间被撑出大块空白 */
        margin-top: 0.85rem;
        padding-top: 0.85rem;
    }

    .fx-inverse-btn {
        display: flex;
        width: 100%;
        min-width: 0;
        min-height: 44px;
        margin-top: 0.75rem;
    }

    .fx-result-line {
        margin-bottom: 0.4rem;
    }

    .fx-out {
        font-size: 1.25rem;
    }

    .fx-updated {
        margin-top: 0.25rem;
    }
}
