/* static/css/articles.css - 文章和組件樣式 (Enhanced for Image Editing) */

/* ============ 文章列表基礎樣式 ============ */
.article-list { 
    max-height: 550px; 
    overflow-y: auto; 
    border: 1px solid #dee2e6; 
    border-radius: 6px; 
    padding: 0; 
    margin-top: 15px; 
}

.article-item { 
    padding: 18px; 
    border-bottom: 1px solid #e9ecef; 
    background-color: #fff; 
    transition: background-color 0.2s; 
}

.article-item:hover { 
    background: #f8f9fa; 
}

.article-item:last-child { 
    border-bottom: none; 
}

.article-item label { 
    font-weight: 600; 
    font-size: 1.05em; 
}

.article-item small { 
    color: #55595c; 
    font-size: 0.9em; 
}

.article-item p { 
    margin: 8px 0; 
    line-height: 1.6; 
}

.article-item textarea { 
    width: 98%; 
    padding: 12px; 
    border: 1px solid #ced4da; 
    border-radius: 5px; 
    font-size: 15px; 
    line-height: 1.6; 
    margin-top: 8px; 
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 
    min-height: 120px; 
}

.article-item textarea:read-only { 
    background-color: #e9ecef; 
    cursor: default; 
}

.article-thumbnail { 
    max-width: 100px; 
    max-height: 100px; 
    margin-top: 10px; 
    border-radius: 4px; 
    border: 1px solid #ddd; 
    object-fit: cover;
}

/* ============ 文章狀態標籤 ============ */
.status { 
    padding: 5px 12px; 
    border-radius: 15px; 
    font-size: 12px; 
    color: white; 
    margin-left: 12px; 
    display: inline-block; 
    vertical-align: middle; 
    font-weight: 500; 
}

