/* Tooltip 樣式 */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    margin-left: 5px;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 250px;
    background-color: #2c3e50;
    color: #fff !important;
    text-align: left;
    border-radius: 6px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    white-space: normal;
    word-wrap: break-word;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
    pointer-events: none;
}

.tooltip:hover .tooltiptext,
.tooltip:focus .tooltiptext {
    visibility: visible;
    opacity: 1;
    transition-delay: 0.2s;
}

.info-icon {
    font-size: 0.9em;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tooltip:hover .info-icon {
    opacity: 1;
}

/* 全局樣式 */
:root {
    --primary-color: #4a6cf7;
    --primary-hover: #3a5ce4;
    --text-color: #333;
    --text-light: #666;
    --border-color: #e0e0e0;
    --bg-light: #f8f9fa;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* 數據集切換器 - 網頁標籤樣式 */
.dataset-tabs {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0.5rem 0.5rem 0;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    position: relative;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dataset-tab {
    padding: 0.6rem 1.5rem;
    margin: 0 0.25rem;
    border: 1px solid #dee2e6;
    border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    background-color: #f1f3f5;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    top: 0;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 -2px 3px -2px rgba(0,0,0,0.1);
}

.dataset-tab:hover {
    background-color: #e9ecef;
    border-color: #dee2e6 #dee2e6 #f8f9fa;
}

.dataset-tab.active {
    background-color: white;
    border-color: #dee2e6;
    border-bottom: 2px solid white;
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 0 0 1px #dee2e6, 0 2px 0 0 white;
    transform: translateY(1px);
    z-index: 1;
}

.dataset-tab-remove {
    margin-left: 0.5rem;
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition);
    font-size: 1rem;
    line-height: 1;
    padding: 0 0 0 0.5rem;
}

.dataset-tab-remove:hover {
    opacity: 1;
    color: #dc3545;
}

.dataset-tab-add {
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    margin-left: 0.5rem;
    font-size: 0.9rem;
}

.dataset-tab-add:hover {
    background: #e9ecef;
    color: var(--primary-color);
}

/* 添加底部邊框以匹配標籤樣式 */
/* 移除多餘的邊框設置，因為現在由包裝器處理 */

/* 加載動畫 */
.loading-overlay {
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
}

.loading-overlay .loading-spinner {
    color: var(--primary-color);
}

/* 主體佈局 */
.data-visualizer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    color: var(--text-color);
}

.tool-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.tool-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.tool-header p {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 700px;
    margin: 0 auto;
}

.container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* 輸入區域 */
.input-section {
    display: grid;
    grid-template-columns: 0.85fr 0.85fr;
    gap: 2rem;
    justify-content: center;
}

.upload-box {
    padding: 20px;
    margin-top: 1.5rem;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

.manual-input-wrapper {
    margin-top: 1.5rem;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

.manual-input-wrapper:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* 手動輸入區域 */
.manual-input {
    padding: 1.5rem;
}

.upload-box h2, .manual-input h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 拖放區域 */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 1rem;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-color);
    background-color: rgba(74, 108, 247, 0.05);
}

.drop-zone i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: block;
}

.file-info {
    font-size: 0.9rem;
    color: var(--text-light);
    text-align: center;
}

.file-info-container {
    margin-top: 10px;
    height: 24px;
    position: relative;
    text-align: center;
    overflow: hidden;
}

/* 共用樣式 */
.file-info-message,
.file-info-hint {
    position: absolute;
    left: 0;
    right: 0;
    font-size: 0.9rem;
    color: #666666;
    opacity: 0.6;
}

