/* =========================================
   設定模态窗口样式
   ========================================= */
.settings-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.settings-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.settings-modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid var(--card-border);
}

.settings-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--card-text);
}

.settings-close-btn {
    background: transparent;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-sub);
    transition: all 0.2s;
    padding: 4px 8px;
    border-radius: 6px;
}

.settings-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: scale(1.1);
}

.settings-tab-container {
    display: flex;
    gap: 8px;
    padding: 16px 28px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--card-border);
}

.settings-tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-sub);
    transition: all 0.3s;
    position: relative;
}

.settings-tab-btn:hover {
    background: rgba(90, 144, 224, 0.1);
    color: var(--accent-text-solid);
}

.settings-tab-btn.active {
    background: var(--accent-text-solid);
    color: white;
    box-shadow: 0 4px 12px rgba(90, 144, 224, 0.3);
}

.settings-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
}

.settings-tab-pane {
    display: none;
}

.settings-tab-pane.active {
    display: block;
}

/* =========================================
   影片源列表样式
   ========================================= */
.video-source-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.video-source-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.video-source-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.video-source-item.drag-over {
    border: 2px dashed #5A90E0;
    background: rgba(90, 144, 224, 0.1);
    transform: scale(1.02);
}

.video-source-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.video-source-icon.youtube {
    color: #ff0000;
}

.video-source-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--card-text);
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.video-source-name.editing {
    background: white;
    border: 2px solid var(--accent-text-solid);
    outline: none;
    color: #333;
}

/* 拖曳優化: 確保子元素不干擾拖曳事件 */
.video-source-item * {
    pointer-events: none;
}

/* 恢復按鈕的可點擊性 */
.video-source-item .video-source-actions,
.video-source-item .video-source-actions * {
    pointer-events: auto;
}

.video-source-actions {
    transform: scale(1.1);
}

.edit-btn:hover {
    background: #3b82f6;
    color: white;
}

.delete-btn:hover {
    background: #ef4444;
    color: white;
}

.add-source-btn {
    width: 100%;
    padding: 14px;
    margin-bottom: 16px;
    /* 與列表隔開 */
    background: linear-gradient(135deg, #6B9FE8 0%, #5A8FDD 100%);
    /* 更輕的藍色 */
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(90, 144, 224, 0.3);
}

.add-source-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(90, 144, 224, 0.4);
}

.add-source-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .video-source-item {
    background: rgba(55, 65, 81, 0.5);
}

[data-theme="dark"] .video-source-name.editing {
    background: #374151;
    color: white;
    border-color: #60a5fa;
}

[data-theme="dark"] .video-source-btn,
[data-theme="dark"] .edit-btn,
[data-theme="dark"] .delete-btn {
    background: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .settings-modal-content {
    background: rgba(31, 41, 55, 0.95);
}

[data-theme="dark"] .settings-modal-header h2,
[data-theme="dark"] .video-source-name {
    color: #f9fafb;
}

[data-theme="dark"] .settings-tab-btn {
    color: #9ca3af;
}

/* =========================================
   添加影片源模態框样式
   ========================================= */
.add-source-modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.add-source-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.add-source-modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.add-source-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.add-source-modal-header h3 {
    margin: 0;
    color: var(--card-text);
    font-size: 1.25rem;
    font-weight: 600;
}

.add-source-modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--card-text);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: var(--sub-card-bg);
    color: var(--card-text);
    font-size: 0.95rem;
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #5A90E0;
    box-shadow: 0 0 0 3px rgba(90, 144, 224, 0.1);
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-sub);
    font-size: 0.82rem;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

.btn-modal-primary,
.btn-modal-secondary {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
}

.btn-modal-primary {
    background: linear-gradient(135deg, #5A90E0 0%, #4A7BC8 100%);
    color: white;
}

.btn-modal-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(90, 144, 224, 0.4);
}

.btn-modal-primary:active {
    transform: translateY(0);
}

.btn-modal-secondary {
    background: var(--sub-card-bg);
    color: var(--card-text);
}

/* =========================================
   Fix for Drag and Drop Interference
   ========================================= */
body.settings-open .grid-stack,
body.settings-open .main-wrapper,
body.settings-open iframe,
body.settings-open video,
body.settings-open .video-js,
body.settings-open .vjs-tech {
    pointer-events: none !important;
}