/* Rules below are scoped one of two ways, and the difference matters.

   .obsidian-local-rest-api-content is added to each setting item this plugin
   fills with its own block content (see prepareCustomContent in src/main.ts).
   Anything scoped to it follows that content wherever the item is rendered --
   including onto the Certificates and Advanced settings pages, which the
   declarative settings framework renders into their own SettingPage container
   rather than as descendants of the settings tab.

   .obsidian-local-rest-api-settings is added to the settings tab's own
   containerEl, so rules scoped to it reach only the top-level page. Use it
   only for framework-rendered elements that this plugin cannot class itself. */

/* .setting-item lays its children out as a flex row (name/desc left, control
   right). Block content written into one needs this, or every top-level child
   -- headings, tables, paragraphs -- becomes a flex item sitting side-by-side
   with its siblings instead of stacking. */
div.setting-item.obsidian-local-rest-api-content {
  display: block;
}

div.obsidian-local-rest-api-content div.api-key-display {
  margin-bottom: 20px;
}

div.obsidian-local-rest-api-content pre {
  font-size: 0.8em;
  padding: 10px 20px;
  margin: 10px 25px;
  background-color: var(--background-modifier-cover);
  font-family: monospace;
  user-select: all;
}

div.obsidian-local-rest-api-content p {
  padding: 0px 15px;
}

/* A value the user is expected to copy, sat next to its copy button. The pre
   carries the margin the standalone rule above would otherwise apply, so that
   the row lines up with surrounding blocks rather than the button hanging off
   the end of one. */
div.obsidian-local-rest-api-content div.copyable-value {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 25px;
}

div.obsidian-local-rest-api-content div.copyable-value pre {
  flex: 1 1 auto;
  /* Without this a long key refuses to shrink and pushes the button out of
     the panel, since flex items floor at their content width by default. */
  min-width: 0;
  margin: 0;
  overflow-x: auto;
}

/* Copyable URLs inside the api-urls tables. The standalone copyable-value
   margin above is sized for block content sitting directly in a settings
   panel; inside a table cell the cell's own padding already provides the
   indent, so the full margin would double it. */
div.obsidian-local-rest-api-content table.api-urls td.url div.copyable-value {
  margin: 4px 0;
}

/* The copyable-value variant for a setting item's control slot (the API key
   row on the main page). Unlike .copyable-value it cannot be scoped to
   .obsidian-local-rest-api-content: that class turns the setting item into a
   block layout, which would destroy the name/desc-left, control-right row
   this variant exists to sit inside. */
div.obsidian-local-rest-api-settings div.inline-copyable-value {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

div.obsidian-local-rest-api-settings div.inline-copyable-value pre {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  font-size: 0.8em;
  padding: 6px 10px;
  background-color: var(--background-modifier-cover);
  font-family: monospace;
  user-select: all;
}

div.obsidian-local-rest-api-content div.certificate-expired {
  padding: 10px 20px;
  border: 2px solid #ff0000;
}

div.obsidian-local-rest-api-content div.certificate-expiring-soon {
  padding: 10px 20px;
  border: 2px solid #ffff00;
}

div.obsidian-local-rest-api-content div.certificate-regeneration-recommended {
  padding: 10px 20px;
  border: 2px solid #ffff00;
}

div.obsidian-local-rest-api-content table.api-urls tr {
  width: 100%;
}

div.obsidian-local-rest-api-content table.api-urls th,
div.obsidian-local-rest-api-content table.api-urls td {
  padding: 5px 25px;
}

div.obsidian-local-rest-api-content table.api-urls tr.disabled td.name,
div.obsidian-local-rest-api-content table.api-urls tr.disabled td.url {
  text-decoration: line-through;
}

div.obsidian-local-rest-api-settings div.setting-item-control {
  min-width: 50%;
}

/* Framework-rendered controls cannot be given a class of our own, so this only
   reaches textareas on the top-level page. The certificate and key textareas
   live on the Certificates page and therefore keep the framework's own sizing;
   widening those would mean a selector broad enough to restyle every other
   plugin's settings, which is not worth it. */
div.obsidian-local-rest-api-settings textarea {
  width: 100%;
}
