* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 40px 20px;
    background: var(--card-bg);
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 15px;
}

/* 頁面導航 */
.page-nav {
    margin-top: 20px;
}

.nav-link {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.nav-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 上傳區域 */
.upload-area {
    margin-bottom: 30px;
}

.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload:hover {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    color: var(--text-secondary);
}

.upload-label svg {
    color: var(--primary-color);
}

.upload-label span {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.upload-label small {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    margin-top: 15px;
}

.file-info span {
    color: var(--success-color);
    font-weight: 500;
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--danger-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.3s;
}

.btn-clear:hover {
    background: #fee2e2;
}

/* 電鍍時間輸入 */
.plating-time-input {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.plating-time-input label {
    font-size: 1rem;
    color: var(--text-primary);
}

.plating-time-input input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

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

/* 按鈕 */
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans TC', sans-serif;
}

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

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-primary:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

/* 統計卡片 */
.stats-section {
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card.highlight {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card h3 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 10px;
    opacity: 0.9;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 10px 0;
}

.stat-unit {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* 熱力圖 */
.heatmap-section {
    margin-bottom: 30px;
}

.heatmap-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
}

.heatmap-container .card {
    min-height: 450px;
}

#thicknessHeatmap,
#auHeatmap {
    width: 100%;
    height: 400px;
    min-height: 400px;
}

/* 資訊提示框 */
.info-box {
    background: #e3f2fd;
    border-left: 4px solid var(--primary-color);
    padding: 15px 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    line-height: 1.6;
}

/* 第一層數據狀態 */
.first-layer-status,
.first-layer-info,
.first-layer-error {
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.status-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.loading-spinner {
    font-size: 1.5rem;
    animation: spin 2s linear infinite;
}

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

.first-layer-info {
    background: #f0f9ff;
    border: 2px solid #0ea5e9;
}

.data-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.preview-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.preview-item strong {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.preview-item span {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.error-box {
    background: #fef2f2;
    border: 2px solid #ef4444;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.error-box strong {
    display: block;
    color: #dc2626;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.error-box p {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.error-box .btn-primary {
    display: inline-block;
    text-decoration: none;
}

/* 數據分組 */
.data-group {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 2px dashed var(--border-color);
}

.data-group:last-of-type {
    border-bottom: none;
}

.data-group h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 金色卡片 */
.gold-card {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
}

.gold-card.highlight {
    background: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
}

/* 圖表描述 */
.chart-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-align: center;
}

/* 對比表 */
.table-responsive {
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.comparison-table thead {
    background: var(--primary-color);
    color: white;
}

.comparison-table th,
.comparison-table td {
    padding: 12px 16px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.comparison-table tbody tr:hover {
    background: #f8fafc;
}

.comparison-table .highlight-col {
    background: #fff3cd;
    font-weight: 600;
    color: #856404;
}

.comparison-table thead .highlight-col {
    background: #ffc107;
    color: #000;
}

/* 匯出區域 */
.export-section-container {
    margin-bottom: 30px;
}

.export-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 0.9rem;
    margin-top: 40px;
}

/* 響應式設計 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .card {
        padding: 20px;
    }

    .heatmap-container {
        grid-template-columns: 1fr;
    }

    .plating-time-input {
        flex-direction: column;
        align-items: stretch;
    }

    .plating-time-input input {
        min-width: 100%;
    }

    .stat-value {
        font-size: 2rem;
    }
}

@media print {
    body {
        background: white;
    }

    .input-section,
    .export-section-container,
    footer {
        display: none;
    }

    .card {
        box-shadow: none;
        page-break-inside: avoid;
    }
}
