/* Shared feedback/issue register component -- self-contained styling under
   the .freg root class, so it never depends on (or leaks into) a host app's
   own generic element selectors. Every color/spacing value is a --freg-*
   custom property with a fallback equal to FinanceTracker's original
   hardcoded literal, so FinanceTracker needs zero extra CSS to look like it
   did before this was extracted. A host with its own theme (e.g. IronLog's
   dark palette) maps its own tokens onto these --freg-* names once, in its
   own stylesheet, rather than editing this file. */

.freg {
  font-family: var(--freg-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  color: var(--freg-text, #1f2430);
  /* Real bug, 2026-09-05: .freg never set its own background, only
     individual widgets inside it did (.freg-btn, .freg-page-modal, etc).
     That was invisible as long as every host page happened to have a
     light background too (FinanceTracker) OR fully remapped --freg-* to
     match its own dark theme (IronLog). The moment an app removed its
     dark remapping to "look like FinanceTracker" (Topdeck register #12)
     but sits on a DARK page, --freg-text fell back to its dark literal
     while the page behind bare text (anything not inside a .freg-btn/
     card element) stayed dark -- dark text on a dark page, unreadable.
     Setting it here makes .freg a genuinely self-contained light panel
     regardless of the host page's own background -- a no-op for
     FinanceTracker (already #fff on #fff) and for any app still mapping
     --freg-bg to its own dark surface color. */
  background: var(--freg-bg, #fff);
}

.freg-hint {
  color: var(--freg-text-dim, #8b91a1);
  font-size: 12px;
}

.freg-btn {
  background: var(--freg-bg, #fff);
  border: 1px solid var(--freg-border, #e5e7eb);
  color: var(--freg-text, #1f2430);
  border-radius: var(--freg-radius, 6px);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.freg-btn:hover { background: var(--freg-bg-hover, #f8f9fc); }
.freg-btn-primary {
  background: var(--freg-accent, #4d7cfe);
  border-color: var(--freg-accent, #4d7cfe);
  color: var(--freg-accent-text, #fff);
  font-weight: 700;
}
.freg-btn-primary:hover { background: var(--freg-accent-hover, #3d6ae0); }

.freg-link-btn {
  background: none;
  border: none;
  color: var(--freg-accent, #4d7cfe);
  padding: 0;
  font-size: 13px;
  cursor: pointer;
}
.freg-link-btn:hover { text-decoration: underline; }

.freg-add-form { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.freg-add-form input,
.freg-add-form select {
  flex: 1;
  min-width: 160px;
}
.freg-add-attach-label {
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 160px;
  font-size: 13px; color: var(--freg-text-dim, #8b91a1); white-space: nowrap;
}
.freg-add-attach-label input[type="file"] { flex: 1; min-width: 0; font-size: 12px; }

.freg input[type="text"],
.freg select,
.freg input[type="file"] {
  background: var(--freg-bg, #fff);
  border: 1px solid var(--freg-border, #e5e7eb);
  color: var(--freg-text, #1f2430);
  border-radius: var(--freg-radius-sm, 4px);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}

.freg-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.freg-filter-label { font-size: 13px; color: var(--freg-text-secondary, #4d556b); display: flex; align-items: center; gap: 6px; }

.freg-table-wrap { overflow-x: auto; }
.freg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.freg-table th, .freg-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--freg-border-light, #eceef2);
  vertical-align: top;
}
.freg-table th { color: var(--freg-text-dim, #8b91a1); font-weight: 600; white-space: nowrap; }
.freg-table th.freg-sortable { cursor: pointer; user-select: none; }
.freg-table th.freg-sortable:hover { color: var(--freg-text-secondary, #4d556b); }
.freg-table td input[type="text"] { width: 100%; }

.freg-text-preview {
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
  border-radius: var(--freg-radius-sm, 4px);
  padding: 4px;
  margin: -4px;
}
.freg-text-preview:hover { background: var(--freg-bg-hover, #f8f9fc); }
.freg-text-empty { color: var(--freg-text-dim, #8b91a1); font-style: italic; }

.freg-text-modal-input {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: var(--freg-bg, #fff);
  border: 1px solid var(--freg-border, #e5e7eb);
  color: var(--freg-text, #1f2430);
  border-radius: var(--freg-radius-sm, 4px);
  padding: 8px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

.freg-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--freg-overlay, rgba(0,0,0,0.4));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.freg-modal-overlay.freg-hidden { display: none; }
.freg-modal {
  background: var(--freg-bg, #fff);
  padding: 24px;
  border-radius: var(--freg-radius-lg, 10px);
  width: min(480px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.freg-modal h3 { margin: 0; font-size: 16px; }
.freg-modal-actions { display: flex; justify-content: flex-end; }

/* ---- mountModal(): the whole register as a page-level overlay, for a
   host that wants "feedback as a popup over the current screen" instead of
   a dedicated tab/section -- see mountModal()'s own comment in the JS for
   why this solves "return to where you were" for free (you never left). ---- */
.freg-page-modal-overlay {
  position: fixed; inset: 0; background: var(--freg-overlay, rgba(0,0,0,0.4));
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.freg-page-modal {
  position: relative; background: var(--freg-bg, #fff);
  border-radius: var(--freg-radius-lg, 10px);
  width: min(1100px, 95vw); max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.freg-page-modal-content { padding: 24px; overflow-y: auto; }
.freg-page-modal-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
  border-radius: 50%; border: none; background: var(--freg-bg-hover, #f3f4f6);
  color: var(--freg-text, #1f2430); font-size: 18px; line-height: 1; cursor: pointer; z-index: 1;
}
.freg-page-modal-close:hover { background: var(--freg-border, #e5e7eb); }

.freg-attach-list { display: flex; flex-wrap: wrap; gap: 12px; }
.freg-attach-thumb { position: relative; width: 90px; }
.freg-attach-thumb img {
  width: 90px; height: 90px; object-fit: cover; border-radius: var(--freg-radius-sm, 6px);
  border: 1px solid var(--freg-border, #e5e7eb); cursor: pointer; display: block;
}
.freg-attach-thumb .freg-attach-remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--freg-danger, #c94b3f); color: #fff; border: none;
  cursor: pointer; font-size: 12px; line-height: 1; padding: 0;
}
.freg-attach-thumb .freg-attach-filename {
  font-size: 11px; color: var(--freg-text-dim, #8b91a1); margin-top: 4px; word-break: break-all;
}
.freg-attach-thumb-file .freg-attach-file-icon {
  width: 90px; height: 90px; border-radius: var(--freg-radius-sm, 6px);
  border: 1px solid var(--freg-border, #e5e7eb); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  background: var(--freg-bg, #f8f9fc);
}

/* ---- responsive: below the breakpoint, each row becomes a stacked card
   (classic CSS-only responsive-table technique -- no JS branching needed
   for mobile vs desktop, same markup renders both ways). ---- */
@media (max-width: 700px) {
  .freg-table-wrap { overflow-x: visible; }
  .freg-table thead { position: absolute; left: -9999px; top: -9999px; }
  .freg-table, .freg-table tbody, .freg-table tr, .freg-table td { display: block; width: 100%; }
  .freg-table tr {
    border: 1px solid var(--freg-border, #e5e7eb);
    border-radius: var(--freg-radius, 6px);
    margin-bottom: 12px;
    padding: 4px 10px;
  }
  .freg-table td {
    border-bottom: 1px solid var(--freg-border-light, #eceef2);
    padding: 8px 0 8px 42%;
    position: relative;
    min-height: 20px;
  }
  .freg-table td:last-child { border-bottom: none; }
  .freg-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 38%;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--freg-text-dim, #8b91a1);
  }
  .freg-table td[data-label=""]::before { content: none; }
  .freg-add-form { flex-direction: column; }
  .freg-add-form input, .freg-add-form select, .freg-add-form button { min-width: 0; width: 100%; }
}
