/**
 * workflows.css — Workflow Automation Builder UI v1.0
 * Visual rule editor + execution log. Namespace: .wf-
 */

:root {
  --wf-blue:    #3B82F6;
  --wf-green:   #10B981;
  --wf-amber:   #F59E0B;
  --wf-red:     #EF4444;
  --wf-purple:  #8B5CF6;
  --wf-cyan:    #06B6D4;
  --wf-surface: #fff;
  --wf-border:  #E5E7EB;
  --wf-sub:     #6B7280;
  --wf-radius:  12px;
}

/* ══════════════════════════════════════════════
   1. SECTION LAYOUT
══════════════════════════════════════════════ */
.wf-section { padding: 0; }
.wf-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 0 14px; flex-wrap: wrap;
}
.wf-header__title { font-size: 18px; font-weight: 900; flex: 1; display:flex;align-items:center;gap:8px; }
.wf-header__actions { display: flex; gap: 8px; }

/* Tabs */
.wf-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--wf-border); margin-bottom: 18px; }
.wf-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 700; color: var(--wf-sub);
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s;
}
.wf-tab:hover { color: #1F2937; }
.wf-tab.active { color: var(--wf-blue); border-bottom-color: var(--wf-blue); }

/* ══════════════════════════════════════════════
   2. WORKFLOW CARDS (list view)
══════════════════════════════════════════════ */
.wf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }

.wf-card {
  background: var(--wf-surface); border: 1px solid var(--wf-border); border-radius: var(--wf-radius);
  padding: 18px 20px; transition: border-color .13s, box-shadow .13s;
  cursor: pointer; position: relative;
}
.wf-card:hover { border-color: #DBEAFE; box-shadow: 0 2px 12px rgba(59,130,246,.06); }
.wf-card.inactive { opacity: .55; }

.wf-card__top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wf-card__icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: #EFF6FF; display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.wf-card__title { font-size: 14px; font-weight: 800; color: #1F2937; line-height: 1.3; }
.wf-card__trigger { font-size: 11px; color: var(--wf-sub); }

.wf-card__flow {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0; margin: 8px 0; border-top: 1px solid #F3F4F6;
  font-size: 11px; color: var(--wf-sub); flex-wrap: wrap;
}
.wf-card__flow-node {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 6px; font-weight: 700;
}
.wf-card__flow-node--trigger  { background: #EFF6FF; color: var(--wf-blue); }
.wf-card__flow-node--condition{ background: #FFFBEB; color: var(--wf-amber); }
.wf-card__flow-node--action   { background: #F0FDF4; color: var(--wf-green); }
.wf-card__flow-arrow { color: #D1D5DB; font-weight: 900; }

.wf-card__footer { display: flex; align-items: center; gap: 8px; }
.wf-card__stats { display: flex; gap: 6px; flex: 1; }

/* ── Stat mini pills ── */
.wf-stat {
  font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 99px;
}
.wf-stat--success { background: rgba(16,185,129,.1); color: var(--wf-green); }
.wf-stat--failed  { background: rgba(239,68,68,.1); color: var(--wf-red); }
.wf-stat--pending { background: rgba(245,158,11,.1); color: var(--wf-amber); }

/* Toggle switch */
.wf-toggle {
  width: 36px; height: 20px; border-radius: 10px; position: relative;
  background: #D1D5DB; cursor: pointer; transition: background .2s;
  border: none; flex-shrink: 0;
}
.wf-toggle.on { background: var(--wf-green); }
.wf-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.wf-toggle.on::after { transform: translateX(16px); }

/* ══════════════════════════════════════════════
   3. BUILDER MODAL
══════════════════════════════════════════════ */
.wf-builder-backdrop {
  display: none; position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
.wf-builder-backdrop.open { display: flex; }

.wf-builder {
  background: #fff; border-radius: 18px; width: 680px; max-width: 96vw;
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  animation: wfSlide .25s ease;
}
.wf-builder__hdr {
  padding: 18px 24px; border-bottom: 1px solid var(--wf-border);
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 900;
}
.wf-builder__close {
  margin-left: auto; width: 32px; height: 32px; border-radius: 8px;
  border: none; background: #F3F4F6; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.wf-builder__close:hover { background: #E5E7EB; }
.wf-builder__body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.wf-builder__footer {
  padding: 14px 24px; border-top: 1px solid var(--wf-border);
  display: flex; justify-content: flex-end; gap: 8px;
}

@keyframes wfSlide { from{opacity:0;transform:translateY(-20px)} to{opacity:1;transform:translateY(0)} }

/* ── Builder sections ── */
.wf-builder-section {
  margin-bottom: 20px; padding: 16px; border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius); background: #FAFBFC;
}
.wf-builder-section__hdr {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  font-size: 13px; font-weight: 800; color: #1F2937;
}
.wf-builder-section__badge {
  padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .3px;
}
.wf-builder-section__badge--trigger   { background: #DBEAFE; color: var(--wf-blue); }
.wf-builder-section__badge--condition { background: #FEF3C7; color: #92400E; }
.wf-builder-section__badge--action    { background: #D1FAE5; color: #065F46; }

/* ── Form fields ── */
.wf-field { margin-bottom: 12px; }
.wf-field label {
  display: block; font-size: 11px; font-weight: 700; color: #374151;
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: .3px;
}
.wf-input, .wf-select {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--wf-border);
  border-radius: 8px; font-size: 13px; color: #1F2937; outline: none;
  box-sizing: border-box; transition: border-color .12s;
}
.wf-input:focus, .wf-select:focus { border-color: var(--wf-blue); }
.wf-textarea {
  width: 100%; min-height: 60px; padding: 8px 12px; border: 1px solid var(--wf-border);
  border-radius: 8px; font-size: 13px; color: #1F2937; outline: none;
  resize: vertical; box-sizing: border-box;
}

/* ── Condition / Action rows ── */
.wf-rule-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
  padding: 8px 10px; background: #fff; border: 1px solid #F3F4F6;
  border-radius: 8px; flex-wrap: wrap;
}
.wf-rule-row .wf-select { width: auto; min-width: 120px; height: 32px; font-size: 12px; }
.wf-rule-row .wf-input  { width: auto; min-width: 100px; flex: 1; height: 32px; font-size: 12px; }
.wf-rule-remove {
  width: 26px; height: 26px; border-radius: 6px; border: none;
  background: rgba(239,68,68,.08); color: var(--wf-red); cursor: pointer;
  font-size: 12px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.wf-rule-remove:hover { background: rgba(239,68,68,.15); }
.wf-add-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 6px; border: 1px dashed #D1D5DB;
  background: none; font-size: 12px; font-weight: 700; color: var(--wf-blue);
  cursor: pointer; transition: border-color .12s;
}
.wf-add-btn:hover { border-color: var(--wf-blue); background: #EFF6FF; }

/* ══════════════════════════════════════════════
   4. TEMPLATE CARDS
══════════════════════════════════════════════ */
.wf-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.wf-tpl-card {
  border: 1px solid var(--wf-border); border-radius: var(--wf-radius);
  padding: 16px; cursor: pointer; transition: all .13s;
}
.wf-tpl-card:hover { border-color: var(--wf-blue); background: #EFF6FF; }
.wf-tpl-card__title { font-size: 13px; font-weight: 800; margin-bottom: 4px; display:flex;align-items:center;gap:6px; }
.wf-tpl-card__desc  { font-size: 11px; color: var(--wf-sub); line-height: 1.4; }
.wf-tpl-card__meta  { font-size: 10px; color: var(--wf-sub); margin-top: 8px; display:flex;gap:8px; }

/* ══════════════════════════════════════════════
   5. EXECUTION LOG
══════════════════════════════════════════════ */
.wf-exec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.wf-exec-table thead th {
  padding: 8px 12px; font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .4px; color: var(--wf-sub); border-bottom: 1px solid var(--wf-border);
  text-align: left; white-space: nowrap;
}
.wf-exec-table tbody tr { border-bottom: 1px solid #F3F4F6; transition: background .1s; }
.wf-exec-table tbody tr:hover { background: #FAFBFC; }
.wf-exec-table td { padding: 10px 12px; vertical-align: middle; }

/* Status badges */
.wf-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 99px; font-size: 10px; font-weight: 800;
  text-transform: uppercase;
}
.wf-status--success  { background:rgba(16,185,129,.1);  color:var(--wf-green); }
.wf-status--failed   { background:rgba(239,68,68,.1);   color:var(--wf-red); }
.wf-status--running  { background:rgba(59,130,246,.1);  color:var(--wf-blue); }
.wf-status--pending  { background:rgba(245,158,11,.1);  color:var(--wf-amber); }
.wf-status--retrying { background:rgba(139,92,246,.1);  color:var(--wf-purple); }

/* ══════════════════════════════════════════════
   6. STATS BAR
══════════════════════════════════════════════ */
.wf-stats { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.wf-stats__card {
  flex: 1; min-width: 140px; padding: 14px 16px;
  background: var(--wf-surface); border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius);
}
.wf-stats__val { font-size: 24px; font-weight: 900; }
.wf-stats__label { font-size: 10px; font-weight: 700; color: var(--wf-sub); text-transform: uppercase; margin-top: 2px; }

/* ══════════════════════════════════════════════
   7. BUTTONS
══════════════════════════════════════════════ */
.wf-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 8px;
  font-size: 13px; font-weight: 700; border: none; cursor: pointer; transition: all .13s;
}
.wf-btn--primary { background: var(--wf-blue); color: #fff; }
.wf-btn--primary:hover { background: #2563EB; }
.wf-btn--ghost   { background: transparent; color: var(--wf-sub); border: 1px solid var(--wf-border); }
.wf-btn--ghost:hover   { color: #1F2937; border-color: #D1D5DB; }
.wf-btn--danger  { background: rgba(239,68,68,.08); color: var(--wf-red); border: 1px solid rgba(239,68,68,.15); }
.wf-btn--danger:hover  { background: rgba(239,68,68,.15); }
.wf-btn--sm      { height: 30px; padding: 0 10px; font-size: 12px; }

/* ══════════════════════════════════════════════
   8. SKELETON / EMPTY
══════════════════════════════════════════════ */
.wf-skel { height: 80px; border-radius: var(--wf-radius); margin-bottom: 8px;
  background: linear-gradient(90deg,#F9FAFB 25%,#F3F4F6 50%,#F9FAFB 75%);
  background-size: 200% 100%; animation: wfShim 1.4s infinite;
}
@keyframes wfShim { 0%{background-position:200% 0}100%{background-position:-200% 0} }

.wf-empty { padding: 40px 20px; text-align: center; color: var(--wf-sub); }
.wf-empty__icon  { font-size: 32px; display: block; margin-bottom: 8px; }
.wf-empty__title { font-size: 14px; font-weight: 700; color: #1F2937; }
.wf-empty__sub   { font-size: 12px; margin-top: 4px; }

/* ══════════════════════════════════════════════
   9. RESPONSIVE
══════════════════════════════════════════════ */
@media(max-width:640px) {
  .wf-grid     { grid-template-columns: 1fr; }
  .wf-tpl-grid { grid-template-columns: 1fr; }
  .wf-builder  { max-width: 100vw; border-radius: 14px; }
  .wf-stats    { flex-direction: column; }
  .wf-rule-row { flex-direction: column; align-items: stretch; }
  .wf-rule-row .wf-select, .wf-rule-row .wf-input { width: 100%; }
}
