/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基础样式 */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 60px 0;
    text-align: center;
    margin-bottom: 40px;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.logo {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    padding: 20px 0;
}

/* 工具网格布局 */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

/* 工具卡片样式 */
.tool-card {
    background: white;
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e9ecef;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.tool-card:hover::before {
    transform: scaleX(1);
}

.tool-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}

.tool-card h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #2c3e50;
}

.tool-card p {
    color: #6c757d;
    margin-bottom: 24px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.desktop-recommendation {
    color: #ffc107 !important;
    font-size: 0.9rem !important;
    font-weight: 500;
    margin-bottom: 16px !important;
    background: rgba(255, 193, 7, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 193, 7, 0.3);
    text-align: center;
}

/* 按钮样式 */
.tool-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.tool-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.tool-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.tool-button:hover::before {
    left: 100%;
}

.tool-button:active {
    transform: translateY(0);
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 32px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.close-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 32px;
}

/* 计算器表单样式 */
.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input.error {
    border-color: #e74c3c;
    background-color: #fdf2f2;
}

.error-message {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* 结果区域样式 */
.result-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 24px;
    margin-top: 24px;
    border: 1px solid #dee2e6;
}

.result-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 16px;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 8px;
}

.result-description {
    color: #6c757d;
    font-size: 0.9rem;
}

/* 家庭开支计算器专用样式 */
.budget-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.budget-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.budget-section h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 货币选择器样式 */
.currency-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.currency-selector label {
    font-weight: 500;
    color: #2c3e50;
    white-space: nowrap;
}

.currency-select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.95rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.currency-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.income-form,
.expense-form {
    margin-bottom: 20px;
}

.item-list {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    min-height: 60px;
    border: 2px dashed #dee2e6;
}

.item-list:empty::before {
    content: 'No records yet. Please add income or expense items.';
    display: block;
    text-align: center;
    padding: 2rem;
    color: var(--text-color-light);
    font-style: italic;
    font-size: 0.95rem;
    border-radius: 8px;
    background-color: var(--background-color-secondary);
}

.budget-item {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.budget-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.budget-item:last-child {
    margin-bottom: 0;
}

.item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-name {
    font-weight: 500;
    color: #2c3e50;
}

.item-details {
    font-size: 0.85rem;
    color: #6c757d;
}

.item-amount {
    font-weight: 600;
    font-size: 1.1rem;
}

.item-amount.income {
    color: #28a745;
}

.item-amount.expense {
    color: #dc3545;
}

.delete-item {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.delete-item:hover {
    background-color: #f8d7da;
}

/* 报表操作按钮样式 */
.report-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tool-button.secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.tool-button.secondary:hover {
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
}

/* 预算报表样式 */
.budget-report {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 24px;
    margin-top: 20px;
    border: 1px solid #dee2e6;
}

.budget-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-item {
    background: white;
    padding: 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #e9ecef;
}

.summary-label {
    font-weight: 500;
    color: #2c3e50;
}

.summary-value {
    font-weight: 600;
    font-size: 1.1rem;
}

.summary-value.income {
    color: #28a745;
}

.summary-value.expense {
    color: #dc3545;
}

.summary-value.positive {
    color: #28a745;
}

.summary-value.negative {
    color: #dc3545;
}

.summary-value.warning {
    color: #ffc107;
}

.expense-breakdown {
    margin-bottom: 24px;
}

.expense-breakdown h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 16px;
}

.category-list {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.category-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
}

.category-item:last-child {
    border-bottom: none;
}

.category-item:nth-child(even) {
    background-color: #f8f9fa;
}

.category-name {
    font-weight: 500;
    color: #2c3e50;
}

.category-amount {
    font-weight: 600;
    color: #dc3545;
    text-align: center;
}

.category-percentage {
    color: #6c757d;
    text-align: right;
    font-size: 0.9rem;
}

.budget-recommendations {
    background: white;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e9ecef;
}

.budget-recommendations h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 16px;
}

