/* ==========================================================================
   #11483 影片編輯總覽：一排三格（當前排程＋段數／總長、背景音樂、全段旁白）
   背景音樂 / 全段旁白格子可點，錨在格子下方跳出浮動視窗。
   全部以 #schedule-view 限定範圍（workflow-management.css 較晚載入，也有 .schedule-overview 規則）。
   ========================================================================== */

#schedule-view .schedule-overview.schedule-overview--audio {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr) minmax(0, 1.25fr);
    gap: 14px;
    align-items: stretch;
}

#schedule-view .schedule-overview--audio .overview-item {
    min-height: 78px;
    padding: 24px 12px 10px;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

/* 當前排程格：名稱＋一行小字（段數、總長） */
#schedule-view .overview-item--current .schedule-display {
    width: 100%;
    padding: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#schedule-view .overview-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px 10px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-light, #6c757d);
    font-variant-numeric: tabular-nums;
}

#schedule-view .overview-stats b {
    font-weight: 600;
    color: var(--secondary-color, #00926b);
}

/* 音訊格：整格是按鈕 */
#schedule-view .overview-audio-anchor {
    position: relative;
    min-width: 0;
    display: flex;
}

#schedule-view button.overview-audio {
    width: 100%;
    font: inherit;
    color: inherit;
    text-align: left;
    align-items: stretch;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

#schedule-view button.overview-audio:hover {
    border-color: var(--primary-color, #59b89f);
    background: #f1f9f6;
}

#schedule-view button.overview-audio:focus-visible {
    outline: 3px solid rgba(89, 184, 159, 0.45);
    outline-offset: 2px;
}

#schedule-view button.overview-audio[aria-expanded="true"] {
    border-color: var(--secondary-color, #00926b);
    background: #f1f9f6;
    box-shadow: 0 0 0 3px rgba(89, 184, 159, 0.18);
}

#schedule-view .overview-audio .schedule-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

#schedule-view .overview-audio-chev {
    position: absolute;
    top: 6px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: #8a959b;
}

#schedule-view .overview-audio:hover .overview-audio-chev,
#schedule-view .overview-audio[aria-expanded="true"] .overview-audio-chev {
    color: var(--secondary-color, #00926b);
}

#schedule-view .overview-audio-dirty:not([hidden]) {
    position: absolute;
    top: 10px;
    right: 58px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f0a12b;
}

#schedule-view .overview-audio-name {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary-color, #00926b);
}

#schedule-view .overview-audio-name > i {
    flex: none;
    color: var(--primary-color, #59b89f);
}

#schedule-view .overview-audio-name > span,
#schedule-view .overview-audio-name .bgm-display,
#schedule-view .overview-audio-name .bgm-display.has-bgm {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: normal;
    color: inherit;
    font-weight: inherit;
    padding: 0;
    background: none;
}

#schedule-view .overview-audio.is-empty .overview-audio-name {
    color: #8a959b;
    font-weight: 500;
}

#schedule-view .overview-audio.is-empty .overview-audio-name > i {
    color: #8a959b;
}

#schedule-view .overview-audio-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    margin-top: 4px;
    min-height: 0;
    font-size: 11.5px;
    color: #6c757d;
}

#schedule-view .overview-audio-meta:empty {
    display: none;
}

#schedule-view .overview-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 7px;
    border: 1px solid #e9ecef;
    border-radius: 999px;
    background: #fff;
    line-height: 18px;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- 浮動視窗 */

.schedule-audio-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    width: min(392px, calc(100vw - 32px));
    max-height: min(480px, 70vh);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(20, 40, 35, 0.18), 0 2px 6px rgba(20, 40, 35, 0.08);
    color: #2c3e50;
    font-size: 14px;
    text-align: left;
    transform-origin: top right;
    animation: schedule-audio-pop-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes schedule-audio-pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .schedule-audio-pop { animation: none; }
}

.schedule-audio-pop-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 8px;
}

.schedule-audio-pop-head h4 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #2c3e50;
}

