/* Editor de texto online — plain notepad (fullscreen workspace) */

.edt-app {
  --edt-pad-y: 16px;
  --edt-pad-x: 18px;
  --edt-lh: 1.55;
  --edt-font: 16px;
  --edt-gutter: 3.25rem;

  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: min(72vh, 820px);
  height: 100%;
  margin: 0;
  border-radius: 0;
  background: var(--dica-surface);
  color: var(--dica-body);
  overflow: hidden;
  box-shadow: none;
}

/* Standalone (non-fullscreen) safety */
.article .edt-app {
  border-radius: 16px;
  margin-bottom: 28px;
  box-shadow: 0 0 0 1px var(--dica-border), 0 12px 32px var(--dica-shadow);
  min-height: min(68vh, 760px);
}

/* ---- Toolbar ---- */
.edt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--dica-border);
  background: var(--dica-surface-soft);
  flex: 0 0 auto;
}

.edt-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.edt-group-view {
  padding-left: 2px;
}

.edt-toolbar-spacer {
  flex: 1 1 12px;
  min-width: 8px;
}

.edt-btn {
  appearance: none;
  border: 1px solid var(--dica-border);
  background: var(--dica-surface);
  color: var(--dica-ink);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.edt-btn:hover {
  border-color: var(--dica-action-border);
  background: var(--dica-action-soft);
}

.edt-btn:active {
  transform: translateY(1px);
}

.edt-btn:focus-visible {
  outline: none;
  border-color: var(--dica-action);
  box-shadow: 0 0 0 3px var(--dica-action-soft);
}

.edt-btn-primary {
  background: var(--dica-action);
  border-color: var(--dica-action);
  color: #fff;
}

.edt-btn-primary:hover {
  filter: brightness(1.06);
  background: var(--dica-action);
  color: #fff;
}

.edt-btn.is-active {
  background: var(--dica-action-soft);
  border-color: var(--dica-action-border);
  color: var(--dica-action);
  box-shadow: inset 0 0 0 1px var(--dica-action-border);
}

.edt-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.edt-btn-icon {
  min-width: 2.35rem;
  padding-left: 10px;
  padding-right: 10px;
  font-variant-numeric: tabular-nums;
}

.edt-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}

.edt-filename {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dica-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--dica-surface);
  border: 1px solid var(--dica-border);
}

.edt-status {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--dica-muted);
  white-space: nowrap;
}

.edt-status.is-dirty {
  color: var(--dica-warning, #b45309);
}

.edt-status.is-saved {
  color: var(--dica-success, #15803d);
}

/* ---- Restore banner ---- */
/* ---- Find bar ---- */
.edt-findbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--dica-border);
  background: var(--dica-surface);
  flex: 0 0 auto;
}

.edt-findbar[hidden] {
  display: none !important;
}

.edt-find-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dica-muted);
}

.edt-find-input {
  flex: 1 1 160px;
  min-width: 120px;
  max-width: 320px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--dica-border);
  background: var(--dica-surface-soft);
  color: var(--dica-ink);
  font: inherit;
  font-size: 0.9rem;
}

.edt-find-input:focus {
  outline: none;
  border-color: var(--dica-action);
  box-shadow: 0 0 0 3px var(--dica-action-soft);
}

.edt-find-count {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--dica-muted);
  min-width: 4.5rem;
  font-variant-numeric: tabular-nums;
}

.edt-find-case {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dica-body);
  cursor: pointer;
  user-select: none;
}

.edt-restore {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--dica-action-border);
  background: var(--dica-action-soft);
  color: var(--dica-ink);
  font-size: 0.88rem;
  line-height: 1.4;
  flex: 0 0 auto;
}

.edt-restore.is-visible {
  display: flex;
}

.edt-restore strong {
  color: var(--dica-action);
}

.edt-restore-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

/* ---- Editor stage ---- */
.edt-stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-height: 0; /* critical for flex child fill */
  background: var(--dica-surface);
}

.edt-stage.is-dragover::after {
  content: "Solte o arquivo para abrir";
  position: absolute;
  inset: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 2px dashed var(--dica-action);
  background: color-mix(in srgb, var(--dica-action) 12%, var(--dica-surface));
  color: var(--dica-action);
  font-weight: 800;
  font-size: 1rem;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--dica-action-soft);
}

.edt-linenos {
  flex: 0 0 auto;
  width: var(--edt-gutter);
  align-self: stretch;
  padding: var(--edt-pad-y) 8px var(--edt-pad-y) 10px;
  margin: 0;
  border: 0;
  border-right: 1px solid var(--dica-border);
  background: var(--dica-surface-soft);
  color: var(--dica-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: calc(var(--edt-font) - 2px);
  font-weight: 500;
  line-height: var(--edt-lh);
  text-align: right;
  overflow: hidden;
  user-select: none;
  white-space: pre;
  tab-size: 2;
  box-sizing: border-box;
}

.edt-app[data-line-numbers="0"] .edt-linenos {
  display: none;
}

/* Wrapper so textarea can truly fill remaining height (textarea ignores flex grow) */
.edt-editor-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
}

.edt-textarea {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--edt-pad-y) var(--edt-pad-x);
  border: 0;
  resize: none;
  background: transparent;
  color: var(--dica-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--edt-font);
  font-weight: 400;
  line-height: var(--edt-lh);
  tab-size: 2;
  outline: none;
  box-sizing: border-box;
  caret-color: var(--dica-action);
  overflow: auto;
}

