/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1a73e8;
    --success-color: #34a853;
    --danger-color: #ea4335;
    --warning-color: #fbbc04;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 加载中 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 头部 */
.header {
    background: var(--primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 20px;
    font-weight: 500;
}

.icon-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.icon-btn:active {
    background: rgba(255,255,255,0.3);
}

.refresh-icon {
    font-size: 24px;
    display: inline-block;
}

.refresh-icon.spinning {
    animation: spin 1s linear infinite;
}

/* 总资产卡片 */
.summary-card {
    background: var(--card-bg);
    margin: 16px;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-item .label {
    font-size: 12px;
    color: var(--text-secondary);
}

.summary-item .value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.summary-item .value.profit {
    color: var(--success-color);
}

.summary-item .value.loss {
    color: var(--danger-color);
}

/* 操作按钮 */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px;
    margin-bottom: 20px;
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

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

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: none;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:active {
    background: var(--bg-color);
}

.btn-icon {
    font-size: 20px;
}

/* 持仓列表 */
.holdings-section,
.trades-section {
    padding: 0 16px;
    margin-bottom: 24px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.holdings-list,
.trades-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.holding-card,
.trade-card {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.holding-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.holding-info {
    flex: 1;
}

.holding-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.holding-code {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.holding-details {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.holding-stats {
    text-align: right;
}

.holding-price {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.holding-profit {
    font-size: 14px;
    font-weight: 500;
}

.profit-positive {
    color: var(--success-color);
}

.profit-negative {
    color: var(--danger-color);
}

/* 交易记录卡片 */
.trade-card {
    display: flex;
    justify-content: space-between;
}

.trade-info {
    flex: 1;
}

.trade-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.trade-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-buy {
    background: #fce4ec;
    color: var(--danger-color);
}

.badge-sell {
    background: #e8f5e9;
    color: var(--success-color);
}

.trade-stock {
    font-size: 15px;
    font-weight: 600;
}

.trade-details {
    font-size: 13px;
    color: var(--text-secondary);
}

.trade-amount {
    text-align: right;
    font-size: 16px;
    font-weight: 600;
}

.trade-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: flex-end;
}

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

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 表单 */
form {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.stock-name {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: var(--success-color);
}

.hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 16px;
    transition: color 0.3s;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 12px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state-text {
    font-size: 15px;
}

/* 响应式 */
@media (max-width: 480px) {
    /* 缩小总资产卡片的字体 */
    .summary-item .value {
        font-size: 15px;
    }

    .summary-item .label {
        font-size: 11px;
    }

    /* 调整持仓卡片 */
    .holding-price {
        font-size: 16px;
    }

    .holding-name {
        font-size: 14px;
    }

    /* 缩小按钮文字 */
    .btn {
        font-size: 14px;
        padding: 12px 16px;
    }

    /* 调整头部 */
    .header h1 {
        font-size: 18px;
    }

    /* 调整可编辑项显示 */
    .editable-item span {
        font-size: 14px !important;
    }

    .editable-item span:first-child {
        font-size: 11px !important;
    }
}

@media (min-width: 768px) {
    body {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: 0 0 20px rgba(0,0,0,0.1);
    }
}

/* 可编辑项 */
.editable-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.editable-item:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

.editable-item:active {
    transform: scale(0.98);
}

/* 开关按钮 */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
}
