/* Nội dung › Văn bản của bạn on the user's server: a text's editor and the web page import (frontend/panel/content/user-texts/). */

/* The editor (read#52–#57; md:L46245–46527) in design system v3: the card, its parts in one column. */

.ut {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ut-scroll {
  position: relative;
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
}

.ut-body {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 120px;
}

.ut-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

.ut-card .field-label {
  margin: 0;
}

/* The bar: back, "Văn bản của bạn / <title>", the save state and "Delete text". */
.ut-bar {
  gap: 8px;
}

.ut-bar-title {
  flex: 1 1 auto;
  gap: 0;
  cursor: default;
}

.ut-bar-title:hover {
  background: none;
}

.ut-crumb {
  flex: none;
  color: var(--text-muted);
  white-space: nowrap;
}

.ut-crumb::after {
  content: "/";
  margin: 0 8px;
  color: var(--text-tertiary);
}

.ut-crumb-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ut-state {
  flex: none;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
}

.ut-delete {
  padding: 0 12px;
}

/* The language check's notice (read#55): a fact about the text, with the switch as its link. */
.ut-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--chip);
  color: var(--chip-text);
  font: 500 14px/20px var(--font);
  animation: ut-pulse 2s ease-in-out infinite;
}

.ut-switch {
  color: var(--accent-soft);
  font-weight: 700;
}

@keyframes ut-pulse {
  50% {
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ut-banner {
    animation: none;
  }
}

.ut-title-input {
  width: 100%;
}

.ut-source {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: -6px 0 0;
  font: 500 13px/18px var(--font);
}

.ut-source-link {
  min-width: 0;
  overflow: hidden;
  color: var(--accent-soft);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ut-source-link:hover {
  text-decoration: underline;
}

.ut-text-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: -8px;
}

.ut-upload-file {
  padding: 0 14px;
}

.ut-upload-file .icon {
  width: 18px;
  height: 18px;
}

.ut-upload-file:disabled {
  background: var(--tonal);
  color: var(--text-disabled);
}

.ut-text {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 15px 17px;
  border: 1px solid var(--field-border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: 400 17px/1.9 var(--font);
  resize: none;
  overflow-y: auto;
}

.ut-text:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.ut-text::placeholder {
  color: var(--text-tertiary);
}

.ut-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  margin: -8px 0 0;
  color: var(--text-muted);
  font: 500 12px/16px var(--font);
}

.ut-meta > span {
  white-space: nowrap;
}

.ut-failed {
  margin: 0;
  color: var(--danger);
  font: 500 13px/18px var(--font);
}

.ut-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ut-start-button {
  padding: 0 24px;
}

/* While the text loads: the card's shape in grey. */
.ut-sk-label {
  width: 64px;
  height: 12px;
}

.ut-sk-field {
  height: 48px;
  border-radius: var(--radius-md);
}

.ut-sk-area {
  height: 320px;
  border-radius: 14px;
}

.ut-error {
  align-items: flex-start;
  gap: 8px;
}

.ut-error-text {
  margin: 0;
  color: var(--text);
  font: 600 15px/20px var(--font);
}

.ut-error-code {
  margin: 0 0 8px;
  color: var(--text-tertiary);
  font: 500 12px/16px var(--font);
}

@media (max-width: 600px) {
  .ut-body {
    padding: 16px 16px 96px;
  }

  .ut-card {
    gap: 12px;
    padding: 16px;
  }

  .ut-crumb,
  .ut-delete-label {
    display: none;
  }

  .ut-delete {
    width: 44px;
    padding: 0;
  }

  .ut-foot {
    padding-top: 0;
    border-top: 0;
  }

  .ut-start-button {
    width: 100%;
  }
}

/* The reader's Edit button on a user text (read#59; md:L1758–1781), the pencil alone on a phone. */
.rd-edit {
  min-height: 40px;
  margin-left: 10px;
  padding: 0 12px;
  font-size: 13px;
}

@media (max-width: 600px) {
  .btn-text.rd-edit {
    width: 36px;
    margin-left: 2px;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }

  .rd-edit-label {
    display: none;
  }
}

/* "Import Text" (import-dialog.js; read#65; the reference's ImportTextModal, im:L172–405) in design system v3:
   the page, three choice cards, the preview with its mini-map, then what Open does beside the buttons. */

.dialog:has(.import-text) {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog:has(.import-text)::backdrop {
  background: var(--scrim);
}

.dialog:has(.import-text) > form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 32px);
}