.edt-app[data-mono="1"] .edt-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: calc(var(--edt-font) - 0.5px);
}

.edt-app[data-wrap="0"] .edt-textarea {
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.edt-app[data-wrap="1"] .edt-textarea {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.edt-textarea::placeholder {
  color: var(--dica-muted);
  opacity: 0.9;
}

.edt-stage:focus-within {
  box-shadow: inset 0 0 0 2px var(--dica-action-soft);
}

/* empty hint (when truly empty, no placeholder-only) */
.edt-empty-hint {
  display: none;
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 1;
  max-width: min(420px, 90%);
  text-align: center;
  pointer-events: none;
  color: var(--dica-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px dashed var(--dica-border);
  background: color-mix(in srgb, var(--dica-surface-soft) 80%, transparent);
}

.edt-empty-hint strong {
  display: block;
  color: var(--dica-ink);
  font-size: 1rem;
  margin-bottom: 6px;
}

.edt-app.is-empty .edt-empty-hint {
  display: block;
}

.edt-app.is-empty .edt-stage:focus-within .edt-empty-hint {
  opacity: 0.28;
}

.edt-empty-keys {
  opacity: 0.85;
  font-size: 0.86em;
}

/* ---- Status bar ---- */
.edt-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 4px;
  padding: 8px 14px;
  border-top: 1px solid var(--dica-border);
  background: var(--dica-surface-soft);
  font-size: 0.8rem;
  color: var(--dica-body);
  flex: 0 0 auto;
}

.edt-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--dica-surface);
  border: 1px solid var(--dica-border);
  color: var(--dica-muted);
  font-weight: 600;
}

.edt-stat strong {
  color: var(--dica-ink);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.edt-stat-cursor {
  margin-left: auto;
}

.edt-stat-hint {
  color: var(--dica-muted);
  font-size: 0.74rem;
  font-weight: 600;
  opacity: 0.85;
}

/* ---- Toast ---- */
.edt-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--dica-ink);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 24px var(--dica-shadow);
  max-width: min(92vw, 420px);
  text-align: center;
}

.edt-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.edt-related {
  margin: 0 0 18px;
}

.edt-faq {
  margin-top: 28px;
}

.edt-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Fullscreen workspace: edge-to-edge tool */
body.is-fullscreen .fs-workspace {
  display: flex;
  flex-direction: column;
}

body.is-fullscreen .fs-workspace .edt-app {
  margin-bottom: 0;
  border-radius: 0;
  flex: 1 1 auto;
  min-height: min(72vh, 820px);
}

body.is-fullscreen .fs-workspace > .edt-app,
body.is-fullscreen .fs-workspace #edt-app {
  width: 100%;
}

@media (max-width: 900px) {
  .edt-stat-hint {
    display: none;
  }
}

@media (max-width: 900px) {
  .edt-hide-sm {
    display: none !important;
  }
}

@media (max-width: 720px) {
  .edt-app {
    --edt-pad-y: 14px;
    --edt-pad-x: 12px;
    --edt-gutter: 2.55rem;
    min-height: min(70vh, 720px);
  }

  .edt-toolbar {
    gap: 6px;
    padding: 10px 10px;
  }

  .edt-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .edt-btn-icon {
    min-width: 2.15rem;
  }

  .edt-filename {
    max-width: 110px;
    font-size: 0.74rem;
  }

  .edt-status {
    width: 100%;
    order: 20;
    font-size: 0.74rem;
  }

  .edt-meta {
    width: 100%;
    justify-content: space-between;
  }

  .edt-toolbar-spacer {
    display: none;
  }

  .edt-stat-cursor {
    margin-left: 0;
  }

  .edt-empty-hint {
    top: 38%;
    font-size: 0.86rem;
  }

  .edt-find-label {
    display: none;
  }
}

@media (max-width: 420px) {
  .edt-group-file .edt-btn:not(.edt-btn-primary):not(#edt-btn-sample) {
    padding-left: 9px;
    padding-right: 9px;
  }
}

html[data-theme="dark"] .edt-filename {
  background: var(--dica-surface-raised);
}

html[data-theme="dark"] .edt-stat {
  background: var(--dica-surface-raised);
}

html[data-theme="dark"] .edt-toast {
  background: var(--dica-surface-raised);
  color: var(--dica-ink);
  border: 1px solid var(--dica-border);
}

html[data-theme="dark"] .edt-empty-hint {
  background: color-mix(in srgb, var(--dica-surface-raised) 88%, transparent);
  border-color: var(--dica-border);
  color: var(--dica-body);
}

html[data-theme="dark"] .edt-empty-hint strong {
  color: var(--dica-ink);
}

html[data-theme="dark"] .edt-findbar {
  background: var(--dica-surface-soft);
}

html[data-theme="dark"] .edt-find-input {
  background: var(--dica-surface-raised);
  border-color: var(--dica-border);
  color: var(--dica-ink);
}

html[data-theme="dark"] .edt-linenos {
  background: var(--dica-surface-soft);
  color: var(--dica-muted);
  border-color: var(--dica-border);
}

html[data-theme="dark"] .edt-toolbar,
html[data-theme="dark"] .edt-stats {
  background: var(--dica-surface-soft);
}

@media (prefers-reduced-motion: reduce) {
  .edt-btn,
  .edt-toast {
    transition: none;
  }
}
