/*
 * The look of applicationbuilder.frontend, without React: the tokens of Corporater's design
 * system (@corpo/design-system theme.css) and the app's semantic tokens (tokens.css), with the
 * shapes of its components written as plain CSS.
 */
:root {
  /* the design system's ramps */
  --neutral-10: #17191c;
  --neutral-40: #5c6470;
  --neutral-60: #8f97a3;
  --neutral-75: #b9bec6;
  --neutral-85: #d5d8dd;
  --neutral-95: #f1f2f4;
  --neutral-98: #f9fafa;
  --primary-18: #002e5c;
  --primary-25: #004080;
  --primary-40: #0066cc;
  --primary-85: #b2d9ff;
  --primary-92: #d6ebff;
  --primary-96: #ebf5ff;

  /* semantic tokens, as applicationbuilder.frontend names them */
  --background: var(--neutral-98);
  --foreground: var(--neutral-10);
  --foreground-subtle: #475569;
  --foreground-faint: var(--neutral-60);
  --card: #fff;
  --primary: var(--primary-18);
  --primary-hover: var(--primary-25);
  --secondary: var(--primary-96);
  --secondary-hover: var(--primary-92);
  --muted: var(--neutral-98);
  --muted-foreground: var(--neutral-40);
  --accent: var(--neutral-95);
  --border: var(--neutral-85);
  --input: #79879c;
  --ring: var(--primary);
  --destructive: #c2290a;
  --destructive-hover: #a11b00;
  --destructive-soft: #feebe7;
  --destructive-soft-foreground: #a11b00;
  --destructive-soft-border: #fbc2b6;
  --success: #17825e;
  --success-soft: #f2fdf9;
  --success-soft-foreground: #0e4e39;
  --success-soft-border: #a6d9c8;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-soft-foreground: #b45309;
  --warning-soft-border: #fde68a;
  --info: #0e7490;
  --info-soft: #ecfeff;
  --info-soft-foreground: #155e75;
  --info-soft-border: #a5f3fc;
  --artifact-folder: #eab308;
  --artifact-model: #3b82f6;
  --highlight: #f08c00;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --shadow-elev-1: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-elev-2: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-elev-3: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-elev-5: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --font-sans: "Roboto", system-ui, "Segoe UI", sans-serif;
  --font-mono: "Fira Code", "Fira Mono", Consolas, Monaco, monospace;
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --topbar-height: 48px;

  /* the names the pages used before, kept as aliases */
  --navy: var(--primary);
  --ink: var(--foreground);
  --line: var(--border);
  --bg: var(--background);
  --ok: var(--success);
  --bad: var(--destructive);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/20px var(--font-sans);
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--foreground); }
h2 { font-size: 20px; line-height: 24px; }
h3 { font-size: 15px; line-height: 20px; }
h4 { font-size: 13px; line-height: 18px; }
a { color: var(--primary-40); }
code, pre, .mono { font-family: var(--font-mono); font-size: 12px; }

.icon { flex: none; width: 1em; height: 1em; vertical-align: -0.15em; }

/* ---- top bar: the design system's Topbar ------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--topbar-height);
  padding: 8px 24px 8px 12px;
  background: var(--primary);
  color: var(--neutral-98);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.brand { display: flex; align-items: center; gap: 12px; height: 100%; padding: 0 4px; color: inherit; text-decoration: none; transition: opacity var(--duration-base) ease; }
.brand:hover { opacity: 0.85; }
.brand img { height: 100%; width: auto; display: block; }
.brand .product { font-size: 15px; font-weight: 500; padding-left: 12px; border-left: 1px solid rgb(255 255 255 / 0.3); white-space: nowrap; }
.topbar nav { display: flex; gap: 2px; height: 100%; align-items: center; }
.topbar nav a { color: rgb(255 255 255 / 0.85); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: var(--radius-md); transition: background var(--duration-fast) ease; }
.topbar nav a:hover { background: rgb(255 255 255 / 0.1); color: #fff; }
.topbar nav a.active { background: rgb(255 255 255 / 0.16); color: #fff; font-weight: 500; }
.topbar .user { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 13px; color: rgb(255 255 255 / 0.85); }
/* by id, to outrank the general field style: a field on the navy bar is drawn into it */
.topbar #user-id { width: 140px; padding: 4px 8px; font: inherit; color: #fff; background: rgb(255 255 255 / 0.1); border: 1px solid rgb(255 255 255 / 0.3); border-radius: var(--radius-md); }
.topbar #user-id:focus { outline: none; border-color: #fff; background: rgb(255 255 255 / 0.16); box-shadow: none; }

