/* =====================================================================
   DedicaQR — Sprint 20 CSS
   Exportación contable: status badges, timeline horizontal, progress
   bars, preview card AJAX, format options, download card.
   Aditivo sobre Sprints 1-19.
   ===================================================================== */

:root {
  --exp-queued:       #d97706;
  --exp-queued-bg:    #fef3c7;
  --exp-running:      #1d4ed8;
  --exp-running-bg:   #dbeafe;
  --exp-completed:    #059669;
  --exp-completed-bg: #d1fae5;
  --exp-failed:       #dc2626;
  --exp-failed-bg:    #fee2e2;
  --exp-cancelled:    #6b7280;
  --exp-cancelled-bg: #f3f4f6;
  --exp-archived:     #9ca3af;
  --exp-archived-bg:  #f5f5f5;
  --exp-expired:      #ea580c;
}

/* =====================================================================
   STAT ROW
   ===================================================================== */

.exp-stat-row { margin: 14px 0 18px; }

/* =====================================================================
   STATUS BADGES
   ===================================================================== */

.exp-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  vertical-align: middle;
}
.exp-status-queued    { background: var(--exp-queued-bg);    color: var(--exp-queued); }
.exp-status-running   { background: var(--exp-running-bg);   color: var(--exp-running); }
.exp-status-completed { background: var(--exp-completed-bg); color: var(--exp-completed); }
.exp-status-failed    { background: var(--exp-failed-bg);    color: var(--exp-failed); }
.exp-status-cancelled { background: var(--exp-cancelled-bg); color: var(--exp-cancelled); }
.exp-status-archived  { background: var(--exp-archived-bg);  color: var(--exp-archived); }

.exp-expired { color: var(--exp-expired); font-weight: 600; }

/* Status cell con progress bar inline */
.exp-status-cell { min-width: 130px; }
.exp-status-cell small { display: block; margin-top: 2px; }

/* =====================================================================
   PROGRESS BAR
   ===================================================================== */

.exp-progress-bar {
  display: block;
  height: 6px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0;
}
.exp-progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--exp-running) 0%, #3b82f6 100%);
  border-radius: 3px;
  transition: width 0.4s ease;
  animation: exp-pulse 2s ease-in-out infinite;
}
@keyframes exp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* =====================================================================
   TABLE LIST
   ===================================================================== */

