/* Filename: style.css */
/* 檔案職責: 網站的所有 CSS 樣式定義。 */

/* CSS 變數 */
:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #f39c12; /* 預覽按鈕顏色 */
    --background-light: #f8f9fa;
    --spacing-unit: 1rem;
    --tab-height: 50px; 
    --bottom-bar-height: 70px;
}

body {
    font-family: '微軟正黑體', 'Arial', sans-serif;
    margin: 0;
    padding-top: var(--tab-height);
    padding-bottom: var(--bottom-bar-height);
    background-color: var(--background-light);
}

/* --- 頂部頁籤區 (Fixed Top) --- */
.tabs-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    height: var(--tab-height);
}
.tab-button {
    flex-grow: 1;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: #555;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab-button.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    font-weight: bold;
}

/* --- 內容區域 --- */
.content {
    padding: var(--spacing-unit);
    box-sizing: border-box;
    max-width: 600px;
    margin: auto;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* 預覽頁籤專用樣式 */
#preview-content {
    display: flex;
    justify-content: center;
    align-items: center;
    /* 調整高度以容納進度條 */
    height: calc(100vh - var(--tab-height) - var(--bottom-bar-height) - 40px);
    flex-direction: column;
    background-color: #333;
    color: white;
    margin-top: var(--spacing-unit);
    border-radius: 8px;
    padding: 20px;
    box-sizing: border-box;
}
.placeholder-video {
    width: 100%;
    max-width: 480px;
    aspect-ratio: 16 / 9;
    background: #555;
    display: flex;
    flex-direction: column; /* 允許內容垂直排列 */
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    overflow: hidden; /* 確保圖片不溢出 */
    position: relative;
}
/* 確保動畫預覽圖片佔滿容器 */
#animationPreviewImage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #333; /* 圖片背景 */
}
/* 佔位文字 */
#previewPlaceholder {
    z-index: 10;
}

/* --- 編輯區塊樣式 --- */
.section {
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    padding: var(--spacing-unit);
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

/* 圖片列表佈局 (Grid) */
#imageList {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}
.image-item {
    background: #fff;
    padding: 8px;
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative; /* 為了放置刪除按鈕 */
}
.image-item img {
    width: 100%;
    aspect-ratio: 1 / 1; 
    object-fit: cover; 
    border-radius: 4px;
    margin-bottom: 5px;
}

/* ⚡️ 新增：排序控制區樣式 */
.sort-control {
    display: flex;
    justify-content: space-around;
    margin-bottom: 8px;
    padding-top: 5px;
    border-top: 1px solid #eee;
}
.sort-btn {
    background: #f1f1f1;
    border: 1px solid #ccc;
    color: #333;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background-color 0.2s;
}
.sort-btn:hover:not([disabled]) {
    background: #ddd;
}
.sort-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}


/* 時長控制 (微按鈕實現) */
.duration-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
    font-size: 0.9rem;
    gap: 5px; /* 讓元素之間有間隔 */
}
.duration-input {
    width: 40px; /* 調整：讓輸入框更窄 */
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    min-height: 30px; 
}
/* 微調按鈕樣式 */
.duration-btn {
    background: #e9ecef;
    border: 1px solid #ccc;
    color: #333;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    transition: background-color 0.2s;
}
.duration-btn:hover {
    background: #d4d8db;
}


/* 刪除按鈕樣式 */
.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-size: 0.8rem;
    cursor: pointer;
    position: absolute;
    top: 5px;
    right: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 10;
}
/* 音訊刪除按鈕的樣式修正 */
#audioStatus p {
    display: flex;
    align-items: center;
    margin: 0;
}
#audioStatusContainer .remove-btn {
    position: static;
    margin-left: 10px;
    vertical-align: middle;
    background: #aaa; /* 音訊刪除顏色可以柔和一點 */
}

/* --- 底部浮動操作區 (Fixed Bottom) --- */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 10px var(--spacing-unit);
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--bottom-bar-height);
    box-sizing: border-box;
}
.render-button {
    width: 60%;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}
.render-button.download {
    background-color: var(--success-color);
}

/* 狀態文字的獨立容器 */
#renderStatusContainer {
    position: fixed;
    bottom: var(--bottom-bar-height);
    left: 0;
    width: 100%;
    min-height: 20px;
    padding: 5px var(--spacing-unit);
    background: var(--background-light);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
    z-index: 999;
}
#renderStatus {
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    margin: 0;
}

/* 桌面版優化 */
@media (min-width: 600px) {
    .content {
        padding: calc(var(--spacing-unit) * 2);
    }
    #imageList {
        grid-template-columns: repeat(3, 1fr);
    }
}
