:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --border-color: #e5e7eb;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --error-bg: #fef2f2;
    --error-text: #dc2626;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-wrapper {
    width: 100%;
    max-width: 600px;
}

.container {
    background-color: var(--card-bg);
    padding: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Header Style */
.header {
    background: linear-gradient(135deg, var(--primary-color), #4f46e5);
    padding: 30px 20px;
    text-align: center;
    color: white;
    position: relative;
}

.icon-circle {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 24px;
}

h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.last-update-time {
    position: absolute;
    bottom: 10px;
    right: 20px;
    font-size: 12px;
    opacity: 0.8;
    font-weight: 400;
}

/* Content Area */
.content-area {
    padding: 30px;
}

/* 上下布局容器 */
.layout-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
}

/* 源货币和目标货币容器 */
.input-section, .target-result-section {
    width: 100%;
}

/* 按钮区域居中 */
.button-section {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.button-section .convert-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 600;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 左侧输入区域 */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.source-currency-container {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: #fff;
    overflow: hidden;
    gap: 0;
    min-height: 52px; /* 单输入框高度 */
}

.source-currency-container select {
    flex: 0 0 auto;
    width: 180px;
    border: none;
    border-radius: 0;
    padding: 12px 16px;
    font-size: 16px;
    background-color: #f8f9fa;
    border-right: 1px solid var(--border-color);
    height: 100%; /* 下拉菜单高度等于容器高度 */
    box-sizing: border-box;
    cursor: pointer;
    /* 确保下拉菜单可点击区域占满整个高度 */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    display: block;
    line-height: 1.5; /* 确保文本垂直居中 */
    min-height: 52px; /* 单输入框高度 */
}

.source-currency-container .input-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%; /* 输入区域高度等于容器高度 */
}

.source-currency-container .input-fields input {
    border: none;
    border-radius: 0;
    padding: 12px 16px;
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
    height: 52px; /* 固定单输入框高度 */
}

.source-currency-container .input-fields input:first-child {
    border-bottom: 1px solid var(--border-color);
}

.source-currency-container .input-fields input:focus,
.source-currency-container select:focus {
    outline: none;
    box-shadow: none;
}

.input-group {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-main);
    font-size: 14px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: stretch;
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #fff;
}


input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 中间按钮区域 */
.button-section {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.button-section .convert-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 600;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 右侧目标货币和结果区域 */
.target-result-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.target-currency-container {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: #fff;
    overflow: hidden;
    gap: 0;
    min-height: 104px; /* 确保最小高度等于两个结果卡片的总高度 */
}

/* 更具体的下拉修复：覆盖通用 input, select 规则，确保下拉高度和父容器一致 */
.source-currency-container > select,
.target-currency-container > select {
    flex: 0 0 180px; /* 固定宽度但允许高度拉伸 */
    width: 180px;
    align-self: stretch; /* 强制垂直拉伸以填满父容器 */
    height: 100%;
    box-sizing: border-box;
    /* 添加下拉箭头 */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' 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 12px center;
    background-size: 16px;
    padding-right: 40px; /* 为箭头留出空间 */
}

.target-currency-container select {
    flex: 0 0 auto;
    width: 180px;
    border: none;
    border-radius: 0;
    padding: 12px 16px;
    font-size: 16px;
    background-color: #f8f9fa;
    border-right: 1px solid var(--border-color);
    height: 100%; /* 下拉菜单高度等于容器高度 */
    box-sizing: border-box;
    cursor: pointer;
    /* 确保下拉菜单可点击区域占满整个高度 */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    display: block;
    line-height: 1.5; /* 确保文本垂直居中 */
    min-height: 104px; /* 确保下拉菜单高度等于两个结果卡片的高度之和 */
}

.target-currency-container .result-container {
    flex: 1;
    margin-top: 0;
    display: block !important;
    height: 100%; /* 结果区域高度等于容器高度 */
}

.target-currency-container .result-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%; /* 结果网格高度等于容器高度 */
}

.target-currency-container .result-card {
    flex: 1; /* 每个结果卡片平均分配高度 */
    border: none;
    border-radius: 0;
    padding: 12px 16px;
    min-height: 52px; /* 确保每个结果卡片高度一致，与输入框保持一致 */
    height: 100%; /* 确保结果卡片占满可用高度 */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: white;
    transition: background-color 0.2s;
    cursor: pointer;
    box-sizing: border-box;
}

.target-currency-container .result-card:last-child {
    border-bottom: none;
}

.target-currency-container .result-card:hover {
    border-color: #cbd5e1;
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.target-currency-container .result-card .value {
    font-size: 16px;
    font-weight: normal;
    color: black;
    text-align: left;
    margin: 0;
}

.result-container {
    margin-top: 0;
    display: block !important;
}

.result-grid {
    display: grid;
    gap: 12px;
}

.result-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    position: relative;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px; /* 与输入框高度保持一致 */
    height: 100%; /* 确保结果卡片占满可用高度 */
    box-sizing: border-box;
}

.result-card:hover {
    border-color: #cbd5e1;
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.result-card .value {
    margin: 0;
    font-size: 16px;
    font-weight: normal;
    color: black;
    text-align: center;
}

/* Button */
.convert-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.2s;
}

.convert-btn:hover {
    background-color: var(--primary-hover);
}

.convert-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}


/* Result Area */
.result-container {
    margin-top: 0;
    display: none;
}

.result-grid {
    display: grid;
    gap: 12px;
}

/* 复制反馈动画 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}


/* Mobile Optimization */
@media (max-width: 480px) {
    .container {
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
    }
    .main-wrapper {
        max-width: 100%;
    }
    body {
        padding: 0;
    }
}