/* ============================================================
   Legal Knowledge Hub Engine — Frontend CSS
   Brand: Roboto Slab / Roboto Condensed, gold #a8782e, burgundy #800020
   ============================================================ */

:root {
  --lkh-gold:       #a8782e;
  --lkh-gold-light: #c9a96e;
  --lkh-gold-pale:  #e0b05a;
  --lkh-burgundy:   #800020;
  --lkh-dark:       #161618;
  --lkh-text:       #1a1a2e;
  --lkh-muted:      #64748b;
  --lkh-bg:         #f8f7f4;
  --lkh-border:     #e2ddd8;
  --lkh-radius:     6px;
  --lkh-shadow:     0 2px 12px rgba(0,0,0,.08);
  --lkh-font-body:  'Roboto Slab', Georgia, serif;
  --lkh-font-ui:    'Roboto Condensed', 'Roboto', sans-serif;
  --lkh-transition: 0.22s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --lkh-bg:     #0f0f12;
    --lkh-text:   #e8e6e1;
    --lkh-border: #2a2a35;
    --lkh-muted:  #8a8a9a;
  }
}

/* ── READING PROGRESS BAR ─────────────────────────────────── */
.lkh-progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--lkh-burgundy), var(--lkh-gold));
  z-index: 9999;
  transition: width .1s linear;
}

/* ── ARTICLE TABS (convenie-tabs article variant) ─────────── */
.lkh-article-tabs {
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--lkh-border);
  border-radius: var(--lkh-radius);
  overflow: hidden;
  box-shadow: var(--lkh-shadow);
  font-family: var(--lkh-font-ui);
}

/* ── TAKEOUT LIST ─────────────────────────────────────────── */
.lkh-takeout-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lkh-takeout-list li {
  padding: .55rem 1rem .55rem 2rem;
  position: relative;
  border-bottom: 1px solid var(--lkh-border);
  font-size: .95rem;
  line-height: 1.55;
}
.lkh-takeout-list li:last-child { border-bottom: none; }
.lkh-takeout-list li::before {
  content: '→';
  color: var(--lkh-gold);
  position: absolute;
  left: .75rem;
  font-weight: 700;
}

/* ── ABSTRACT BADGES ──────────────────────────────────────── */
.lkh-abstract-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
}
.lkh-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .65rem;
  border-radius: 20px;
  font-size: .78rem;
  font-family: var(--lkh-font-ui);
  font-weight: 500;
  letter-spacing: .02em;
}
.lkh-badge--level  { background: var(--lkh-burgundy); color: #fff; }
.lkh-badge--type   { background: var(--lkh-gold);     color: #fff; }
.lkh-badge--time   { background: var(--lkh-border);   color: var(--lkh-text); }

/* ── RESOURCES LIST ───────────────────────────────────────── */
.lkh-resources-list {
  list-style: none;
  margin: 0; padding: 0;
}
.lkh-resource {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--lkh-border);
}
.lkh-resource:last-child { border-bottom: none; }
.lkh-resource-icon { font-size: 1.1rem; flex-shrink: 0; }
.lkh-resource a {
  color: var(--lkh-burgundy);
  text-decoration: none;
  font-weight: 500;
}
.lkh-resource a:hover { color: var(--lkh-gold); text-decoration: underline; }
.lkh-no-resources { color: var(--lkh-muted); font-style: italic; }

/* ── TABLE OF CONTENTS ────────────────────────────────────── */
.lkh-toc {
  background: var(--lkh-bg);
  border: 1px solid var(--lkh-border);
  border-left: 4px solid var(--lkh-gold);
  border-radius: var(--lkh-radius);
  padding: 1rem 1.25rem;
  margin: 2rem 0;
  font-family: var(--lkh-font-ui);
}
.lkh-toc__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}
.lkh-toc__title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--lkh-text);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.lkh-toc__toggle {
  background: none;
  border: 1px solid var(--lkh-border);
  border-radius: 4px;
  padding: .2rem .5rem;
  cursor: pointer;
  font-size: .8rem;
  color: var(--lkh-muted);
}
.lkh-toc__list {
  margin: 0; padding: 0;
  list-style: none;
}
.lkh-toc__item { line-height: 1.6; }
.lkh-toc__item--h3 { padding-left: 1rem; }
.lkh-toc__item--h4 { padding-left: 2rem; }
.lkh-toc__link {
  color: var(--lkh-muted);
  text-decoration: none;
  font-size: .9rem;
  transition: color var(--lkh-transition);
}
.lkh-toc__link:hover,
.lkh-toc__link.active { color: var(--lkh-gold); }
.lkh-toc__link.active { font-weight: 600; }
.lkh-toc__list.collapsed { display: none; }