.exp-table td { vertical-align: top; font-size: 13px; }
.exp-table code { background: var(--dqr-bg, #FFF8F5); padding: 1px 6px; border-radius: 3px; font-size: 11px; }

/* =====================================================================
   STATUS CHECKBOXES (new form)
   ===================================================================== */

.exp-status-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 4px;
}
.exp-status-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fafafa;
  border: 1px solid #ececec;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.exp-status-check input { margin: 0; }
.exp-status-check:has(input:checked) {
  border-color: var(--dqr-brand, #C9184A);
  background: var(--dqr-bg, #FFF8F5);
}

/* =====================================================================
   FORMAT OPTIONS (new form)
   ===================================================================== */

.exp-format-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0;
}
.exp-format-option {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: white;
  border: 2px solid #ececec;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.exp-format-option:hover {
  border-color: var(--dqr-pink, #FFB3C1);
}
.exp-format-option:has(input:checked) {
  border-color: var(--dqr-brand, #C9184A);
  background: var(--dqr-bg, #FFF8F5);
}
.exp-format-option input {
  flex-shrink: 0;
  margin-top: 4px;
}
.exp-format-option > div { flex: 1; }
.exp-format-option strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}
.exp-format-option small {
  display: block;
  color: #666;
  font-size: 12px;
  line-height: 1.4;
}
.exp-format-option code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* =====================================================================
   PREVIEW CARD (sticky aside en new form)
   ===================================================================== */

.exp-preview-box {
  background: white;
  border: 1px solid #ececec;
  border-radius: 12px;
  padding: 20px;
  position: sticky;
  top: 16px;
}
.exp-preview-box h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.exp-preview-loading {
  text-align: center;
  padding: 30px 10px;
  color: #888;
  font-style: italic;
}

.exp-preview-content { display: block; }

.exp-preview-stat {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.exp-preview-stat:last-child { border-bottom: 0; }

.exp-preview-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.exp-preview-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--dqr-brand, #C9184A);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.exp-preview-warn {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--exp-queued-bg);
  border-left: 3px solid var(--exp-queued);
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
}

.exp-preview-error {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--exp-failed-bg);
  border-left: 3px solid var(--exp-failed);
  border-radius: 6px;
  font-size: 12px;
  color: #7f1d1d;
}

/* =====================================================================
   TIMELINE (show.php)
   ===================================================================== */

.exp-timeline {
  display: flex;
  gap: 0;
  margin: 18px 0 24px;
  background: white;
  border: 1px solid #ececec;
  border-radius: 12px;
  padding: 18px;
  overflow-x: auto;
}

.exp-timeline-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  padding: 0 12px;
  min-width: 150px;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.exp-timeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  width: 1px;
  height: 60%;
  background: #e5e7eb;
  transform: translateY(-50%);
}

.exp-timeline-step.exp-step-done { opacity: 1; }
.exp-timeline-step.exp-step-done .exp-timeline-icon {
  background: var(--exp-completed);
  color: white;
}
.exp-timeline-step.exp-step-active { opacity: 1; }
.exp-timeline-step.exp-step-active .exp-timeline-icon {
  background: var(--exp-running);
  color: white;
}
.exp-timeline-step.exp-step-failed { opacity: 1; }
.exp-timeline-step.exp-step-failed .exp-timeline-icon {
  background: var(--exp-failed);
  color: white;
}
.exp-timeline-step.exp-step-expired { opacity: 0.6; }
.exp-timeline-step.exp-step-expired .exp-timeline-icon {
  background: var(--exp-expired);
  color: white;
}

.exp-timeline-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.exp-timeline-content {
  flex: 1;
  min-width: 0;
}
.exp-timeline-content strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
}
.exp-timeline-content small {
  display: block;
  color: #666;
  font-size: 11px;
}

/* =====================================================================
   DOWNLOAD CARD (prominent CTA)
   ===================================================================== */

.exp-download-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 26px;
  background: linear-gradient(135deg, var(--exp-completed-bg) 0%, white 100%);
  border: 2px solid var(--exp-completed);
  border-radius: 14px;
  margin: 18px 0;
  flex-wrap: wrap;
}
.exp-download-icon {
  font-size: 48px;
  line-height: 1;
  flex-shrink: 0;
}
.exp-download-info { flex: 1; min-width: 200px; }
.exp-download-info h3 {
  margin: 0 0 4px;
  color: var(--exp-completed);
  font-size: 18px;
}
.exp-download-info p {
  margin: 0;
  color: #064e3b;
  font-size: 13px;
}
.exp-download-card .btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
}

/* =====================================================================
   ACTIONS ROW (show.php)
   ===================================================================== */

.exp-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 22px;
}

/* =====================================================================
   MANIFEST PREVIEW TABLE
   ===================================================================== */

.exp-files-table td { vertical-align: middle; padding: 8px 10px; }

.exp-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.exp-kind-xml      { background: var(--exp-running-bg);   color: var(--exp-running); }
.exp-kind-pdf      { background: var(--exp-failed-bg);    color: var(--exp-failed); }
.exp-kind-manifest { background: var(--exp-queued-bg);    color: var(--exp-queued); }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 1024px) {
  .exp-timeline { flex-wrap: wrap; }
  .exp-timeline-step { flex: 1 1 calc(50% - 12px); min-width: 130px; }
  .exp-timeline-step::after { display: none; }
}

@media (max-width: 768px) {
  .exp-stat-row { grid-template-columns: repeat(2, 1fr); }
  .exp-preview-box { position: static; }
  .exp-preview-value { font-size: 1.5rem; }
  .exp-download-card { flex-direction: column; text-align: center; }
  .exp-download-card .btn-lg { width: 100%; }
  .exp-timeline-step { flex: 1 1 100%; }
  .exp-files-table { font-size: 11px; }
  .exp-files-table td { padding: 6px 4px; }
}

@media (max-width: 480px) {
  .exp-stat-row { grid-template-columns: 1fr; }
  .exp-status-checks { gap: 4px; }
  .exp-status-check { font-size: 11px; padding: 4px 10px; }
  .exp-actions-row > * { width: 100%; text-align: center; }
}
