/* 全局字体大小体系 */
:root {
    --font-xs: 0.75rem;      /* 12px */
    --font-sm: 0.875rem;     /* 14px */
    --font-base: 1rem;       /* 16px */
    --font-lg: 1.125rem;     /* 18px */
    --font-xl: 1.25rem;      /* 20px */
    --font-2xl: 1.5rem;      /* 24px */
    --font-3xl: 1.875rem;    /* 30px */
    --font-4xl: 2.25rem;     /* 36px */
    --font-5xl: 3rem;        /* 48px */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #0f1419;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-size: var(--font-base);
    line-height: 1.5;
}

.container {
    background-color: #ffffff;
    padding: 2rem;
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* 主布局容器 */
.main-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 输入面板样式 */
.input-panel {
    width: 100%;
    max-width: 28rem;
    margin: 0 auto;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 结果面板样式 */
.results-panel {
    width: 100%;
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* 显示结果时的样式 */
.results-panel.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* 过期结果样式 */
.results-panel.outdated {
    opacity: 0.5;
    filter: grayscale(50%);
}

.results-panel.outdated .stat-value {
    color: #9ca3af !important;
}

.results-panel.outdated .main-result {
    color: #9ca3af !important;
}

.results-panel.outdated .chart-title {
    color: #9ca3af !important;
}

/* 桌面端动态布局 */
@media (min-width: 80rem) {
    .container {
        padding: 3rem;
    }
    
    /* 默认居中状态 */
    .main-layout {
        justify-content: center;
        align-items: center;
        min-height: 70vh;
    }
    
    /* 显示结果时的左右布局 */
    .main-layout.results-active {
        flex-direction: row;
        gap: 4rem;
        align-items: flex-start;
        justify-content: flex-start;
        min-height: auto;
    }
    
    .main-layout.results-active .input-panel {
        flex: 0 0 28rem;
        margin: 0;
        position: sticky;
        top: 3rem;
        max-height: calc(100vh - 6rem);
        overflow-y: auto;
    }
    
    .main-layout.results-active .results-panel {
        flex: 1;
        min-width: 0;
    }
}

/* 结果区域高度优化 */
.results-container {
    display: grid;
    gap: 0.75rem;
}

/* 桌面端布局优化 */
@media (min-width: 80rem) {
    .results-container {
        max-height: calc(100vh - 10rem);
        overflow-y: auto;
    }
}

.header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eff3f4;
}

.header h1 {
    color: #1d9bf0;
    font-size: var(--font-4xl);
    margin-bottom: 0.5rem;
    font-weight: 800;
}

.header-description {
    color: #536471;
    font-size: var(--font-lg);
    font-weight: 400;
}

.input-section {
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: #0f1419;
    font-size: var(--font-base);
}

.input-group input[type="number"],
.input-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #eff3f4;
    border-radius: 12px;
    font-size: var(--font-base);
    color: #0f1419;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #ffffff;
}

.input-group input[type="number"]:focus,
.input-group select:focus {
    border-color: #1d9bf0;
    box-shadow: 0 0 0 4px rgba(29, 155, 240, 0.1);
    outline: none;
}

.input-helper {
    font-size: var(--font-sm);
    color: #536471;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.calculate-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background-color: #1d9bf0;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: var(--font-lg);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(29, 155, 240, 0.3);
}

.calculate-btn:hover {
    background-color: #1a8cd8;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(29, 155, 240, 0.4);
}

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

#results {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eff3f4;
    text-align: center;
}

.main-result {
    font-size: var(--font-5xl);
    color: #1d9bf0;
    font-weight: 800;
    margin-bottom: 0;
}

.main-result-label {
    font-size: var(--font-lg);
    color: #536471;
    margin-bottom: 0;
    font-weight: 400;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 0;
    justify-content: center;
}

/* 中等屏幕调整为2列3行 */
@media (max-width: 64rem) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background-color: #ffffff;
    padding: 1.25rem;
    border-radius: 16px;
    border: 2px solid #eff3f4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
    text-align: center;
}

