/**
 * ArchiMate Editor styling.
 *
 * Deliberately close to bpmn_editor's css/bpmn-editor.css so the two
 * modellers feel like one family of tools when used side by side on the
 * same site - see that file's own comments for the base rationale. Only
 * the lifecycle-status badge colours are new here.
 */

.archimate-editor {
  --archimate-editor-height: 640px;
  --archimate-editor-accent: #F0A500;
  --archimate-editor-border: #d8d8d8;
  --archimate-editor-header-bg: #1c1f26;
  --archimate-editor-header-fg: #f4f4f4;
  --archimate-editor-lifecycle-supported: #2e7d32;
  --archimate-editor-lifecycle-extended: #c77700;
  --archimate-editor-lifecycle-expired: #c0143c;
  --archimate-editor-lifecycle-retired: #8b0000;
  --archimate-editor-lifecycle-retired-fill: #f2b6b0;
  --archimate-editor-lifecycle-unknown: #767676;

  display: flex;
  flex-direction: column;
  border: 1px solid var(--archimate-editor-border);
  border-radius: 4px;
  overflow: hidden;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #ffffff;
}

.archimate-editor:fullscreen {
  --archimate-editor-height: 100vh;
  border-radius: 0;
}

.archimate-editor__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--archimate-editor-header-bg);
  color: var(--archimate-editor-header-fg);
  flex: 0 0 auto;
}

.archimate-editor__toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.archimate-editor__button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--archimate-editor-header-fg);
  background: transparent;
  border: 1px solid rgba(244, 244, 244, 0.35);
  border-radius: 3px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.archimate-editor__button:hover:not(:disabled) {
  border-color: var(--archimate-editor-accent);
  color: var(--archimate-editor-accent);
}

.archimate-editor__button:disabled {
  opacity: 0.35;
  cursor: default;
}

.archimate-editor__button--primary {
  background: var(--archimate-editor-accent);
  border-color: var(--archimate-editor-accent);
  color: #1c1f26;
  font-weight: 600;
}

.archimate-editor__button--primary:hover {
  filter: brightness(1.08);
}

/*
 * Unlike the other .archimate-editor__button modifiers (styled for the
 * dark toolbar), this one is used inside the white properties panel -
 * see js/archimate-properties-panel.js's buildDeleteButton() - so it
 * overrides colour/background/border completely rather than layering
 * on the toolbar's near-white default text colour, which would be
 * invisible against a white background.
 */
.archimate-editor__button--danger {
  color: var(--archimate-editor-lifecycle-expired);
  background: #ffffff;
  border: 1px solid var(--archimate-editor-lifecycle-expired);
}

.archimate-editor__button--danger:hover {
  color: #ffffff;
  background: var(--archimate-editor-lifecycle-expired);
}

/* Same "used inside the white properties panel" reasoning as
 * --danger above. */
.archimate-editor__button--secondary {
  color: #1c1f26;
  background: #ffffff;
  border: 1px solid var(--archimate-editor-border);
}

.archimate-editor__button--secondary:hover {
  border-color: var(--archimate-editor-accent);
  color: #8a5a00;
}

.archimate-editor__properties-layer-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.archimate-editor__properties-layer-buttons .archimate-editor__button {
  flex: 1 1 0;
}

.archimate-editor__properties-delete {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--archimate-editor-border);
}

.archimate-editor__save-status {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: rgba(244, 244, 244, 0.6);
  margin-left: 0.5rem;
}

.archimate-editor__save-status[data-state="saving"] {
  color: var(--archimate-editor-accent);
}

.archimate-editor__save-status[data-state="error"] {
  color: #ff6b6b;
}

.archimate-editor__read-only-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(244, 244, 244, 0.35);
  border-radius: 3px;
  color: rgba(244, 244, 244, 0.75);
}

.archimate-editor__body {
  position: relative;
  display: flex;
  height: var(--archimate-editor-height);
  min-height: 200px;
  flex: 1 1 auto;
}

.archimate-editor__canvas {
  flex: 1 1 auto;
  position: relative;
  background: #fafafa;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px);
  background-size: 16px 16px;
}

.archimate-editor__properties {
  flex: 0 0 300px;
  border-left: 1px solid var(--archimate-editor-border);
  background: #ffffff;
  overflow-y: auto;
  padding: 0.75rem;
  font-size: 0.85rem;
}

.archimate-editor__properties-empty {
  color: #888;
  font-style: italic;
}

.archimate-editor__properties h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  margin: 0 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--archimate-editor-border);
}

