/* 進階智能體介面樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    line-height: 1.5;
}

/* 整體介面容器 */
.advanced-interface {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header 樣式 */
.interface-header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #64748b;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #22c55e;
    animation: pulse 2s infinite;
}

.status-dot.active {
    background-color: #22c55e;
}

.header-controls {
    display: flex;
    gap: 12px;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn.primary {
    background: #3b82f6;
    color: white;
}

.control-btn.primary:hover {
    background: #2563eb;
}

.control-btn.secondary {
    background: #f59e0b;
    color: white;
}

.control-btn.secondary:hover {
    background: #d97706;
}

.control-btn.outline {
    background: transparent;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

.control-btn.outline:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* 主要介面佈局 */
.interface-main {
    flex: 1;
    display: grid;
    grid-template-columns: 300px 1fr 320px;
    gap: 1px;
    background: #e2e8f0;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* 通用面板樣式 */
.left-panel, .center-panel, .right-panel {
    background: white;
    min-height: calc(100vh - 70px);
    overflow-y: auto;
}

.panel-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

/* 左側面板 - AI智能體列表 */
.agent-count {
    font-size: 12px;
    color: #64748b;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 12px;
}

.agent-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8fafc;
    border: 1px solid transparent;
}

.agent-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.agent-item.active {
    background: #eff6ff;
    border-color: #3b82f6;
}

.agent-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.agent-indicator.active {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.agent-indicator.working {
    background: #3b82f6;
    animation: pulse 2s infinite;
}

.agent-indicator.idle {
    background: #94a3b8;
}

.agent-info {
    flex: 1;
}

.agent-name {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 2px;
}

.agent-status {
    font-size: 12px;
    color: #64748b;
}

.agent-actions {
    color: #94a3b8;
    font-size: 14px;
}

/* 中央面板 - 流程時序區 */
.timeline-controls {
    display: flex;
    gap: 8px;
}

.timeline-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-btn.active {
    background: #3b82f6;
    color: white;
}

.workflow-area {
    padding: 20px;
}

.workflow-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.workflow-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 11px; /* 16px * 0.7 = 11.2px */
    transition: all 0.2s ease;
    transform: scale(0.85); /* 整體縮小15%額外優化 */
    margin: -8px; /* 負邊距補償縮放後的空間 */
}

.workflow-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

.workflow-card.active {
    border-color: #3b82f6;
    background: #eff6ff;
}

.card-header {
    margin-bottom: 8px; /* 12px * 0.7 = 8.4px */
}

.card-title {
    font-size: 13px; /* 14px * 0.9 = 12.6px */
    font-weight: 600;
    color: #1e293b;
}

.card-subtitle {
    font-size: 11px; /* 12px * 0.9 = 10.8px */
    color: #64748b;
    margin-top: 1px; /* 2px * 0.7 = 1.4px */
}

.card-content {
    margin-bottom: 11px; /* 16px * 0.7 = 11.2px */
}

.task-badge {
    display: flex;
    align-items: center;
    gap: 6px; /* 8px * 0.7 = 5.6px */
    padding: 6px 8px; /* 8px * 0.7 = 5.6px, 12px * 0.7 = 8.4px */
    border-radius: 6px; /* 8px * 0.7 = 5.6px */
    font-size: 12px; /* 13px * 0.9 = 11.7px */
    font-weight: 500;
}

.task-badge.active {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.task-badge.pending {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.task-count {
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: auto;
}

.card-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar {
    flex: 1;
    height: 3px; /* 4px * 0.7 = 2.8px */
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

.progress-text {
    font-size: 11px; /* 12px * 0.9 = 10.8px */
    font-weight: 500;
    color: #475569;
    min-width: 28px; /* 32px * 0.85 = 27.2px */
    text-align: right;
}

/* 信息顯示區 */
.info-display-area {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.info-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.info-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.analysis-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.analysis-btn:hover {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.analysis-btn:active {
    transform: translateY(0);
}

.analysis-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.clear-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

.info-content {
    max-height: 170px; /* 縮小為85%: 200px * 0.85 = 170px */
    overflow-y: auto;
    padding: 12px 0;
}

.info-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 20px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.info-message:hover {
    background: #f8fafc;
}

.info-message.system {
    border-left-color: #64748b;
}

.info-message.normal {
    border-left-color: #3b82f6;
}

.info-message.warning {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.info-message.error {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.info-message.success {
    border-left-color: #22c55e;
    background: #f0fdf4;
}

.info-time {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    min-width: 40px;
    margin-top: 1px;
}

.info-text {
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
    flex: 1;
}

.info-message.warning .info-text {
    color: #92400e;
}

.info-message.error .info-text {
    color: #dc2626;
}

.info-message.success .info-text {
    color: #166534;
}

/* 信息顯示區滾動條 */
.info-content::-webkit-scrollbar {
    width: 4px;
}

.info-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.info-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.info-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 異常分析模態對話框 */
.analysis-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.analysis-modal.show {
    opacity: 1;
    visibility: visible;
}

.analysis-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.analysis-modal.show .analysis-content {
    transform: scale(1);
}

.analysis-header {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analysis-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.analysis-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.analysis-section {
    margin-bottom: 24px;
}

.analysis-section:last-child {
    margin-bottom: 0;
}

.analysis-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.analysis-item:last-child {
    margin-bottom: 0;
}

.analysis-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.analysis-value {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

.analysis-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.analysis-metric:last-child {
    border-bottom: none;
}

.metric-name {
    font-size: 14px;
    color: #374151;
}

.metric-value {
    font-size: 14px;
    font-weight: 600;
}

.metric-value.good {
    color: #22c55e;
}

.metric-value.warning {
    color: #f59e0b;
}

.metric-value.danger {
    color: #ef4444;
}

.recommendation-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recommendation-list li {
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    color: #166534;
}

.recommendation-list li:last-child {
    margin-bottom: 0;
}

/* 系統摘要視圖 */
.system-summary {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}

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

.summary-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.summary-status {
    font-size: 12px;
    color: #22c55e;
    background: #dcfce7;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.summary-item {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    text-align: center;
}

.summary-label {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.summary-value {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

/* 右側面板 - 數據展示 */
.right-panel .panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    width: 40px;
    height: 40px;
    background: #eff6ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
}

.header-info h2 {
    font-size: 16px;
    font-weight: 600;
}

.header-count {
    font-size: 12px;
    color: #64748b;
}

.stats-grid {
    padding: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.stat-icon {
    width: 36px;
    height: 36px;
    background: #eff6ff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
}

.stat-label {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.metrics-section, .completion-section {
    padding: 20px;
    border-top: 1px solid #f1f5f9;
}

.metrics-section h3, .completion-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
}

.metric-item, .completion-item {
    margin-bottom: 16px;
}

.metric-header, .completion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.metric-name, .completion-name {
    font-size: 13px;
    color: #475569;
}

.metric-percentage, .completion-percentage {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.metric-progress, .completion-progress {
    height: 6px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar.blue .progress-fill {
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.progress-bar.green .progress-fill {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.progress-bar.orange .progress-fill {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.system-info {
    padding: 20px;
    border-top: 1px solid #f1f5f9;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #64748b;
}

.info-dot {
    width: 6px;
    height: 6px;
    background: #3b82f6;
    border-radius: 50%;
}

.floating-add {
    position: absolute;
    bottom: 20px;
    right: 20px;
}

.add-btn {
    width: 48px;
    height: 48px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
}

.add-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* 動畫效果 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .interface-main {
        grid-template-columns: 280px 1fr 300px;
    }
}

@media (max-width: 1024px) {
    .interface-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .left-panel, .right-panel {
        min-height: auto;
    }
    
    .workflow-cards {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .header-controls {
        justify-content: center;
    }
    
    .control-btn {
        flex: 1;
        justify-content: center;
    }
    
    .workflow-cards {
        grid-template-columns: 1fr;
    }
    
    .panel-header {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .timeline-controls {
        justify-content: center;
    }
}

/* 狀態動畫 */
.agent-item.working .agent-indicator {
    animation: working-pulse 1.5s infinite;
}

.workflow-card.working {
    animation: card-working 2s infinite;
}

@keyframes working-pulse {
    0%, 100% {
        transform: scale(1);
        background-color: #3b82f6;
    }
    50% {
        transform: scale(1.2);
        background-color: #1d4ed8;
    }
}

@keyframes card-working {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    }
    50% {
        box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
    }
}

/* 通知系統 */
.notification-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.notification {
    background: white;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 320px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left-color: #22c55e;
}

.notification.warning {
    border-left-color: #f59e0b;
}

.notification.error {
    border-left-color: #ef4444;
}