/* Jobs Management Styles */

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.header-title h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-subtitle {
    margin: 0.25rem 0 0 0;
    font-size: 0.875rem;
    color: var(--text-muted, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-subtitle strong {
    color: var(--primary-color, #3b82f6);
    font-weight: 600;
}

.page-subtitle-inline {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card.active {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-value.stat-total { color: #3b82f6; }
.stat-value.stat-running { color: #0ea5e9; }
.stat-value.stat-pending { color: #f59e0b; }
.stat-value.stat-completed { color: #22c55e; }
.stat-value.stat-failed { color: #ef4444; }

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted, #6b7280);
}

/* Filters Section */
.filters-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

.filter-group select,
.filter-group input {
    min-width: 160px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: var(--input-bg, #fff);
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.btn-filter {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Jobs Table */
.jobs-table-container {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    overflow: hidden;
}

.jobs-table {
    width: 100%;
    border-collapse: collapse;
}

.jobs-table th,
.jobs-table td {
    padding: 0.875rem 1rem;
    text-align: start;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.jobs-table th {
    background: var(--table-header-bg, #f9fafb);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted, #6b7280);
}

.jobs-table tbody tr {
    transition: background 0.15s ease;
}

.jobs-table tbody tr:hover {
    background: var(--row-hover-bg, #f3f4f6);
}

.jobs-table tbody tr:last-child td {
    border-bottom: none;
}

/* Row States */
.row-running {
    animation: pulse-bg 2s infinite;
}

@keyframes pulse-bg {
    0%, 100% { background-color: rgba(59, 130, 246, 0.05); }
    50% { background-color: rgba(59, 130, 246, 0.1); }
}

.row-failed {
    background-color: rgba(239, 68, 68, 0.05);
}

.row-completed {
    background-color: rgba(34, 197, 94, 0.03);
}

/* Job ID */
.job-id {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

.job-id-full {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    word-break: break-all;
}

/* Progress Bar (inline) */
.progress-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-bar-mini {
    width: 100px;
    height: 8px;
    background: var(--progress-bg, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill-mini {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill-mini.running { background: #3b82f6; }
.progress-fill-mini.completed { background: #22c55e; }
.progress-fill-mini.failed { background: #ef4444; }

.progress-text {
    font-size: 0.875rem;
    min-width: 40px;
}

/* Details Page */
.job-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.job-main-card {
    grid-column: 1 / -1;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem 2rem;
    margin-bottom: 1.5rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

.info-value {
    font-size: 1rem;
}

/* Large Progress Bar */
.progress-section {
    background: var(--progress-section-bg, #f9fafb);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.progress-label {
    font-size: 0.875rem;
    color: var(--text-color, #374151);
}

.progress-percent {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color, #3b82f6);
}

.progress-bar-large {
    height: 16px;
    background: var(--progress-bg, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.4s ease;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}

.progress-fill.progress-completed {
    background: linear-gradient(90deg, #22c55e, #10b981);
}

.progress-fill.progress-failed {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.progress-fill.progress-running {
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

.progress-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Action Section */
.action-section {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

/* Timeline */
.timeline {
    position: relative;
    padding-inline-start: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    inset-inline-start: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color, #e5e7eb);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-icon {
    position: absolute;
    inset-inline-start: -2rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--card-bg, #fff);
    border: 2px solid var(--border-color, #e5e7eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

.timeline-item.completed .timeline-icon {
    border-color: #22c55e;
    color: #22c55e;
}

.timeline-item.failed .timeline-icon {
    border-color: #ef4444;
    color: #ef4444;
}

.timeline-item.pending .timeline-icon {
    border-color: var(--border-color, #e5e7eb);
    color: var(--text-muted, #6b7280);
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.timeline-title {
    font-weight: 500;
}

.timeline-time {
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

/* Duration Badge */
.duration-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--badge-bg, #f3f4f6);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Result/Error Cards */
.result-card .card-header.bg-success,
.error-card .card-header.bg-danger {
    color: #fff;
}

.result-json {
    background: var(--code-bg, #1e1e1e);
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.error-message {
    color: #dc2626;
    font-size: 0.95rem;
    margin: 0;
    white-space: pre-wrap;
}

/* Pagination */
.pagination-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted, #6b7280);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-controls button {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    background: var(--card-bg, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease;
}

.pagination-controls button:hover:not(:disabled) {
    background: var(--btn-hover-bg, #f3f4f6);
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-page {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--text-muted, #6b7280);
}

/* Badges */
.badge-lg {
    font-size: 1rem;
    padding: 0.5rem 1rem;
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group select,
    .filter-group input {
        width: 100%;
    }
    
    .job-details-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .pagination-section {
        flex-direction: column;
        text-align: center;
    }
}

/* RTL Adjustments */
[dir="rtl"] .timeline::before {
    inset-inline-start: auto;
    inset-inline-end: calc(100% - 0.75rem - 2px);
}

[dir="rtl"] .timeline-icon {
    inset-inline-start: auto;
    inset-inline-end: -2rem;
}
