/* Web-Text_To_Speech_Pro 自訂樣式 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
}

body {
    background-color: #f8f9fa;
    font-family: 'Microsoft JhengHei', 'PingFang TC', 'Heiti TC', 'Noto Sans CJK TC', sans-serif;
}

/* 標題樣式 */
h1 {
    color: var(--primary-color);
    font-weight: 600;
}

/* 卡片樣式增強 */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), #0b5ed7);
    color: white;
    border-radius: 12px 12px 0 0 !important;
    border: none;
}

.card-header h5 {
    margin: 0;
    font-weight: 500;
}

/* 按鈕樣式增強 */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-lg {
    padding: 12px 30px;
    font-size: 1.1rem;
}

/* 表單控制項樣式 */
.form-control {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* 文字區域樣式 */
#textInput {
    resize: vertical;
    min-height: 200px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
}

/* 字數統計樣式 */
.form-text {
    text-align: right;
    font-weight: 500;
    color: var(--secondary-color);
}

/* 音訊片段樣式 */
.audio-segment {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.audio-segment:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.audio-segment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.audio-segment-title {
    font-weight: 600;
    color: var(--dark-color);
    margin: 0;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-progress {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.audio-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #0b5ed7);
    border-radius: 4px;
    transition: width 0.1s ease; /* 讓跳轉更即時 */
    pointer-events: none; /* 確保點擊事件能穿透到 wrapper */
}

/* 新增：進度條容器，用於擴大點擊/拖拉區域 */
.audio-progress-wrapper {
    position: relative;
    padding: 8px 0; /* 增加垂直方向的觸控區域 */
    cursor: pointer;
}

/* 新增：可拖拉的圓點按鈕 */
.progress-handle {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background-color: white;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none; /* 讓 handle 本身不攔截事件 */
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* 當滑鼠懸停在進度條上時，顯示圓點 */
.audio-progress-wrapper:hover .progress-handle {
    opacity: 1;
}

.audio-time {
    font-size: 0.9rem;
    color: var(--secondary-color);
    font-weight: 500;
}

/* 播放按鈕樣式 */
.play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.play-btn:hover {
    background: #0b5ed7;
    transform: scale(1.1);
}

.play-btn.playing {
    background: var(--danger-color);
}

/* 音量控制樣式 */
.volume-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.volume-slider {
    width: 80px;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* 載入動畫 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 狀態指示器 */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-indicator.connected {
    color: var(--success-color);
}

.status-indicator.disconnected {
    color: var(--danger-color);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container-fluid {
        padding: 10px;
    }
    
    .card {
        margin-bottom: 15px;
    }
    
    .btn-lg {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .audio-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .volume-control {
        justify-content: center;
    }
}

/* 自訂滾動條 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0b5ed7;
}

/* 動畫效果 */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}


/* --- 全新的批次輸入 UI 樣式 --- */

.text-input-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.status-indicator-batch {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    transition: all 0.3s ease;
}

.status-indicator-batch.pending {
    background-color: #6c757d; /* Secondary */
}

.status-indicator-batch.processing .loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(13, 110, 253, 0.2); /* 淡藍色軌道 */
    border-top-color: #0d6efd; /* 主題藍色 */
}

.status-indicator-batch.success {
    background-color: #198754; /* Success */
}

.status-indicator-batch.error {
    background-color: #dc3545; /* Danger */
}

.text-input-row textarea {
    flex-grow: 1;
    min-height: 80px;
    resize: vertical;
}

.char-count-batch {
    font-size: 0.8rem;
    color: #6c757d;
    text-align: right;
    margin-top: 2px;
}

.remove-row-btn {
    flex-shrink: 0;
    margin-top: 5px;
}
