/* 基礎樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #64748b;
    --secondary-color: #475569;
    --accent-color: #374151;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --card-background-light: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --gradient-subtle: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 24px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* 頭部樣式 */
.header {
    background: var(--gradient-subtle);
    color: var(--text-primary);
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 1.875rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.025em;
}

.header h1::before {
    content: '🖥️';
    font-size: 1.25rem;
    opacity: 0.7;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    background: var(--card-background);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.logout-btn {
    background: var(--text-primary);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 50px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.logout-btn:hover {
    background: var(--primary-color);
    transform: translateY(-1px);
}

/* 內容網格 */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 2rem;
    background: var(--background-color);
}

.content-grid .card:last-child {
    grid-column: 1 / -1;
}

/* 卡片樣式 */
.card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-color);
}

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

.card h2::before {
    content: attr(data-icon);
    font-size: 1rem;
    opacity: 0.7;
}

/* 表格樣式 */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: var(--card-background);
}

.table th,
.table td {
    padding: 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.table th {
    background: var(--card-background-light);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    font-weight: 400;
    color: var(--text-primary);
}

.table tr:hover {
    background: var(--card-background-light);
}

/* 按鈕樣式 */
.refresh-btn {
    background: var(--card-background);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.refresh-btn:hover {
    background: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

/* 日誌樣式 */
.logs {
    background: var(--text-primary);
    color: #f8fafc;
    padding: 1.5rem;
    border-radius: var(--border-radius-sm);
    max-height: 500px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    min-height: 300px;
}

.log-entry {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
    word-wrap: break-word;
    white-space: pre-wrap;
    opacity: 0.9;
}

.log-entry:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin: 0.25rem -0.5rem;
}

/* 狀態標籤 */
.status {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status.idle {
    background: #ecfdf5;
    color: var(--success-color);
    border: 1px solid #a7f3d0;
}

.status.running,
.status.executing {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #93c5fd;
}

.status.error,
.status.failed {
    background: #fef2f2;
    color: var(--error-color);
    border: 1px solid #fecaca;
}

.status.pending {
    background: #fffbeb;
    color: var(--warning-color);
    border: 1px solid #fed7aa;
}

/* 數據可視化增強 */
.metric-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-background-light);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.metric-icon {
    font-size: 1.5rem;
    opacity: 0.7;
}

.metric-content h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

/* 圖表容器 */
.chart-container {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--card-background-light);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    position: relative;
    height: 250px;
}

/* 多任務容器樣式 */
.task-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.task-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    transition: all 0.2s ease;
}

.task-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.task-id {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.task-status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* 資源使用率條 */
.resource-bar {
    margin: 0.5rem 0;
}

.resource-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--warning-color), var(--error-color));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.low { background: var(--success-color); }
.progress-fill.medium { background: var(--warning-color); }
.progress-fill.high { background: var(--error-color); }

/* Docker 狀態指示器 */
.docker-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0;
    padding: 0.5rem;
    background: var(--card-background-light);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.docker-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error-color);
}

.docker-indicator.enabled {
    background: var(--success-color);
}

.docker-indicator.partial {
    background: var(--warning-color);
}

/* 信任分數顯示 */
.trust-score {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.trust-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.75rem;
}

.trust-badge.high { background: #ecfdf5; color: var(--success-color); }
.trust-badge.medium { background: #fffbeb; color: var(--warning-color); }
.trust-badge.low { background: #fef2f2; color: var(--error-color); }

/* 響應式設計 */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .content-grid .card:last-child {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px;
    }
    
    .header {
        padding: 1.5rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-right {
        flex-direction: row;
        gap: 0.75rem;
    }
    
    .content-grid {
        padding: 1.5rem;
        gap: 1rem;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
}