.budget-recommendations ul {
    list-style: none;
    padding: 0;
}

.budget-recommendations li {
    padding: 8px 0;
    border-bottom: 1px solid #f1f3f4;
    color: #2c3e50;
}

.budget-recommendations li:last-child {
    border-bottom: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    .header {
        padding: 40px 0;
    }
    .logo {
        font-size: 2.5rem;
    }
    .subtitle {
        font-size: 1.1rem;
    }
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .tool-card {
        padding: 24px;
    }
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    .modal-header,
    .modal-body {
        padding: 24px;
    }
    .form-row {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }
    
    /* 移动端预算计算器表单布局优化 */
    .budget-container .form-row {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    .budget-container .form-row .form-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .budget-container .form-row .form-group label {
        font-weight: 500;
        color: #2c3e50;
        margin-bottom: 4px;
    }
    
    .budget-container .form-row .form-group input,
    .budget-container .form-row .form-group select {
        width: 100%;
        padding: 12px 16px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        font-size: 1rem;
        transition: all 0.3s ease;
    }
    
    .budget-container .form-row .form-group input:focus,
    .budget-container .form-row .form-group select:focus {
        outline: none;
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }
    
    .budget-summary {
        flex-direction: column;
        gap: 15px;
    }
    .category-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .category-amount,
    .category-percentage {
        padding-left: 15px;
    }

    /* General Calculator Layout for Mobile */
    .calculator-layout {
        flex-direction: column;
        gap: 24px;
    }
    .result-container {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #e9ecef;
        padding-top: 24px;
    }
    
    .tip-options {
        flex-wrap: wrap;
    }
    .tip-option {
        flex-basis: calc(33.333% - 8px);
    }
    .tip-summary {
        padding: 0;
    }
    .summary-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 2.2rem;
    }
    .tool-card {
        padding: 20px;
    }
    .tool-button {
        padding: 10px 24px;
        font-size: 0.95rem;
    }
    
    /* 小屏幕预算计算器进一步优化 */
    .budget-container .form-row {
        gap: 16px;
    }
    
    .budget-container .form-row .form-group {
        gap: 6px;
    }
    
    .budget-container .form-row .form-group label {
        font-size: 0.95rem;
        margin-bottom: 2px;
    }
    
    .budget-container .form-row .form-group input,
    .budget-container .form-row .form-group select {
        padding: 10px 14px;
        font-size: 0.95rem;
    }
    
    .budget-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .budget-section h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
}

/* 页面加载动画 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 工具提示样式 */
.tooltip {
    position: relative;
    display: inline-block;
}
.tooltip .tooltiptext {
    visibility: hidden;
    width: 140px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -70px;
    opacity: 0;
    transition: opacity 0.3s;
}
.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Tip Calculator Specific Styles */
.tip-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tip-option {
    flex: 1 1 auto;
    padding: 10px;
    font-size: 0.95rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.tip-option:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}
.tip-option.active {
    background: linear-gradient(135deg, #6a82fb 0%, #7b4bff 100%);
    color: white;
    border-color: transparent;
    font-weight: 500;
}
.tip-summary {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
}
.summary-row:last-child {
    border-bottom: none;
}
.summary-label {
    color: #6c757d;
    font-size: 0.95rem;
}
.summary-value {
    font-weight: 600;
}
.summary-value.highlight {
    font-size: 1.1rem;
    color: #667eea;
}

/* New Responsive Calculator Layout */
.calculator-layout {
    display: flex;
    gap: 32px;
}

.form-container {
    flex: 1;
    min-width: 0; /* Prevents overflow in flex container */
}

.result-container {
    flex: 1;
    border-left: 1px solid #e9ecef;
    padding-left: 32px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.result-container .result-section {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-container .result-title {
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 600;
}
.result-container .result-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
} 