.status.pending { background: #ffc107; color: #212529; }
.status.processing { background: #17a2b8; }
.status.completed { background: #28a745; }
.status.draft { background: #fd7e14; color: white; }
.status.error { background: #dc3545; }
.status.published { background: #5cb85c; }

/* ============ 分類標籤 ============ */
.category-badge {
    display: inline-block; 
    padding: 3px 8px; 
    font-size: 0.75em; 
    font-weight: bold; 
    color: white;
    background-color: #6c757d; 
    border-radius: 10px; 
    margin-left: 8px; 
    vertical-align: middle;
}

/* 確保標籤內的連結文字顏色正確 */
.category-badge a {
    color: white !important;
    text-decoration: none;
}

.category-badge a:hover {
    text-decoration: underline;
}

/* 來源/分類特定顏色 */
.category-badge.Apple { background-color: #0071e3; }
.category-badge.Android { background-color: #3ddc84; }
.category-badge.AI { background-color: #ff69b4; }
.category-badge.Tech { background-color: #fd7e14; }
.category-badge.Google { background-color: #4285f4; }
.category-badge.Microsoft { background-color: #0078d4; }
.category-badge.Gaming { background-color: #9146ff; }
.category-badge.Blockchain { background-color: #f7931a; }
.category-badge.Security { background-color: #dc3545; }
.category-badge.Startup { background-color: #17a2b8; }

/* App Store 相關來源 */
.category-badge[class*="App Store"] { background-color: #0071e3; }
.category-badge[class*="Google Play"] { background-color: #3ddc84; }

/* RSS 來源特定樣式 */
.category-badge.TechCrunch { background-color: #0f9d58; }
.category-badge.Engadget { background-color: #00bcd4; }
.category-badge.Verge { background-color: #e50050; }
.category-badge.Ars { background-color: #ff4500; }

/* ============ 日期分組樣式 ============ */
.date-group { border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; }
.date-header:hover { background: #d1ecf1 !important; }
.completed-article-compact .article-header:hover { background: #e2e6ea !important; }
.date-group-content, .article-content { transition: all 0.3s ease; }

/* ============ Feed 資訊樣式 ============ */
#feed-info-list { margin-top: 10px; padding: 10px; background-color: #e9ecef; border-radius: 5px; font-size: 0.9em; }
#feed-info-list div { margin-bottom: 5px; }

/* ============ RSS 來源和提取器項目樣式 ============ */
.rss-source-item, .extractor-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid #eee; gap: 10px; }
.rss-source-item:last-child, .extractor-item:last-child { border-bottom: none; }
.rss-source-details, .extractor-details { flex-grow: 1; word-break: break-all; }
.rss-source-actions button, .extractor-actions button { margin-left: 8px; padding: 6px 10px; font-size: 0.85em; white-space: nowrap; }
#rss-sources-list, #custom-extractors-list { border: 1px solid #dee2e6; border-radius: 6px; max-height: 300px; overflow-y: auto; margin-bottom: 15px;}

/* ============ 分類群組管理樣式 ============ */
.category-form { background: #f8f9fa; padding: 20px; border-radius: 8px; border: 1px solid #e9ecef; margin-bottom: 25px; }
.category-form h4 { margin-top: 0; color: #495057; border-bottom: 1px solid #dee2e6; padding-bottom: 10px; }
.category-groups { background: white; border: 1px solid #dee2e6; border-radius: 8px; padding: 0; overflow: hidden; }
.category-groups h4 { margin: 0; padding: 15px 20px; background: #e9ecef; border-bottom: 1px solid #dee2e6; color: #495057; }
.category-group-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #f1f3f4; transition: background-color 0.2s ease; }
.category-group-item:last-child { border-bottom: none; }
.category-group-item:hover { background-color: #f8f9fa; }
.category-group-item.editing { background-color: #fff3cd; border: 1px solid #ffeaa7; }
.group-info { flex-grow: 1; }
.group-name { font-weight: 600; color: #2c3e50; margin-bottom: 5px; font-size: 16px; }
.group-ids { color: #6c757d; font-size: 14px; }
.group-actions { display: flex; gap: 8px; }
.btn-add, .btn-edit, .btn-delete, .btn-save, .btn-cancel { padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.2s ease; }
.btn-add { background: #28a745; color: white; } .btn-add:hover { background: #218838; }
.btn-edit { background: #ffc107; color: #212529; } .btn-edit:hover { background: #e0a800; }
.btn-delete { background: #dc3545; color: white; } .btn-delete:hover { background: #c82333; }
.btn-save { background: #28a745; color: white; } .btn-save:hover { background: #218838; }
.btn-cancel { background: #6c757d; color: white; } .btn-cancel:hover { background: #545b62; }
.edit-form { width: 100%; }
.edit-form input { width: 100%; padding: 8px 12px; margin-bottom: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px; }
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; }


/* --- NEW: Image Management Styles --- */
.image-management-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}
.image-management-section h4 {
    margin-top: 0;
    color: #0056b3;
}
.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    min-height: 150px; /* Ensure gallery has height even when empty */
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}
.gallery-item {
    position: relative;
    width: 150px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}
.gallery-item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.gallery-item.thumbnail-selected {
    border-color: #007bff;
    box-shadow: 0 0 12px rgba(0, 123, 255, 0.5);
}
.gallery-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}
.gallery-item-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: space-around;
    padding: 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.gallery-item:hover .gallery-item-controls {
    opacity: 1;
}
.gallery-item-controls button {
    padding: 4px 6px;
    font-size: 11px;
    background: #fff;
    color: #333;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}
.gallery-item-controls button.danger {
    background: #dc3545;
    color: #fff;
}

.image-upload-area {
    margin-top: 20px;
}
.upload-tabs {
    display: flex;
    border-bottom: 1px solid #ccc;
    margin-bottom: 15px;
}
.upload-tab-button {
    background-color: #f1f1f1;
    border: 1px solid transparent;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}
.upload-tab-button.active {
    background-color: #fff;
    border-color: #ccc;
    border-bottom-color: #fff;
    font-weight: 600;
}
.upload-pane {
    display: none;
}
.upload-pane.active {
    display: block;
}
.upload-pane input[type="file"],
.upload-pane input[type="url"] {
    width: calc(100% - 120px);
    margin-right: 10px;
}

/* --- Styles for WP Media Library --- */
.wp-media-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    background: #f0f2f5;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 10px;
}
.wp-media-item {
    width: 120px;
    height: 120px;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease;
    background: #fff;
}
.wp-media-item:hover {
    border-color: #007bff;
}
.wp-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============ 文章排程系統樣式 ============ */

.scheduler-overview {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.status-panel {
    display: flex;
    gap: 30px;
    align-items: center;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.status-label {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

.status.running, .status.enabled {
    background: #28a745;
    color: white;
}

.status.stopped, .status.disabled {
    background: #dc3545;
    color: white;
}

.scheduler-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.action-group {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.action-group h4 {
    margin: 0 0 10px 0;
    color: #495057;
}

.action-group p {
    margin: 0 0 15px 0;
    color: #6c757d;
    font-size: 14px;
}

.statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #007bff;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.next-schedule {
    background: #e7f3ff;
    padding: 15px;
    border-radius: 6px;
    margin-top: 20px;
    text-align: center;
}

.next-label {
    font-weight: 600;
    color: #495057;
    margin-right: 10px;
}

.scheduler-controls {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.filter-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.scheduled-article-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

.scheduled-article-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.article-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.publish-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.publish-status.draft {
    background: #ffc107;
    color: #212529;
}

.publish-status.publish {
    background: #28a745;
    color: white;
}

.retry-count {
    background: #17a2b8;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 8px;
    border-radius: 4px;
    margin-top: 8px;
    font-size: 12px;
}

.article-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.status-group {
    margin-bottom: 30px;
}

.status-header {
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-weight: 600;
    color: white;
}

.status-header.status-pending {
    background: #ffc107;
    color: #212529;
}

.status-header.status-processing {
    background: #17a2b8;
}

.status-header.status-completed {
    background: #28a745;
}

.status-header.status-failed {
    background: #dc3545;
}

.status-header.status-cancelled {
    background: #6c757d;
}

.articles-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
}

.settings-form {
    max-width: 600px;
}

/* 模態框樣式 */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 0;
    border: none;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #495057;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.button.small {
    padding: 4px 8px;
    font-size: 12px;
}