.dialog:has(.import-text) .dialog-title {
  grid-column: 1 / -1;
  margin: 0;
  padding: 16px 64px 16px 24px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: 700 17px/24px var(--font);
}

.import-text {
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  gap: 18px;
  min-height: 0;
  padding: 20px 24px;
  overflow-y: auto;
}

.import-text-close {
  position: absolute;
  top: 6px;
  right: 8px;
}

.import-text-page {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.import-text-page-words {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.import-text-page-title,
.import-text-page-address {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.import-text-page-title {
  font: 700 16px/22px var(--font);
}

.import-text-page-address {
  color: var(--text-muted);
  font: 500 13px/18px var(--font);
}

.import-text-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.import-text-source {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 64px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
}

.import-text-source:hover {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.import-text-source.is-chosen {
  background: var(--tonal);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.import-text-source.is-disabled {
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: default;
}

.import-text-source input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid var(--field-border);
  border-radius: 50%;
  background: var(--surface);
  appearance: none;
}

.import-text-source input:checked {
  border: 6px solid var(--accent);
}

.import-text-source input:disabled {
  border-color: var(--text-disabled);
}

.import-text-source input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.import-text-source-words {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.import-text-source-name {
  color: var(--text);
  font: 600 14px/20px var(--font);
}

.import-text-source-note {
  color: var(--text-muted);
  font: 500 12px/16px var(--font);
  text-wrap: balance;
}

.import-text-source.is-disabled .import-text-source-name,
.import-text-source.is-disabled .import-text-source-note {
  color: var(--text-disabled);
}

.import-text-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.import-text-panes {
  display: flex;
  height: clamp(160px, 32vh, 320px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.import-text-preview,
.import-text-map-text {
  padding: 16px 18px;
  font: 400 15px/1.8 var(--font);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.import-text-preview {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  color: var(--text);
}

.import-text-map {
  position: relative;
  flex-shrink: 0;
  width: 72px;
  overflow: hidden;
  border-left: 1px solid var(--line);
}

.import-text-map-scroll {
  position: relative;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.import-text-map-inner {
  position: relative;
  width: 100%;
}

.import-text-map-text {
  box-sizing: border-box;
  color: var(--text-tertiary);
  transform-origin: 0 0;
  user-select: none;
  pointer-events: none;
}

.import-text-map-view {
  position: absolute;
  left: 0;
  width: 100%;
  border-top: 1px solid var(--progress-fill);
  border-bottom: 1px solid var(--progress-fill);
  background: color-mix(in srgb, var(--progress-fill) 12%, transparent);
  pointer-events: none;
}

.import-text-note {
  display: flex;
  grid-column: 1;
  align-items: center;
  margin: 0;
  padding: 16px 0 16px 24px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font: 500 13px/18px var(--font);
  text-wrap: balance;
}

.dialog:has(.import-text) .dialog-actions {
  flex-wrap: nowrap;
  grid-column: 2;
  align-items: center;
  margin: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}

.dialog:has(.import-text):not(:has(.import-text-note)) .dialog-actions {
  grid-column: 1 / -1;
}

.dialog:has(.import-text) .dialog-actions .button {
  justify-content: center;
  min-width: 96px;
  height: auto;
  min-height: 44px;
  margin-bottom: var(--lip-px);
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-md);
  font: 600 14px/1 var(--font);
}

.dialog:has(.import-text) .dialog-actions .button:not(.primary) {
  background: var(--surface);
  color: var(--text-label);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.dialog:has(.import-text) .dialog-actions .button.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 var(--lip-px) 0 var(--block-lip);
}

.dialog:has(.import-text) .dialog-actions .button:active {
  transform: translateY(var(--lip-px));
  box-shadow: none;
}

@media (max-width: 600px) {
  .dialog:has(.import-text) {
    width: calc(100vw - 16px);
  }

  .dialog:has(.import-text) > form {
    grid-template-columns: minmax(0, 1fr);
  }

  .import-text {
    padding: 16px;
  }

  .import-text-choices {
    grid-template-columns: minmax(0, 1fr);
  }

  .import-text-note {
    grid-column: 1;
    padding: 12px 16px 0;
  }

  .dialog:has(.import-text) .dialog-actions {
    grid-column: 1;
    padding: 12px 16px 16px;
  }

  .dialog:has(.import-text):has(.import-text-note) .dialog-actions {
    border-top: 0;
  }

  .dialog:has(.import-text) .dialog-actions .button {
    flex: 1 1 0%;
  }
}

/* An image line of a page read in the reader on this device (local-reader.js; read#64). */
.reader-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}