.stat-card:hover {
    border-color: #1d9bf0;
    box-shadow: 0 4px 12px rgba(29, 155, 240, 0.1);
}

.stat-value {
    font-size: var(--font-xl);
    font-weight: 800;
    color: #1d9bf0;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.stat-label {
    font-size: var(--font-sm);
    color: #536471;
    font-weight: 500;
}

.warning {
    background-color: #fff8e7;
    color: #ad5700;
    padding: 1.25rem;
    border-radius: 16px;
    border: 2px solid #ffd280;
    margin-top: 1rem;
    font-size: var(--font-sm);
    font-weight: 500;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

#chartSection {
    margin-top: 0;
}

.chart-section {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 16px;
    border: 2px solid #eff3f4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.chart-title {
    font-size: var(--font-2xl);
    color: #1d9bf0;
    margin-bottom: 0;
    text-align: center;
    font-weight: 800;
}

.chart-container {
    position: relative;
    height: 20rem;
    width: 100%;
}

#growthChart {
    max-width: 100%;
    height: auto;
}

@media (max-width: 1199px) {
    .main-layout {
        flex-direction: column;
        gap: 2rem;
    }
}

/* 桌面端布局优化 */
@media (min-width: 80rem) {
    #results {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }
    
    #chartSection {
        margin-top: 1.5rem;
    }
}

/* 中等屏幕 */
@media (max-width: 79.99rem) {
    .main-layout {
        flex-direction: column;
        gap: 2rem;
    }
}

/* 小屏幕优化 */
@media (max-width: 48rem) {
    .container {
        padding: 1.5rem 1rem;
    }

    .main-layout {
        gap: 1.5rem;
    }

    .header h1 {
        font-size: var(--font-3xl);
    }

    .header-description {
        font-size: var(--font-base);
    }

    .input-group {
        margin-bottom: 1rem;
    }

    .input-group input[type="number"],
    .input-group select {
        padding: 0.625rem 0.75rem;
        font-size: var(--font-sm);
    }

    .calculate-btn {
        font-size: var(--font-base);
        padding: 0.875rem;
    }

    .main-result {
        font-size: var(--font-4xl);
    }

    .main-result-label {
        font-size: var(--font-lg);
    }

    .main-result-label {
        font-size: var(--font-lg);
    }

    .chart-title {
        font-size: var(--font-xl);
    }

    .chart-container {
        height: 16rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: var(--font-lg);
    }
}

/* 超小屏幕 */
@media (max-width: 30rem) {
    .container {
        padding: 1rem 0.75rem;
    }

    .header h1 {
        font-size: var(--font-2xl);
    }

    .chart-container {
        height: 14rem;
    }

    .input-section {
        margin-bottom: 1.5rem;
    }
}

/* 计算模式选择器样式 */
.calculation-mode {
    margin-bottom: 2rem;
}

.mode-title {
    font-size: var(--font-lg);
    font-weight: 700;
    color: #0f1419;
    margin-bottom: 1rem;
    text-align: center;
}

.mode-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 48rem) {
    .mode-buttons {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.mode-btn {
    background-color: #ffffff;
    border: 2px solid #eff3f4;
    border-radius: 16px;
    padding: 1.25rem 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    font-family: inherit;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mode-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(29, 155, 240, 0.1),
        transparent
    );
    transition: left 0.5s ease;
}

.mode-btn:hover::before {
    left: 100%;
}

.mode-btn:hover {
    border-color: #1d9bf0;
    box-shadow: 
        0 8px 25px rgba(29, 155, 240, 0.15),
        0 3px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px) scale(1.02);
    background-color: #fafbff;
}

