/* Text expansions (espanso import) — scoped to .espanso- / .esp- */

.espanso-dialog {
  max-width: min(960px, calc(100% - 24px));
  width: calc(100% - 24px);
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.espanso-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.espanso-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  padding: 0;
  margin: 0;
}

.espanso-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 1rem 1.1rem 0.5rem;
}

.espanso-foot {
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.espanso-subtitle {
  margin: 0.25rem 0 0;
  color: var(--dim);
  font-size: 0.92rem;
}

.espanso-privacy {
  font-size: 0.88rem;
  color: var(--dim);
  margin: 0.75rem 0;
  line-height: 1.45;
}

.esp-drop {
  display: block;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  margin: 0.5rem 0;
}

.esp-drop.esp-drag {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
}

.esp-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.esp-drop:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.esp-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
  align-items: center;
}

.esp-file-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  font-size: 0.88rem;
}

.esp-file-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.esp-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.esp-badge.ok { border-color: #3a8f5c; }
.esp-badge.partial { border-color: #c9a227; }
.esp-badge.error { border-color: #c44; }
.esp-badge.empty { color: var(--dim); }
.esp-badge.not-match-file { color: var(--dim); }

.esp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.esp-toolbar .chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--bg);
}

.esp-table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0 1rem;
}

table.esp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.esp-table th,
.esp-table td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.5rem;
  vertical-align: top;
  text-align: left;
}

.esp-table th {
  background: var(--surface-2);
  cursor: pointer;
  white-space: nowrap;
}

.esp-table th[aria-sort] {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.esp-table tr.esp-dup-row {
  border-left: 3px solid var(--accent);
}

.esp-trigger {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.esp-flag {
  display: inline-block;
  font-size: 0.72rem;
  margin: 0.1rem 0.15rem 0.1rem 0;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: default;
}

.esp-flag.dup-cross {
  border-color: #c9a227;
  cursor: pointer;
}

.esp-flag.dup-same {
  color: var(--dim);
}

.esp-flag.secret {
  border-color: #c44;
}

.esp-replace-preview {
  white-space: pre-wrap;
  word-break: break-word;
}

.esp-replace-preview.esp-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

.esp-exports {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--surface);
  z-index: 2;
}

.espanso-hint .btn {
  margin-left: 0.35rem;
  vertical-align: baseline;
}

.esp-yaml-pre {
  max-height: 12rem;
  overflow: auto;
  font-size: 0.8rem;
  padding: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (max-width: 760px) {
  table.esp-table thead {
    display: none;
  }

  table.esp-table,
  table.esp-table tbody,
  table.esp-table tr,
  table.esp-table td {
    display: block;
    width: 100%;
  }

  table.esp-table tr {
    margin-bottom: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.35rem 0.5rem;
  }

  table.esp-table td {
    border: none;
    padding: 0.35rem 0;
  }

  table.esp-table td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--dim);
    margin-bottom: 0.15rem;
  }

  .esp-toolbar .chip,
  .espanso-dialog .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .espanso-dialog .btn.sm {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 600px) {
  .espanso-dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }

  .espanso-form {
    max-height: none;
    height: 100%;
  }

  /* the export bar is tall on phones (buttons + scope + checkbox): do not let it cover the cards */
  .esp-exports {
    position: static;
  }
}

@media print {
  body.printing .esp-print-doc {
    color: #000;
    background: #fff;
    font-size: 9pt;
    padding: 0;
  }

  body.printing .esp-print-doc h1 {
    font-size: 14pt;
    margin: 0 0 8pt;
  }

  body.printing .esp-print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }

  body.printing .esp-print-table th,
  body.printing .esp-print-table td {
    border: 1px solid #333;
    padding: 3pt 4pt;
    vertical-align: top;
  }

  body.printing .esp-print-table thead {
    display: table-header-group;
  }

  body.printing .esp-print-table tr {
    break-inside: avoid;
  }

  body.printing .esp-print-table .esp-print-trigger {
    font-family: ui-monospace, monospace;
    font-size: 8.5pt;
  }

  body.printing .esp-print-foot {
    margin-top: 10pt;
    font-size: 8pt;
    color: #444;
  }
}
