/* ===================================
   全局样式
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --secondary-color: #3b82f6;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ===================================
   头部样式
   =================================== */
.header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 32px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 600;
}

.nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

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

.nav-btn i {
    font-size: 18px;
}

/* ===================================
   主内容区
   =================================== */
.main {
    flex: 1;
    padding: 30px 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================
   数据看板样式
   =================================== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.dashboard-header h2 {
    font-size: 28px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-filter select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    background: white;
    transition: var(--transition);
}

.date-filter select:hover,
.date-filter select:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
}

.stat-info h3 {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.stat-unit {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 图表区域 */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-container {
    position: relative;
}

/* 排行榜 */
.ranking-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.ranking-card h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    transition: var(--transition);
}

.ranking-item:hover {
    background: #e0f2fe;
}

.ranking-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.ranking-number.top-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #854d0e;
}

.ranking-number.top-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    color: #44403c;
}

.ranking-number.top-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #e8a87c 100%);
    color: #fff;
}

.ranking-info {
    flex: 1;
}

.ranking-info h4 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.ranking-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.ranking-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.ranking-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
}

/* ===================================
   表单样式
   =================================== */
.form-card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.form-card h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

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

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 10px;
}

.unit-display {
    padding: 12px 15px;
    background: var(--bg-color);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
}

.emission-preview {
    padding: 15px 20px;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-radius: var(--radius);
    border: 2px solid #10b981;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary:hover {
    background: #4b5563;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
}

/* 碳排放系数参考表 */
.reference-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.reference-card h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.factor-table {
    display: grid;
    gap: 10px;
}

.factor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-color);
    border-radius: 8px;
}

.factor-name {
    font-weight: 500;
    color: var(--text-primary);
}

.factor-value {
    color: var(--primary-color);
    font-weight: 600;
}

/* ===================================
   历史记录样式
   =================================== */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.history-header h2 {
    font-size: 28px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    min-width: 200px;
}

.filter-select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
}

.table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-color);
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-color);
}

.no-data {
    text-align: center;
    padding: 40px !important;
    color: var(--text-secondary);
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    margin-right: 5px;
}

.action-btn.edit {
    background: var(--secondary-color);
    color: white;
}

.action-btn.delete {
    background: var(--danger-color);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.page-btn {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.page-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

/* ===================================
   关于页面样式
   =================================== */
.about-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.about-card h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.about-section {
    margin-bottom: 30px;
}

.about-section h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.about-section p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 10px;
}

.feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.feature-list i {
    color: var(--success-color);
    font-size: 18px;
    margin-top: 2px;
}

.coefficient-info p {
    padding: 10px 15px;
    background: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    margin-bottom: 10px;
    border-radius: 4px;
}

.tips-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.tips-list li {
    padding: 15px;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tech-badge {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* ===================================
   模态框样式
   =================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--danger-color);
}

.modal-content form {
    padding: 25px;
}

/* ===================================
   加载和提示
   =================================== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

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

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

.loading p {
    margin-top: 15px;
    color: var(--text-secondary);
    font-size: 14px;
}

.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 15px 25px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    display: none;
    align-items: center;
    gap: 10px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.toast.active {
    display: flex;
}

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

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

/* ===================================
   页脚样式
   =================================== */
.footer {
    background: var(--text-primary);
    color: white;
    padding: 20px 0;
    text-align: center;
    margin-top: auto;
}

.footer p {
    font-size: 14px;
    opacity: 0.8;
}

/* ===================================
   响应式设计
   =================================== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .nav {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-btn span {
        display: none;
    }

    .nav-btn {
        padding: 10px 15px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .history-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-controls {
        width: 100%;
    }

    .search-input,
    .filter-select {
        flex: 1;
        min-width: 0;
    }

    .table-container {
        overflow-x: scroll;
    }

    .data-table {
        min-width: 600px;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .about-card {
        padding: 20px;
    }

    .tips-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 18px;
    }

    .logo i {
        font-size: 24px;
    }

    .dashboard-header h2,
    .history-header h2,
    .about-card h2 {
        font-size: 22px;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        margin: 0 auto;
    }

    .modal-content {
        width: 95%;
    }

    .toast {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}