.mode-btn.active {
    background: linear-gradient(135deg, #1d9bf0 0%, #1a8cd8 100%);
    border-color: #1d9bf0;
    color: white;
    box-shadow: 
        0 12px 30px rgba(29, 155, 240, 0.4),
        0 4px 15px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* 添加按钮内容的动态效果 */
.mode-btn h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    transition: all 0.3s ease;
}

.mode-btn:hover h3 {
    font-weight: 700;
    transform: scale(1.05);
}

.mode-btn.active h3 {
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 添加微妙的脉冲效果给激活状态 */
.mode-btn.active {
    animation: subtle-pulse 3s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% {
        box-shadow: 
            0 12px 30px rgba(29, 155, 240, 0.4),
            0 4px 15px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 
            0 15px 35px rgba(29, 155, 240, 0.5),
            0 5px 18px rgba(0, 0, 0, 0.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
}

/* 优化悬停时的光泽效果 */
.mode-btn:hover {
    background: linear-gradient(135deg, #fafbff 0%, #f0f8ff 100%);
}

.mode-btn.active:hover {
    background: linear-gradient(135deg, #1d9bf0 0%, #1a8cd8 100%);
    animation: none; /* 悬停时暂停脉冲 */
    box-shadow: 
        0 15px 40px rgba(29, 155, 240, 0.6),
        0 5px 20px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.mode-btn.active::before {
    display: none;
}

.mode-btn:active {
    transform: translateY(-1px) scale(0.98);
    transition: all 0.1s ease;
}

.mode-icon {
    font-size: var(--font-2xl);
    margin-bottom: 0.25rem;
}

.mode-label {
    font-size: var(--font-base);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.mode-desc {
    font-size: var(--font-sm);
    opacity: 0.8;
    font-weight: 400;
    transition: all 0.3s ease;
    color: #657786;
}

.mode-btn.active .mode-desc {
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.9);
}

.mode-btn:hover .mode-desc {
    opacity: 0.9;
    color: #536471;
}

@media (max-width: 48rem) {
    .mode-btn {
        min-height: 80px;
        padding: 1rem;
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
    }
    
    .mode-btn:hover {
        transform: translateY(-2px) scale(1.01);
        box-shadow: 
            0 6px 20px rgba(29, 155, 240, 0.12),
            0 2px 8px rgba(0, 0, 0, 0.06);
    }
    
    .mode-btn.active {
        transform: translateY(-1px);
        box-shadow: 
            0 8px 25px rgba(29, 155, 240, 0.35),
            0 3px 12px rgba(0, 0, 0, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    
    .mode-btn:hover h3 {
        transform: scale(1.03);
    }
    
    .mode-icon {
        font-size: var(--font-xl);
        margin-bottom: 0;
        margin-right: 1rem;
        flex-shrink: 0;
        transition: transform 0.3s ease;
    }
    
    .mode-btn:hover .mode-icon {
        transform: scale(1.1);
    }
    
    .mode-content {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .mode-label {
        margin-bottom: 0.125rem;
    }
}

.main-result-container {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 48rem) {
    .main-result-container {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
}

/* 性能优化：减少不必要的重绘 */
.mode-btn {
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 为支持减少动画的用户优化 */
@media (prefers-reduced-motion: reduce) {
    .mode-btn,
    .mode-btn::before,
    .mode-desc,
    .mode-btn h3,
    .mode-icon {
        animation: none !important;
        transition: none !important;
    }
    
    .mode-btn:hover,
    .mode-btn.active {
        transform: none !important;
    }
}

/* 为焦点状态添加无障碍支持 */
.mode-btn:focus-visible {
    outline: 3px solid #1d9bf0;
    outline-offset: 2px;
    box-shadow: 
        0 0 0 3px rgba(29, 155, 240, 0.3),
        0 8px 25px rgba(29, 155, 240, 0.15),
        0 3px 12px rgba(0, 0, 0, 0.08);
}

.mode-btn.active:focus-visible {
    outline-color: #ffffff;
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 0.8),
        0 12px 30px rgba(29, 155, 240, 0.4),
        0 4px 15px rgba(0, 0, 0, 0.1);
}