.archimate-editor__properties label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
  margin: 0.75rem 0 0.2rem;
}

.archimate-editor__properties input[type="text"],
.archimate-editor__properties textarea,
.archimate-editor__properties select {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--archimate-editor-border);
  border-radius: 3px;
}

.archimate-editor__app-search-results {
  border: 1px solid var(--archimate-editor-border);
  border-top: none;
  max-height: 160px;
  overflow-y: auto;
  border-radius: 0 0 3px 3px;
}

.archimate-editor__app-search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.45rem;
  background: #fff;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 0.82rem;
}

.archimate-editor__app-search-result:hover {
  background: #fdf3dc;
}

.archimate-editor__linked-app {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: #fdf3dc;
  border: 1px solid var(--archimate-editor-accent);
  border-radius: 3px;
  font-size: 0.82rem;
}

.archimate-editor__linked-app span {
  flex: 1 1 auto;
}

.archimate-editor__linked-app-open {
  flex: 0 0 auto;
  color: #1c1f26;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.archimate-editor__linked-app-open:hover {
  text-decoration: underline;
}

.archimate-editor__linked-app button {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: #a33;
  cursor: pointer;
  font-size: 0.78rem;
}

.archimate-editor__lifecycle-badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--archimate-editor-lifecycle-unknown);
}

.archimate-editor__lifecycle-badge[data-status="supported"] {
  background: var(--archimate-editor-lifecycle-supported);
}

.archimate-editor__lifecycle-badge[data-status="extended"] {
  background: var(--archimate-editor-lifecycle-extended);
}

.archimate-editor__lifecycle-badge[data-status="expired"] {
  background: var(--archimate-editor-lifecycle-expired);
}

.archimate-editor__lifecycle-badge[data-status="retired"] {
  background: var(--archimate-editor-lifecycle-retired);
}

.archimate-editor__linked-element,
.archimate-editor__linked-element * {
  cursor: pointer !important;
}

/* Applied directly to a linked Application Component shape on the
 * canvas (both editable and read-only) - see setElementLifecycleStyle()
 * in js/archimate-editor.js. Retired gets a dashed outline AND a red
 * fill tint so it reads as "inactive" rather than merely "at risk"
 * (expired/extended), even at a glance or for colourblind users.
 *
 * Targets direct children of .djs-visual specifically (rect/circle/
 * ellipse, not the descendant combinator) so this reaches every part
 * of the shape's own outline - including an Application Component's
 * two small "tabs" (see Renderer.js's _drawComponentTabs(), appended as
 * siblings of the base rect, not nested inside it) - while leaving the
 * type icon alone: appendIcon() wraps icon primitives in their OWN
 * nested <g>, one level deeper, so they never match a direct-child
 * selector and keep their normal colour regardless of lifecycle status. */
.archimate-js-element--lifecycle-expired .djs-visual > rect,
.archimate-js-element--lifecycle-expired .djs-visual > circle,
.archimate-js-element--lifecycle-expired .djs-visual > ellipse {
  stroke: var(--archimate-editor-lifecycle-expired) !important;
  stroke-width: 2.5px !important;
}

.archimate-js-element--lifecycle-retired .djs-visual > rect,
.archimate-js-element--lifecycle-retired .djs-visual > circle,
.archimate-js-element--lifecycle-retired .djs-visual > ellipse {
  stroke: var(--archimate-editor-lifecycle-retired) !important;
  stroke-width: 2.5px !important;
  stroke-dasharray: 6, 3 !important;
  fill: var(--archimate-editor-lifecycle-retired-fill) !important;
}

.archimate-js-element--lifecycle-extended .djs-visual > rect,
.archimate-js-element--lifecycle-extended .djs-visual > circle,
.archimate-js-element--lifecycle-extended .djs-visual > ellipse {
  stroke: var(--archimate-editor-lifecycle-extended) !important;
  stroke-width: 2.5px !important;
}

.archimate-editor__field-edit-link,
.archimate-editor__field-add-link,
.archimate-editor__add-new-link {
  margin-top: 0.4rem;
}

.archimate-editor__revision-banner {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #fdf3dc;
  border: 1px solid var(--archimate-editor-accent);
  border-radius: 3px;
  font-size: 0.85rem;
}

.archimate-editor__revision-message {
  color: #666;
  font-size: 0.8rem;
  margin: 0.15rem 0 0;
}

.archimate-editor__xml-textarea {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  white-space: pre;
}

.archimate-editor__noscript {
  padding: 1rem;
  color: #a33;
}
