/* ==========================================================================
   Scheduled Video (預約影片發布與管理) - Phase B
   支援桌機與手機 (375px) RWD、深淺色系自適應、按鈕觸控 >= 44px
   ========================================================================== */

/* 1. 上傳 Modal 內之「發布方式」區塊 */
.lx-schedule-box {
    margin: 15px 0;
    background: var(--lx-raised, #242038);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 16px;
    box-sizing: border-box;
}

.lx-schedule-box .lx-schedule-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--lx-text, #ffffff);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lx-schedule-radios {
    display: flex;
    gap: 20px;
    margin-bottom: 6px;
}

.lx-schedule-radio-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--lx-text, #ffffff);
    user-select: none;
    min-height: 44px; /* 手機友善點擊高度 */
}

.lx-schedule-radio-label input[type="radio"] {
    margin-right: 8px;
    accent-color: var(--lx-accent, #df8285);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.lx-schedule-time-picker {
    margin-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
    padding-top: 12px;
    animation: lxFadeIn 0.25s ease-in-out;
}

@keyframes lxFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.lx-schedule-input-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--lx-text, #ffffff);
    display: block;
    margin-bottom: 6px;
}

.lx-schedule-datetime {
    width: 100%;
    padding: 10px 14px;
    background: var(--lx-surface, #181524);
    border: 1px solid var(--lx-accent, #df8285);
    border-radius: 8px;
    color: var(--lx-text, #ffffff);
    font-size: 15px;
    box-sizing: border-box;
    min-height: 44px;
    color-scheme: dark;
}

.lx-schedule-datetime:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(223, 130, 133, 0.35);
}

.lx-schedule-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 8px;
    line-height: 1.5;
}

.lx-schedule-hint strong {
    color: var(--lx-accent, #df8285);
}

.lx-schedule-notice {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.35);
    color: #ffc107;
}

.lx-schedule-radio-label.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.lx-schedule-radio-label.is-disabled input {
    cursor: not-allowed;
}

/* 上傳進度條 */
.lx-schedule-progress {
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99rem;
    height: 8px;
    overflow: hidden;
}

.lx-schedule-progress-bar {
    background: var(--lx-accent, #df8285);
    height: 100%;
    width: 0%;
    transition: width 0.2s ease;
}

/* 2. 發布者工作台「預約發布管理」面板樣式 */
.ap-scheduled-panel {
    animation: lxFadeIn 0.2s ease-in-out;
}

.ap-scheduled-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.ap-scheduled-filter-bar label {
    font-size: 13px;
    color: var(--lx-text, #ffffff);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ap-scheduled-filter-bar select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--lx-surface, #181524);
    color: var(--lx-text, #ffffff);
    min-height: 40px;
}

/* 6 種狀態徽章 */
.ap-sch-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 99rem;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.ap-sch-badge.processing {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.35);
}

.ap-sch-badge.scheduled {
    background: rgba(13, 110, 253, 0.15);
    color: #38b6ff;
    border: 1px solid rgba(13, 110, 253, 0.35);
}

.ap-sch-badge.publishing {
    background: rgba(153, 102, 255, 0.18);
    color: #c084fc;
    border: 1px solid rgba(153, 102, 255, 0.4);
    animation: apPulse 1.8s infinite ease-in-out;
}

@keyframes apPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.ap-sch-badge.published {
    background: rgba(25, 135, 84, 0.15);
    color: #20c997;
    border: 1px solid rgba(25, 135, 84, 0.35);
}

.ap-sch-badge.failed {
    background: rgba(220, 53, 69, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(220, 53, 69, 0.35);
}

.ap-sch-badge.cancelled {
    background: rgba(108, 117, 125, 0.15);
    color: #adb5bd;
    border: 1px solid rgba(108, 117, 125, 0.35);
}

/* 列表表格與卡片排版 */
.ap-sch-table {
    width: 100%;
    border-collapse: collapse;
}

.ap-sch-table th,
.ap-sch-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    vertical-align: middle;
}

.ap-sch-table th {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.15);
}

/* 長標題單行 ellipsis 截斷 */
.ap-sch-content-cell {
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
    cursor: pointer;
}

.ap-sch-content-cell:hover {
    text-decoration: underline;
}

/* 私有縮圖 */
.ap-sch-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #000;
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 操作按鈕組 */
.ap-sch-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ap-sch-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: var(--lx-surface, #181524);
    color: var(--lx-text, #ffffff);
    font-size: 13px;
    cursor: pointer;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.ap-sch-btn:hover:not(:disabled) {
    background: var(--lx-accent, #df8285);
    color: #fff;
    border-color: var(--lx-accent, #df8285);
}

.ap-sch-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ap-sch-btn.danger {
    color: #ff6b6b;
    border-color: rgba(220, 53, 69, 0.4);
}

.ap-sch-btn.danger:hover:not(:disabled) {
    background: #dc3545;
    color: #fff;
}

/* 失敗錯誤提示 */
.ap-sch-error-note {
    font-size: 12px;
    color: #ff6b6b;
    margin-top: 4px;
    display: block;
}

/* 3. 模態視窗 (編輯與預覽 Dialog) */
.ap-sch-dialog {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--lx-surface, #1c182c);
    color: var(--lx-text, #ffffff);
    border-radius: 16px;
    padding: 24px;
    width: min(540px, calc(100vw - 32px));
    max-width: 540px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.ap-sch-dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
}

.ap-sch-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.ap-sch-dialog-header h3 {
    margin: 0;
    font-size: 18px;
}

.ap-sch-dialog-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.ap-sch-dialog-notice {
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.4);
    color: #ffd24d;
}

.ap-sch-dialog-notice.error {
    background: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.4);
    color: #ff8585;
}

.ap-sch-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* 4. 手機 375px RWD 響應式適配 */
@media (max-width: 576px) {
    .lx-schedule-radios {
        flex-direction: column;
        gap: 6px;
    }

    .ap-sch-table thead {
        display: none; /* 小螢幕轉卡片模式 */
    }

    .ap-sch-table, 
    .ap-sch-table tbody, 
    .ap-sch-table tr, 
    .ap-sch-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .ap-sch-table tr {
        background: var(--lx-raised, #242038);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 12px;
        margin-bottom: 14px;
        padding: 12px;
    }

    .ap-sch-table td {
        border-bottom: none;
        padding: 6px 0;
    }

    .ap-sch-content-cell {
        max-width: 100%;
        white-space: normal;
        word-break: break-all;
    }

    .ap-sch-actions {
        margin-top: 10px;
        border-top: 1px dashed rgba(255, 255, 255, 0.1);
        padding-top: 10px;
    }

    .ap-sch-btn {
        flex: 1;
        min-height: 44px; /* 滿足觸控規範 */
    }
}

/* Opaque sticky headers prevent scrolled content showing through in either theme. */
.ap-workspace .ap-sch-table th{background:var(--ap-soft,#eaf0f8);color:var(--ap-ink,#142b49);z-index:3;box-shadow:0 1px 0 var(--ap-line,#cbd5e1)}
.sch-pagination{display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap;padding:16px 0;color:var(--ap-ink,inherit)}
.sch-pagination[hidden]{display:none}
.sch-pagination button:disabled{opacity:.45;cursor:default}
.sch-time24{display:flex;align-items:center;gap:8px;max-width:100%}
.sch-time24 input,.sch-time24 select{min-width:0;min-height:44px;padding:8px;border:1px solid #888;border-radius:8px;background:var(--ap-bg,var(--lx-surface,#181524));color:var(--ap-ink,var(--lx-text,#fff));font-size:16px}
.sch-time24 input{flex:1;width:45%}.sch-time24 select{width:64px}
.sch-detail-text{white-space:pre-wrap;overflow-wrap:anywhere;max-height:65vh;overflow:auto;line-height:1.8}

@media(max-width:480px){.sch-time24{flex-wrap:wrap}.sch-time24 input{flex:0 0 100%;width:100%}}

@media(max-width:576px){.ap-workspace .ap-sch-table tr{background:var(--ap-bg,#fff);color:var(--ap-ink,#142b49);border-color:var(--ap-line,#ddd)}.ap-workspace .ap-sch-table td{white-space:normal;overflow-wrap:anywhere}.ap-workspace .ap-sch-content-cell{display:block;margin-bottom:8px}}

.sch-pagination .ap-sch-btn{flex:0 0 auto;min-width:44px;min-height:44px}
.sch-pagination .ap-sch-btn[aria-current="page"]{opacity:1;background:var(--ap-accent,#8551bb);color:#fff;border-color:var(--ap-accent,#8551bb);font-weight:700}
.sch-pagination-summary{flex-basis:100%;text-align:center}
@media(max-width:576px){.sch-pagination{gap:6px}.sch-pagination .ap-sch-btn{padding:8px 10px}}

/* Episode fields must use the same surface and text pair in both themes. */
#schUploadEpisodeNumber,#schUploadEpisodeTitle,#schUploadSeries,
#schEditEpisodeNumber,#schEditEpisodeTitle,#schEditSeries {
    box-sizing:border-box;min-height:44px;width:100%;padding:10px 12px;
    background:var(--lx-surface,#fff);color:var(--lx-text,#202438);
    border:1px solid var(--lx-line,#a7a2b2);border-radius:8px;
}
#schUploadEpisodeNumber::placeholder,#schUploadEpisodeTitle::placeholder,
#schEditEpisodeNumber::placeholder,#schEditEpisodeTitle::placeholder {color:var(--lx-muted,#666);opacity:1}
#schUploadEpisodeNumber:focus,#schUploadEpisodeTitle:focus,#schUploadSeries:focus,
#schEditEpisodeNumber:focus,#schEditEpisodeTitle:focus,#schEditSeries:focus {outline:2px solid var(--lx-accent,#a955b0);outline-offset:2px}
.ap-dark #schEditEpisodeNumber,.ap-dark #schEditEpisodeTitle,.ap-dark #schEditSeries {background:#242034;color:#eceaf2;border-color:#665b79}

/* Scheduled series inline required guidance. */
.sch-required{font-size:.9em;color:inherit;font-weight:700}
#story_videomodal .sch-field-error,#schEditDialog .sch-field-error{color:#b42318!important;background:#fff0ee;padding:8px 10px;border-radius:6px;font-size:14px;line-height:1.5;margin:6px 0 10px}
.sch-field-error[hidden],.sch-required[hidden]{display:none!important}
#schUploadEpisodeNumber[aria-invalid=true],#schUploadEpisodeTitle[aria-invalid=true],#schEditEpisodeNumber[aria-invalid=true],#schEditEpisodeTitle[aria-invalid=true]{border:2px solid #d94841}
/* Scheduled work settings share the composer theme, including readable native inputs. */
#story_videomodal .sch-work-form{margin:16px 0;padding:16px;border:1px solid var(--lx-border,#777);border-radius:12px;min-width:0}
#story_videomodal .sch-work-form fieldset{min-width:0;padding:14px;border:1px solid var(--lx-border,#777);border-radius:10px;margin:16px 0}
#story_videomodal .sch-work-form legend{font-size:18px;color:var(--lx-text);width:auto;padding:0 6px}
#story_videomodal .sch-work-form label{display:block;margin:10px 0 6px;color:var(--lx-text)}
#story_videomodal .sch-work-form input:not([type=checkbox]),#story_videomodal .sch-work-form select,#story_videomodal .sch-work-form textarea{display:block;box-sizing:border-box;width:100%;min-width:0;min-height:44px;padding:10px 12px;border:1px solid var(--lx-border,#888);border-radius:8px;background:var(--lx-surface,#211c28);color:var(--lx-text,#fff);font-size:16px}
#story_videomodal .sch-work-form input::placeholder{color:var(--lx-muted,#aaa)}
#story_videomodal .sch-work-row{display:grid;grid-template-columns:110px minmax(0,1fr);gap:12px}
#story_videomodal .sch-work-form .sch-work-check{display:flex;align-items:flex-start;gap:8px;line-height:1.6;cursor:pointer}
#story_videomodal .sch-work-check input{flex:0 0 18px;width:18px;height:18px;margin-top:4px;accent-color:#ff70b4}
#story_videomodal .sch-work-hint{font-size:13px;line-height:1.6;margin:8px 0;color:var(--lx-muted,#bbb)}
#story_videomodal .sch-work-form [hidden]{display:none!important}
@media(max-width:480px){#story_videomodal .sch-work-form{padding:12px}#story_videomodal .sch-work-row{grid-template-columns:1fr}}
#story_videomodal .sch-work-form input[type=date]{color-scheme:dark}
[data-theme=light] #story_videomodal .sch-work-form input[type=date]{color-scheme:light}