/* ---- layout and surfaces -------------------------------------------------------------------- */

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}
.card > h2, .card > h3 { margin-bottom: 12px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.muted { color: var(--muted-foreground); }
.small { font-size: 12px; line-height: 16px; }
p { margin: 0 0 8px; }

/* ---- buttons: primary, outline (secondary), ghost --------------------------------------------- */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font: 600 14px/20px var(--font-sans);
  white-space: nowrap;
  color: #fff;
  background: var(--primary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast);
}
button:hover:not(:disabled) { background: var(--primary-hover); }
button:active:not(:disabled) { transform: scale(0.98); }
button:focus-visible { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ring); }
button:disabled { background: var(--muted-foreground); cursor: not-allowed; opacity: 0.55; }

button.secondary { color: var(--foreground-subtle); background: var(--card); border-color: var(--border); }
button.secondary:hover:not(:disabled) { background: var(--card); border-color: var(--input); color: var(--foreground); }
button.secondary:disabled { background: var(--card); opacity: 0.4; }

button.ghost { color: var(--muted-foreground); background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--accent); color: var(--foreground); }
button.ghost:disabled { background: transparent; opacity: 0.35; }

button.danger { color: var(--destructive); background: transparent; }
button.danger:hover:not(:disabled) { background: rgb(194 41 10 / 0.1); }

button.small { padding: 6px 12px; font-size: 12px; font-weight: 700; line-height: 16px; }
button.icon-only { padding: 6px; font-size: 16px; line-height: 16px; }
button .icon { font-size: 16px; }
button.small .icon { font-size: 14px; }

/* ---- form fields ------------------------------------------------------------------------- */

input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  font: 400 14px/20px var(--font-sans);
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--input);
  border-radius: var(--radius-lg);
  padding: 7px 10px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px rgb(0 46 92 / 0.2); }
input:disabled, select:disabled, textarea:disabled { background: var(--muted); color: var(--muted-foreground); opacity: 0.7; }
input::placeholder, textarea::placeholder { color: var(--foreground-faint); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; vertical-align: -3px; }
label { color: var(--foreground-subtle); }

/* ---- badges: the design system's Chip --------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted-foreground);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 999px;
}
.badge.warn, .badge.running { color: var(--warning-soft-foreground); background: var(--warning-soft); border-color: var(--warning-soft-border); }
.badge.ended, .badge.ok { color: var(--success-soft-foreground); background: var(--success-soft); border-color: var(--success-soft-border); }
.badge.editing { color: var(--primary); background: var(--secondary); border-color: var(--primary-85); }
.badge.archived { color: var(--muted-foreground); background: var(--muted); border-color: var(--border); }

.status { font-weight: 600; }
.status.ok { color: var(--success); }
.status.bad { color: var(--destructive); }

/* ---- alerts ------------------------------------------------------------------------------- */

.message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid;
  border-radius: var(--radius-lg);
}
.message > .icon { font-size: 18px; margin-top: 1px; }
.message.ok { color: var(--success-soft-foreground); background: var(--success-soft); border-color: var(--success-soft-border); }
.message.bad { color: var(--destructive-soft-foreground); background: var(--destructive-soft); border-color: var(--destructive-soft-border); }
.message.info { color: var(--info-soft-foreground); background: var(--info-soft); border-color: var(--info-soft-border); }
.message button { margin-left: auto; }

/* ---- tables ------------------------------------------------------------------------------- */

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { text-align: left; padding: 8px; border-bottom: 1px solid var(--accent); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }

pre {
  margin: 0;
  padding: 12px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 300px;
}

/* ---- the render and process-model pages ----------------------------------------------------- */

#drop { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 24px; text-align: center; color: var(--muted-foreground); background: var(--card); }
#drop.over { border-color: var(--primary); color: var(--primary); background: var(--secondary); }

#diagram { overflow: auto; min-height: 120px; }
#diagram svg { max-width: none; }
#diagram .bpmn-element { cursor: pointer; }
#diagram .bpmn-element:hover { filter: drop-shadow(0 0 3px var(--primary)); }
#diagram .bpmn-element.selected { filter: drop-shadow(0 0 4px var(--highlight)) drop-shadow(0 0 2px var(--highlight)); }
