/**
 * SimCard Manager - Jobs Stylesheet (jobs.css)
 * استایل‌های صفحه مدیریت عملیات، کارت‌های جاب، نوارهای پیشرفت زنده، لاگ بلادرنگ SSE
 */

.jobs-header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.jobs-filter-group {
  display: flex;
  gap: 8px;
}

.job-quick-triggers {
  display: flex;
  gap: 10px;
}

/* Active Jobs Hero Card */
.active-job-banner {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(30, 41, 59, 0.7));
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.15);
  position: relative;
  overflow: hidden;
}

.active-job-banner::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #38bdf8);
  background-size: 200% 100%;
  animation: pulseGradient 2s linear infinite;
}

@keyframes pulseGradient {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.active-job-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.active-job-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.active-job-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.active-job-title {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
}

.active-job-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 14px;
  background: #0d131f;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  transition: width 0.3s ease;
  position: relative;
}

.progress-bar.animated {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 30px 30px;
  animation: progressStripes 1.2s linear infinite;
}

@keyframes progressStripes {
  from { background-position: 30px 0; }
  to { background-position: 0 0; }
}

.progress-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.progress-percentage {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  font-family: Consolas, monospace;
}

/* Jobs History Cards Grid */
.jobs-list-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
  flex-wrap: wrap;
}

.job-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.job-card-main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 260px;
}

.job-type-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.job-details-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.job-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

/* Job Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.queued { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.status-badge.running { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.status-badge.completed { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.status-badge.partially_completed { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.status-badge.failed { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.status-badge.cancelled { background: rgba(148, 163, 184, 0.15); color: #64748b; }

.status-badge.running::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Job Stats Bar inside Card */
.job-card-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

.job-stat-chip {
  background: #0d131f;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: Consolas, monospace;
}

/* Job Item Detail in Modal */
.job-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.job-item-row:last-child {
  border-bottom: none;
}

.job-item-phone {
  font-family: Consolas, monospace;
  font-weight: 700;
  color: #fff;
}

.job-item-err {
  font-size: 11.5px;
  color: var(--danger);
  margin-top: 2px;
}

/* SSE Live Terminal Console */
.job-failures-link { cursor: pointer; font: inherit; }
.job-failures-link:hover { border-color: var(--danger); }
.job-details-meta, .job-details-status-filters, .job-details-toolbar, .job-details-pagination {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.job-details-meta { margin-bottom: 14px; font-size: 12px; overflow-wrap: anywhere; }
.job-details-status-filters { margin-bottom: 12px; }
.job-details-filter.selected { border-color: var(--primary); background: rgba(56, 189, 248, .12); }
.job-details-toolbar input { flex: 2 1 200px; min-width: 0; }
.job-details-toolbar select { flex: 1 1 140px; min-width: 0; }
.job-details-result-count { margin: 10px 0; color: var(--text-muted); font-size: 12px; }
.job-details-items { max-height: 400px; overflow: auto; background: #0b0f19; border: 1px solid var(--border-color); border-radius: 8px; }
.job-details-items .job-item-row { gap: 12px; align-items: flex-start; }
.job-item-info { min-width: 0; overflow-wrap: anywhere; }
.job-item-name { font-weight: 700; margin-bottom: 4px; }
.job-item-service { display: inline-block; margin-inline-start: 8px; color: var(--primary); }
.job-item-failed { border-inline-start: 3px solid var(--danger); }
.job-item-error-code { margin-top: 6px; color: var(--danger); font-size: 12px; }
.job-item-hint { margin-top: 4px; font-size: 12px; line-height: 1.7; }
.job-item-err { overflow-wrap: anywhere; white-space: pre-wrap; }
.job-details-pagination { justify-content: center; margin-top: 12px; font-size: 12px; }
.job-details-empty { padding: 24px; text-align: center; color: var(--text-muted); }
@media (max-width: 480px) {
  .job-details-toolbar input, .job-details-toolbar select { flex-basis: 100%; }
  .job-details-items .job-item-row { flex-wrap: wrap; padding: 10px; }
  .job-details-filter { flex: 1 1 auto; }
}

.sse-console-box {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 14px;
  max-height: 240px;
  overflow-y: auto;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12.5px;
  color: #a5f3fc;
  line-height: 1.5;
  margin-top: 16px;
  direction: ltr;
  text-align: left;
}

.sse-log-entry {
  margin-bottom: 4px;
}

.sse-log-ts {
  color: #64748b;
  margin-right: 6px;
}

.sse-log-event {
  color: #38bdf8;
  font-weight: 700;
}

/* ===================================================
   Persistent Schedules Automation Styles (W5)
   =================================================== */

.schedules-automation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 28px;
}

.schedules-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.schedule-health-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.schedule-health-badge.healthy {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.schedule-health-badge.degraded {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.schedule-health-badge.stopped {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.schedules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

@media (max-width: 480px) {
  .schedules-grid {
    grid-template-columns: 1fr;
  }
}

.schedule-item-card {
  background: #0d131f;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.2s ease;
}

.schedule-item-card.enabled {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.schedule-item-card.disabled {
  opacity: 0.7;
  border-color: rgba(255, 255, 255, 0.08);
}

.schedule-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.schedule-card-icon {
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.schedule-card-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.schedule-card-interval {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.schedule-card-meta {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}

.schedule-meta-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.schedule-meta-line .meta-label {
  color: var(--text-muted);
}

.schedule-meta-line .meta-val {
  font-family: Consolas, monospace;
}

.schedule-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.schedule-run-btn {
  flex: 1;
  min-height: 40px;
}

/* Accessible Toggle Switch (min 44px tap zone) */
.schedule-toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  min-width: 46px;
  cursor: pointer;
}

.schedule-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.schedule-toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.schedule-toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}
