/**
 * Blog Pipeline Dashboard - Styles
 * Modern, clean design with smooth interactions
 */

/* ==================== Base ==================== */

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1c2128;
    --bg-card: #242b33;
    --bg-hover: #2d3640;
    
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    --accent-primary: #58a6ff;
    --accent-success: #3fb950;
    --accent-warning: #d29922;
    --accent-error: #f85149;
    
    --border-color: #30363d;
    --border-radius: 12px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
    
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ==================== Dashboard Layout ==================== */

.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==================== Header ==================== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.header-left .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-badge.status-idle .status-dot { background: #22c55e; }
.status-badge.status-running .status-dot { 
    background: var(--accent-primary); 
    animation: pulse 1.5s infinite;
}
.status-badge.status-error .status-dot { background: var(--accent-error); }
.status-badge.status-cancelled .status-dot { background: var(--accent-warning); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    font-size: 14px;
    font-weight: 500;
}

/* ==================== Buttons ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: #4c8ed9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--accent-error);
    color: white;
}

.btn-danger:hover {
    background: #d73a49;
    transform: translateY(-1px);
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
}

/* ==================== Main Content ==================== */

.main {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ==================== Progress Section ==================== */

.progress-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-stats {
    display: flex;
    gap: 24px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== Stats Section ==================== */

.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 32px;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== Two Column Layout ==================== */

.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* ==================== Sources Section ==================== */

.sources-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.sources-section h2 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 16px;
}

.sources-list {
    max-height: 300px;
    overflow-y: auto;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.source-item:hover {
    background: var(--bg-secondary);
}

.source-item.disabled {
    opacity: 0.5;
}

.source-icon {
    font-size: 20px;
}

.source-info {
    flex: 1;
}

.source-name {
    font-size: 14px;
    font-weight: 500;
}

.source-url {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-category {
    font-size: 12px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    color: var(--text-secondary);
}

/* ==================== Log Section ==================== */

.log-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.log-section h2 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 16px;
}

.log-container {
    height: 300px;
    overflow-y: auto;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 12px;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 13px;
}

.log-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.log-item {
    display: flex;
    gap: 12px;
    padding: 4px 0;
}

.log-time {
    color: var(--text-muted);
    width: 60px;
}

.log-message {
    flex: 1;
}

.log-item.log-info .log-message { color: var(--text-primary); }
.log-item.log-success .log-message { color: var(--accent-success); }
.log-item.log-warning .log-message { color: var(--accent-warning); }
.log-item.log-error .log-message { color: var(--accent-error); }

/* ==================== Articles Section ==================== */

.articles-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.articles-header {
    margin-bottom: 12px;
}

.articles-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.articles-actions-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.articles-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.articles-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

.article-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    overflow: hidden; /* Prevent buttons escaping */
}

.article-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.article-select {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.article-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.article-info {
    flex: 1;
    min-width: 0; /* Allow text truncation */
    overflow: hidden;
}

.article-title {
    font-size: 14px !important;
    font-weight: 500 !important;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #e6edf3 !important;
    display: block !important;
    max-width: 100%;
    line-height: 1.4;
}

.article-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.article-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    flex-shrink: 0;
    margin-right: 8px;
}

.status-modified {
    background: var(--success-bg, #e6f4ea);
    color: var(--success-text, #1e7e34);
}

.status-unmodified {
    background: var(--warning-bg, #fff3cd);
    color: var(--warning-text, #856404);
}

.article-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.article-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

.article-actions {
    display: flex;
    gap: 8px;
}

/* ==================== Footer ==================== */

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-left a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-left a:hover {
    color: var(--accent-primary);
}

/* ==================== Modal ==================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 500;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    border: none;
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

/* ==================== Toast ==================== */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.toast-success { border-color: var(--accent-success); color: var(--accent-success); }
.toast-error { border-color: var(--accent-error); color: var(--accent-error); }
.toast-warning { border-color: var(--accent-warning); color: var(--accent-warning); }
.toast-info { border-color: var(--accent-primary); color: var(--accent-primary); }

.toast.fade-out {
    opacity: 0;
    transform: translateY(10px);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== Scrollbar ==================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== Responsive ==================== */

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 16px;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
    }
    
    .columns {
        grid-template-columns: 1fr;
    }
    
    .articles-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .articles-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .search-input {
        width: 100%;
    }
}