.schedule-audio-pop-head h4 i {
    color: var(--primary-color, #59b89f);
}

.schedule-audio-pop-close {
    margin-left: auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
}

.schedule-audio-pop-close:hover {
    background: #f8f9fa;
    color: #2c3e50;
}

.schedule-audio-search-wrap {
    position: relative;
    padding: 0 14px 8px;
}

.schedule-audio-search-wrap > i {
    position: absolute;
    left: 25px;
    top: 11px;
    font-size: 13px;
    color: #8a959b;
    pointer-events: none;
}

.schedule-audio-pop input.schedule-audio-search {
    width: 100%;
    height: 34px;
    margin: 0;
    padding: 0 10px 0 32px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    color: #2c3e50;
    font: inherit;
    font-size: 13.5px;
}

.schedule-audio-pop input.schedule-audio-search:focus {
    outline: none;
    border-color: var(--primary-color, #59b89f);
    box-shadow: 0 0 0 3px rgba(89, 184, 159, 0.18);
}

.schedule-audio-list {
    overflow-y: auto;
    padding: 0 8px 6px;
    display: grid;
    align-content: start;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: #cfd8d5 transparent;
}

.schedule-audio-pop--narration .schedule-audio-list {
    max-height: 170px;
}

.schedule-audio-opt {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto 18px;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.schedule-audio-opt:hover,
.schedule-audio-opt:focus-visible {
    background: #f8f9fa;
    outline: none;
}

.schedule-audio-opt[aria-selected="true"] {
    background: #f1f9f6;
    border-color: rgba(89, 184, 159, 0.4);
}

.schedule-audio-opt-ic {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 13px;
}

.schedule-audio-opt[aria-selected="true"] .schedule-audio-opt-ic {
    background: #fff;
    color: var(--secondary-color, #00926b);
}

.schedule-audio-opt-info {
    display: grid;
    min-width: 0;
    line-height: 1.35;
}

.schedule-audio-opt-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13.5px;
    font-weight: 500;
}

.schedule-audio-opt.is-none .schedule-audio-opt-name {
    color: #6c757d;
}

.schedule-audio-opt-sub {
    font-size: 11.5px;
    color: #8a959b;
    font-variant-numeric: tabular-nums;
}

.schedule-audio-play {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    background: #fff;
    color: var(--secondary-color, #00926b);
    font-size: 10px;
    cursor: pointer;
}

.schedule-audio-play:hover {
    border-color: var(--primary-color, #59b89f);
}

.schedule-audio-play.is-playing {
    background: var(--secondary-color, #00926b);
    border-color: var(--secondary-color, #00926b);
    color: #fff;
}

.schedule-audio-opt-check {
    color: var(--secondary-color, #00926b);
    visibility: hidden;
}

.schedule-audio-opt[aria-selected="true"] .schedule-audio-opt-check {
    visibility: visible;
}

.schedule-audio-empty {
    margin: 8px;
    font-size: 12.5px;
    color: #6c757d;
}

/* #11483：音訊清單載入失敗時的重試入口（原本永遠停在「載入中…」） */
.schedule-audio-retry {
    margin-left: 6px;
    padding: 2px 10px;
    font-size: 12.5px;
    color: var(--primary-color, #0d6efd);
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 6px;
    cursor: pointer;
}

.schedule-audio-retry:hover {
    background: rgba(13, 110, 253, 0.08);
}

.schedule-audio-pop-foot {
    display: grid;
    gap: 8px;
    padding: 10px 14px 12px;
    border-top: 1px solid #e9ecef;
}

.schedule-audio-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
}

.schedule-audio-pop .schedule-audio-row label.bgm-loop-toggle {
    margin: 0 !important;
}

.schedule-audio-lbl {
    min-width: 60px;
    font-size: 13px;
    font-weight: 500;
}

.schedule-audio-unit {
    font-size: 12.5px;
    color: #6c757d;
}

.schedule-audio-step {
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

.schedule-audio-step button {
    width: 30px;
    height: 30px;
    border: 0;
    background: #f8f9fa;
    color: #2c3e50;
    cursor: pointer;
}

.schedule-audio-step button:hover:not(:disabled) {
    background: #e9ecef;
}

.schedule-audio-step button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.schedule-audio-pop input.schedule-narration-delay {
    width: 56px;
    height: 30px;
    margin: 0;
    padding: 0 4px;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #2c3e50;
    text-align: center;
    font: 500 13.5px/1 var(--font-family, inherit);
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}

.schedule-audio-pop input.schedule-narration-delay::-webkit-inner-spin-button,
.schedule-audio-pop input.schedule-narration-delay::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.schedule-audio-pop input.schedule-narration-delay:focus {
    outline: none;
    background: #f1f9f6;
}

/* 全段旁白時間軸 */
.schedule-audio-tl {
    display: grid;
    gap: 5px;
}

.schedule-audio-tl-segs {
    display: flex;
    height: 22px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.schedule-audio-tl-segs > span {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    overflow: hidden;
    border-right: 1px solid #e9ecef;
    background: #fff;
    color: #6c757d;
    font-size: 10.5px;
    white-space: nowrap;
}

.schedule-audio-tl-segs > span:last-child {
    border-right: 0;
}

.schedule-audio-tl-segs > span.has-narration {
    background: repeating-linear-gradient(135deg, #f3effb 0 4px, #fff 4px 8px);
    color: #6b4fb0;
}

.schedule-audio-tl-track {
    position: relative;
    height: 12px;
    border-radius: 6px;
    background: #f8f9fa;
}

.schedule-audio-tl-bar {
    position: absolute;
    top: 0;
    height: 12px;
    border-radius: 6px;
    background: var(--primary-color, #59b89f);
    transition: left 0.2s ease, width 0.2s ease;
}

.schedule-audio-tl-bar.is-cut {
    border-radius: 6px 0 0 6px;
    background: linear-gradient(90deg, var(--primary-color, #59b89f) 88%, rgba(192, 57, 43, 0.6));
}

.schedule-audio-tl-bar.is-unknown {
    background: repeating-linear-gradient(90deg, var(--primary-color, #59b89f) 0 10px, rgba(89, 184, 159, 0.45) 10px 16px);
}

.schedule-audio-tl-scale {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
    color: #8a959b;
    font-variant-numeric: tabular-nums;
}

.schedule-audio-note {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #6c757d;
}

.schedule-audio-note.is-warn {
    color: #b02a37;
}

.schedule-audio-help {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: #6c757d;
}

.schedule-audio-help > i {
    flex: none;
    color: #8a959b;
}

.schedule-audio-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--secondary-color, #00926b);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.schedule-audio-seglist {
    margin: 0;
    padding-left: 1.2em;
    max-height: 96px;
    overflow-y: auto;
    font-size: 12px;
    color: #495057;
}

/* 儲存 / 覆蓋排程對話框的摘要（背景音樂、全段旁白在總覽選，這裡只顯示） */
.schedule-save-audio-summary {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f8f9fa;
    font-size: 13px;
    color: #6c757d;
}

.schedule-save-audio-summary b {
    font-weight: 600;
    color: #2c3e50;
}

.schedule-save-audio-summary small {
    font-size: 12px;
    color: #8a959b;
}

.schedule-save-confirm {
    margin: 0;
    font-size: 14px;
}

/* ---------------------------------------------------------------- 窄螢幕 */

@media (max-width: 1200px) {
    #schedule-view .schedule-overview.schedule-overview--audio {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #schedule-view .schedule-overview--audio .overview-item--current {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    #schedule-view .schedule-overview.schedule-overview--audio {
        grid-template-columns: minmax(0, 1fr);
    }

    /* 浮動視窗改成從下方滑上來的抽屜 */
    .schedule-audio-pop {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-height: 78vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -10px 30px rgba(20, 40, 35, 0.2);
        transform-origin: bottom center;
    }
}
