/* CleanForm form builder — Logic & Calculations tab (Clappia-style) */

.cf-logic-root {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #0f172a;
}

.cf-logic-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.02);
}

.cf-logic-tab {
  border: none;
  background: transparent;
  padding: 0.55rem 1rem;
  border-radius: 0.5rem 0.5rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
}

.cf-logic-tab.is-active {
  background: #fff;
  color: #0d9488;
  box-shadow: 0 -1px 0 #fff, inset 0 2px 0 #0d9488;
}

.cf-logic-panel {
  display: none;
  padding: 1rem;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.cf-logic-panel.is-active {
  display: block;
}

.cf-logic-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px dashed #99f6e4;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, rgba(204, 251, 241, 0.35), rgba(240, 253, 250, 0.6));
}

.cf-logic-quick__label {
  width: 100%;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0f766e;
}

.cf-logic-quick button {
  border: 1px solid #5eead4;
  background: #fff;
  color: #115e59;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.cf-logic-quick button:hover {
  background: #ccfbf1;
}

.cf-logic-section {
  margin-bottom: 1.25rem;
}

.cf-logic-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
}

.cf-logic-section p {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: #64748b;
}

.cf-logic-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  background: #fff;
}

.cf-logic-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

@media (max-width: 900px) {
  .cf-logic-row {
    grid-template-columns: 1fr;
  }
}

.cf-logic-row label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  display: block;
  margin-bottom: 0.15rem;
}

.cf-logic-row select,
.cf-logic-row input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.45rem 0.55rem;
  font-size: 0.8125rem;
}

.cf-logic-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.cf-logic-btn {
  border: none;
  border-radius: 0.5rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.cf-logic-btn--primary {
  background: #0d9488;
  color: #fff;
}

.cf-logic-btn--ghost {
  background: #f1f5f9;
  color: #334155;
}

.cf-logic-btn--danger {
  background: #fee2e2;
  color: #b91c1c;
}

.cf-logic-save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
}

.cf-logic-save-bar .cf-logic-status {
  font-size: 0.8125rem;
  color: #64748b;
}

.cf-logic-empty {
  padding: 1.5rem;
  text-align: center;
  color: #94a3b8;
  font-size: 0.875rem;
  border: 1px dashed #cbd5e1;
  border-radius: 0.75rem;
}

.cf-logic-builder-host {
  position: relative;
}

.cf-logic-builder-host.cf-logic-fields-hidden > main,
.cf-logic-builder-host.cf-logic-fields-hidden [data-cf-builder-main] {
  display: none !important;
}

.cf-logic-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 99999;
  background: #0f766e;
  color: #fff;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.cf-logic-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.cf-logic-card--calc {
  border-color: #99f6e4;
  background: linear-gradient(135deg, rgba(240, 253, 250, 0.9), #fff);
}

.cf-logic-calc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.cf-logic-calc-num {
  font-size: 0.72rem;
  font-weight: 800;
  color: #0d9488;
  background: #ccfbf1;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.cf-logic-row--calc {
  grid-template-columns: minmax(140px, 1fr) 2fr auto !important;
}

.cf-logic-formula-wrap {
  display: grid;
  gap: 0.35rem;
}

.cf-logic-formula-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.cf-logic-formula-chip {
  border: 1px solid #5eead4;
  background: #fff;
  color: #115e59;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.cf-logic-formula-chip:hover {
  background: #ccfbf1;
}

.cf-logic-formula-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.cf-logic-formula-presets__label {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
}

.cf-logic-formula-presets button {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.cf-logic-formula-hint {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0.35rem 0 0;
}

.cf-access-modes {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.cf-access-mode {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  flex-direction: row !important;
  font-weight: 600;
}

.cf-access-mode input {
  width: auto;
}

.cf-access-picks select {
  width: 100%;
  min-height: 120px;
  margin-top: 0.35rem;
}

.cf-logic-quick--inline {
  margin-bottom: 0.75rem;
}

.cf-test-fill-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99990;
  background: linear-gradient(90deg, #78350f, #b45309);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.cf-test-fill-bar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.55rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.cf-test-fill-bar__badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.cf-test-fill-bar__text {
  flex: 1;
  font-size: 0.82rem;
  opacity: 0.92;
}

.cf-test-fill-bar__actions {
  display: flex;
  gap: 0.5rem;
}

.cf-test-fill-bar__btn {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.cf-test-fill-bar__btn--primary {
  background: #fff;
  color: #92400e;
  border-color: #fff;
}

.cf-test-fill-success {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #92400e;
}

.cf-test-fill-success__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

body:has(#cf-test-fill-bar) {
  padding-top: 52px;
}