@keyframes fadeInOutMessage {
    0%, 40% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

@keyframes fadeInOutHint {
    0%, 50% {
        opacity: 0;
    }
    60%, 90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}



/* 設定動畫效果 */
.file-info-message {
    animation: fadeInOutMessage 4s infinite;
}

.file-info-hint {
    animation: fadeInOutHint 4s infinite;
}

/* 檔案已上傳狀態：停用動畫，只顯示 message */
.file-uploaded .file-info-message {
    animation: none;
    opacity: 1;
    display: block;
}

.file-uploaded .file-info-hint {
    animation: none;
    opacity: 0;
    display: none;
}

/* 手動輸入區域 */
.input-grid {
    margin-bottom: 1rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
    padding-bottom: 5px;
    border-bottom: 0.6px solid var(--border-color);
}

.input-x, .input-y {
    width: 5rem;
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: var(--transition);
}

.input-x:focus, .input-y:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: var(--transition);
    padding: 0.25rem;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    opacity: 1;
    background-color: rgba(220, 53, 69, 0.1);
}

/* 按鈕組 */
.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    margin-bottom: 1rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    background-color: #f0f0f0;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    background-color: #e0e0e0;
}

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

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

/* 標籤頁 */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

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

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

/* 圖表控制項 */
.chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

#chartType {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    min-width: 150px;
}

.chart-options {
    display: flex;
    gap: 1.5rem;
}

.chart-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 0;
    margin-top: 1.5rem;
    overflow: hidden;
    transition: height 0.3s ease;
}

.chart-container.active {
    height: 400px;
}

/* 數據表格 */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
}

.table-container {
    width: 100%;
}

.data-table-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    padding: 0.75rem 1rem;
    background-color: var(--bg-light);
    border-radius: 4px 4px 0 0;
    border-bottom: 1px solid var(--border-color);
}

#dataTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#dataTable th, #dataTable td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

#dataTable th {
    background-color: var(--bg-light);
    font-weight: 600;
    color: var(--text-light);
}

#dataTable tbody tr:hover {
    background-color: rgba(74, 108, 247, 0.05);
}

#dataTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#dataTable th, #dataTable td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

#dataTable th {
    background-color: var(--bg-light);
    font-weight: 600;
    color: var(--text-light);
}

#dataTable tbody tr:hover {
    background-color: rgba(74, 108, 247, 0.05);
}

/* 統計卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 45%));
    gap: 1.5rem;
    justify-content: center;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
}

.stat-card h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.stat-item span:last-child {
    font-weight: 600;
    color: var(--text-color);
}

.correlation-container {
    grid-column: 1 / -1;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.correlation-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 25px;
    margin: 0 auto;
    max-width: 600px;
    text-align: center;
}

.correlation-coefficient {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.correlation-strength {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    margin-right: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.correlation-strength.strong {
    background-color: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
    border-left: 4px solid #2e7d32;
}

.correlation-strength.medium {
    background-color: rgba(255, 167, 38, 0.1);
    color: #ff8f00;
    border-left: 4px solid #ff8f00;
}

.correlation-strength.weak {
    background-color: rgba(244, 67, 54, 0.1);
    color: #c62828;
    border-left: 4px solid #c62828;
}

.correlation-direction {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: rgba(66, 165, 245, 0.1);
    color: #1976d2;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    border-left: 4px solid #1976d2;
}

.correlation-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.75rem;
    color: #2c3e50;
    color: var(--text-color);
    margin: 0.5rem 0;
}

.correlation-hint {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 1.5rem;
    text-align: center;
    line-height: 1.6;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.correlation-hint p {
    margin: 0.5rem 0;
}

@media (max-width: 768px) {
    .correlation-card {
        padding: 20px 15px;
    }
    
    .correlation-coefficient {
        font-size: 2rem;
    }
}

/* 響應式設計 */
@media (max-width: 992px) {
    .input-section {
        grid-template-columns: 0.75fr;
    }
}

@media (max-width: 768px) {
    .tool-header h1 {
        font-size: 2rem;
    }
    
    .tool-header p {
        font-size: 1rem;
    }
    
    .chart-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .chart-options {
        width: 100%;
        justify-content: space-between;
    }
    
    .stats-grid {
        grid-template-columns: 0.75fr;
    }

    .input-row {
        display: flex;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
        align-items: center;
        flex-wrap: wrap;
    }
}

/* 加載動畫 */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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