/* ── FRONTEND FORM ────────────────────────────────────────── */
.lkh-form-wrap {
  max-width: 860px;
  margin: 0 auto;
  font-family: var(--lkh-font-ui);
}
.lkh-form-notice {
  padding: .85rem 1.25rem;
  border-radius: var(--lkh-radius);
  margin-bottom: 1.25rem;
  font-size: .95rem;
  font-weight: 500;
}
.lkh-form-notice--error {
  background: #fef2f2;
  border: 1px solid #f87171;
  color: #991b1b;
}
.lkh-form-notice--success {
  background: #f0fdf4;
  border: 1px solid #4ade80;
  color: #166534;
}
.lkh-form-notice--info {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
}

.lkh-fieldset {
  border: 1px solid var(--lkh-border);
  border-radius: var(--lkh-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: #fff;
}
@media (prefers-color-scheme: dark) {
  .lkh-fieldset { background: #15151c; }
}
.lkh-fieldset legend {
  font-weight: 700;
  font-size: 1rem;
  color: var(--lkh-text);
  padding: 0 .5rem;
  letter-spacing: .02em;
}
.lkh-fieldset__desc {
  margin: 0 0 1rem;
  color: var(--lkh-muted);
  font-size: .9rem;
}

.lkh-field { margin-bottom: 1rem; }
.lkh-field label {
  display: block;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: .35rem;
  color: var(--lkh-text);
}
.lkh-field input[type="text"],
.lkh-field input[type="url"],
.lkh-field textarea,
.lkh-field select {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid var(--lkh-border);
  border-radius: var(--lkh-radius);
  font-family: var(--lkh-font-ui);
  font-size: .92rem;
  color: var(--lkh-text);
  background: var(--lkh-bg);
  transition: border-color var(--lkh-transition), box-shadow var(--lkh-transition);
  box-sizing: border-box;
}
.lkh-field input:focus,
.lkh-field textarea:focus,
.lkh-field select:focus {
  outline: none;
  border-color: var(--lkh-gold);
  box-shadow: 0 0 0 3px rgba(168,120,46,.15);
}
.lkh-field__hint {
  display: block;
  font-size: .78rem;
  color: var(--lkh-muted);
  margin-top: .3rem;
}
.lkh-required { color: var(--lkh-burgundy); }
.lkh-field--required label::after { content: ' *'; color: var(--lkh-burgundy); }

.lkh-wide { width: 100%; box-sizing: border-box; }

.lkh-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.lkh-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.lkh-grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
@media (max-width: 680px) {
  .lkh-grid-2,
  .lkh-grid-3,
  .lkh-grid-4 { grid-template-columns: 1fr; }
}

/* Radio group */
.lkh-radio-group { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.lkh-radio { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-weight: 400; font-size: .9rem; }
.lkh-radio input { accent-color: var(--lkh-gold); }

/* Image upload */
.lkh-image-upload-area {
  border: 2px dashed var(--lkh-border);
  border-radius: var(--lkh-radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--lkh-transition);
}
.lkh-image-upload-area:hover,
.lkh-image-upload-area.drag-over { border-color: var(--lkh-gold); }
.lkh-upload-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.lkh-upload-trigger { cursor: pointer; }
.lkh-image-preview { position: relative; display: inline-block; }
.lkh-image-preview img { max-width: 280px; max-height: 160px; object-fit: cover; border-radius: var(--lkh-radius); }
.lkh-remove-image {
  position: absolute; top: -8px; right: -8px;
  background: var(--lkh-burgundy); color: #fff;
  border: none; border-radius: 50%; width: 24px; height: 24px;
  cursor: pointer; font-size: .8rem; line-height: 1;
}

/* Hub sections */
.lkh-hub-section {
  border-top: 1px solid var(--lkh-border);
  padding-top: 1.25rem;
  margin-top: 1.25rem;
}
.lkh-hub-section:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.lkh-hub-section h4 {
  margin: 0 0 .75rem;
  font-size: .95rem;
  font-family: var(--lkh-font-ui);
  font-weight: 700;
  color: var(--lkh-text);
}

/* Repeater rows */
.lkh-repeater-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}
.lkh-bullet { color: var(--lkh-gold); font-weight: 700; flex-shrink: 0; }
.lkh-takeout-input { flex: 1; }
.lkh-remove-row {
  background: none; border: none; color: #f87171; cursor: pointer;
  font-size: 1rem; flex-shrink: 0; padding: .2rem;
}

/* FAQ rows */
.lkh-faq-row { margin-bottom: 1rem; }
.lkh-faq-row__inner { display: grid; grid-template-columns: 1fr 1.5fr; gap: .75rem; }
@media (max-width: 580px) { .lkh-faq-row__inner { grid-template-columns: 1fr; } }
.lkh-faq-q label, .lkh-faq-a label {
  display: block; font-size: .8rem; font-weight: 700;
  color: var(--lkh-muted); margin-bottom: .25rem;
}

/* Body editor */
.lkh-body-editor {
  width: 100%; box-sizing: border-box;
  font-family: var(--lkh-font-body);
  font-size: .95rem;
  line-height: 1.7;
  resize: vertical;
}
.lkh-body-meta {
  display: flex; gap: 1.5rem;
  margin-top: .4rem;
  font-size: .82rem;
  color: var(--lkh-muted);
}

/* Submit */
.lkh-form-submit { text-align: center; padding: 1.5rem 0; }
.lkh-btn-publish {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  background: var(--lkh-burgundy);
  color: #fff;
  border: none;
  border-radius: var(--lkh-radius);
  padding: .85rem 2.5rem;
  font-size: 1.05rem;
  font-family: var(--lkh-font-ui);
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background var(--lkh-transition), transform var(--lkh-transition);
}
.lkh-btn-publish:hover { background: #600018; transform: translateY(-1px); }
.lkh-btn-publish:disabled { background: var(--lkh-muted); cursor: not-allowed; transform: none; }
.lkh-submit-hint { font-size: .82rem; color: var(--lkh-muted); margin-top: .5rem; }

/* Success panel */
.lkh-success-box {
  text-align: center;
  padding: 2.5rem;
  border: 2px solid #4ade80;
  border-radius: var(--lkh-radius);
  background: #f0fdf4;
}
.lkh-success-links { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }

/* ── PROMPTS MODULE ───────────────────────────────────────── */
.lkh-prompts-container {
  margin: 1.5rem 0;
}
.lkh-prompts-btn-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.lkh-prompt-btn-wrap {
  flex: 1 1 240px;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.lkh-prompt-hidden-ta {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}
.lkh-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--prompt-color, var(--lkh-gold));
  color: #fff;
  border: none;
  border-radius: var(--lkh-radius);
  font-family: var(--lkh-font-ui);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .03em;
  transition: filter .18s ease, transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 4px 20px -6px rgba(0,0,0,.4);
  line-height: 1.2;
}
.lkh-copy-btn:hover {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px -8px rgba(0,0,0,.45);
}
.lkh-copy-btn:active { transform: translateY(0); filter: brightness(.95); }
.lkh-copy-btn.copied { background: #16a34a !important; }
.lkh-copy-btn__icon { font-size: 1.2rem; flex-shrink: 0; }
.lkh-copy-btn__text { font-size: .95rem; }
.lkh-copy-feedback {
  text-align: center;
  font-size: .78rem;
  min-height: 1.1em;
  color: #16a34a;
}

/* ── JSON IMPORT ZONE ─────────────────────────────────────── */
.lkh-json-import-zone {
  background: linear-gradient(135deg, #0f0f14 0%, #1a0a10 100%);
  border: 1px solid var(--lkh-gold);
  border-radius: var(--lkh-radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
  font-family: var(--lkh-font-ui);
}
.lkh-json-import-zone__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.lkh-json-import-zone__icon { font-size: 2rem; flex-shrink: 0; }
.lkh-json-import-zone__text {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.lkh-json-import-zone__text strong {
  color: var(--lkh-gold-light);
  font-size: 1rem;
}
.lkh-json-import-zone__text span {
  color: #888;
  font-size: .85rem;
}
.lkh-btn-import {
  background: var(--lkh-gold);
  color: #fff;
  border: none;
  border-radius: var(--lkh-radius);
  padding: .6rem 1.4rem;
  font-family: var(--lkh-font-ui);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--lkh-transition);
  white-space: nowrap;
}
.lkh-btn-import:hover { background: var(--lkh-gold-pale); }

.lkh-json-import-status {
  margin-top: .9rem;
  padding: .5rem .85rem;
  border-radius: 4px;
  font-size: .88rem;
  font-weight: 500;
}
.lkh-json-import-status--success { background: rgba(74,222,128,.12); color: #4ade80; border: 1px solid rgba(74,222,128,.3); }
.lkh-json-import-status--error   { background: rgba(248,113,113,.12); color: #f87171; border: 1px solid rgba(248,113,113,.3); }
.lkh-json-import-status--loading { background: rgba(168,120,46,.12);  color: var(--lkh-gold-light); border: 1px solid rgba(168,120,46,.3); }

.lkh-json-image-import {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(168,120,46,.25);
}
.lkh-json-image-import__label { color: #aaa; font-size: .88rem; margin-bottom: .65rem; }
.lkh-json-image-import__label strong { color: var(--lkh-gold-light); }
.lkh-json-image-import__row { display: flex; gap: .65rem; align-items: center; flex-wrap: wrap; }
.lkh-image-url-field {
  flex: 1; min-width: 220px;
  padding: .5rem .8rem;
  border: 1px solid rgba(168,120,46,.4);
  border-radius: var(--lkh-radius);
  background: rgba(255,255,255,.05);
  color: #e8e6e1;
  font-family: var(--lkh-font-ui);
  font-size: .88rem;
}
.lkh-image-url-field:focus { outline: none; border-color: var(--lkh-gold); }
.lkh-imagine-prompt-hint {
  margin-top: .75rem;
  padding: .6rem .9rem;
  background: rgba(168,120,46,.08);
  border-radius: 4px;
  font-size: .82rem;
  color: #aaa;
  line-height: 1.55;
}
.lkh-imagine-prompt-hint strong { color: var(--lkh-gold-light); display: block; margin-bottom: .25rem; }

/* Prompt badge */
.lkh-prompt-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  background: rgba(255,255,255,.12);
  color: #fff;
  padding: .15rem .5rem;
  border-radius: 10px;
  margin-left: .4rem;
  vertical-align: middle;
  letter-spacing: .03em;
}
/* Admin settings */
.lkh-notice-info {
  background: #f0f4ff;
  border-left: 4px solid #4f46e5;
  padding: .85rem 1.25rem;
  border-radius: 0 var(--lkh-radius) var(--lkh-radius) 0;
  margin-bottom: 1.5rem;
  font-size: .9rem;
}
.lkh-prompt-badge-admin {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  background: #800020;
  color: #fff;
  padding: .15rem .5rem;
  border-radius: 10px;
  margin-left: .5rem;
  vertical-align: middle;
}

/* ── JSON / Image mode tabs (v1.2) ────────────────────── */
.lkh-json-mode-tabs {
    display: flex;
    gap: 4px;
    margin: 10px 0 8px;
    flex-wrap: wrap;
}
.lkh-json-mode-tab,
.lkh-img-mode-tab {
    padding: 6px 14px;
    border: 1px solid rgba(168,120,46,.4);
    border-radius: 4px;
    background: rgba(255,255,255,.04);
    cursor: pointer;
    font-size: 13px;
    color: #c9a96e;
    transition: background .15s, border-color .15s;
}
.lkh-json-mode-tab.active,
.lkh-img-mode-tab.active {
    background: rgba(168,120,46,.18);
    border-color: #a8782e;
    color: #c9a96e;
}
.lkh-json-mode-panel,
.lkh-img-mode-panel {
    padding: 8px 0 4px;
}
.lkh-json-paste-textarea {
    width: 100%;
    font-family: monospace;
    font-size: 12px;
    border: 1px solid rgba(168,120,46,.3);
    border-radius: 4px;
    padding: 8px;
    resize: vertical;
    background: rgba(0,0,0,.4);
    color: #d4d4d4;
    box-sizing: border-box;
    margin-bottom: 8px;
}
.lkh-image-url-file {
    flex: 1;
    color: inherit;
}
