/* css/metadata-premium.css — refined Metadata tab. Loaded last; everything is scoped to #tab-meta. */

#tab-meta {
  --mp-ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mp-surface: #ffffff;
  --mp-surface-2: #faf7f1;
  --mp-border: rgba(26, 22, 17, 0.09);
  --mp-border-strong: rgba(26, 22, 17, 0.17);
  --mp-ring: rgba(168, 52, 31, 0.14);
  --mp-good: #1f7a4d;
  --mp-good-bg: #e3f4ea;
  --mp-warn: #9a6200;
  --mp-warn-bg: #fdf1d8;
  --mp-radius: 14px;
  --mp-radius-sm: 10px;
  --mp-shadow: 0 1px 2px rgba(26, 22, 17, 0.04), 0 8px 24px -16px rgba(26, 22, 17, 0.18);
  font-family: var(--mp-ui);
}

body.fs-theme-dark #tab-meta {
  --mp-surface: var(--card);
  --mp-surface-2: #16181e;
  --mp-border: rgba(255, 255, 255, 0.07);
  --mp-border-strong: rgba(255, 255, 255, 0.14);
  --mp-ring: rgba(224, 105, 79, 0.22);
  --mp-good: #6fd49b;
  --mp-good-bg: rgba(111, 212, 155, 0.12);
  --mp-warn: #f0c26b;
  --mp-warn-bg: rgba(240, 194, 107, 0.12);
  --mp-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -16px rgba(0, 0, 0, 0.6);
}

/* ── Page frame ── */
#tab-meta .meta-page {
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 32px;
  max-width: 1320px;
}

#tab-meta .meta-content { gap: 40px; }

/* ── Sidebar: one panel with title, progress, and section links ── */
#tab-meta .meta-sidebar {
  top: 12px;
  gap: 0;
  padding: 0;
  background: var(--mp-surface);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius);
  box-shadow: var(--mp-shadow);
  overflow: hidden auto;
}

#tab-meta .meta-sidebar-head { padding: 20px 20px 14px; }

#tab-meta .meta-page-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 6px;
}

#tab-meta .meta-page-lead { font-size: 12.5px; line-height: 1.55; }

#tab-meta .meta-checklist {
  margin: 0 14px;
  padding: 14px;
  background: var(--mp-surface-2);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  box-shadow: none;
}

#tab-meta .meta-checklist-head { margin-bottom: 10px; }

#tab-meta .meta-checklist-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

#tab-meta .meta-checklist-count {
  color: var(--mp-good);
  background: var(--mp-good-bg);
}

#tab-meta .meta-checklist.is-incomplete .meta-checklist-count {
  color: var(--mp-warn);
  background: var(--mp-warn-bg);
}

.meta-progress {
  height: 6px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--mp-border);
  overflow: hidden;
}

.meta-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  transition: width 0.4s ease;
}

.meta-checklist.is-complete .meta-progress-fill { background: var(--mp-good); }

#tab-meta .meta-checklist-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 6px;
}

#tab-meta .meta-checklist-btn {
  padding: 5px 6px;
  font-family: var(--mp-ui);
  font-size: 12px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink-soft);
}

#tab-meta .meta-checklist-btn:hover { background: var(--mp-border); }

#tab-meta .meta-checklist-icon { width: 16px; height: 16px; font-size: 10px; }

#tab-meta .meta-checklist-item.is-done .meta-checklist-icon { background: var(--mp-good-bg); color: var(--mp-good); }
#tab-meta .meta-checklist-item.is-pending .meta-checklist-icon { background: var(--mp-warn-bg); color: var(--mp-warn); }
#tab-meta .meta-checklist-item.is-optional .meta-checklist-icon { background: var(--mp-border); color: var(--muted); }

#tab-meta .meta-subnav { padding: 14px 10px 16px; gap: 2px; }

#tab-meta .meta-subnav-link {
  padding: 9px 10px;
  border-left: 0;
  border-radius: var(--mp-radius-sm);
  font-family: var(--mp-ui);
  font-size: 13px;
  color: var(--ink-soft);
}

#tab-meta .meta-subnav-link:hover { background: var(--mp-surface-2); color: var(--ink); }

#tab-meta .meta-subnav-link.is-active {
  color: var(--accent);
  background: var(--mp-ring);
  font-weight: 600;
}

#tab-meta .meta-subnav-num {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--mp-surface-2);
  border: 1px solid var(--mp-border);
  color: var(--muted);
}

#tab-meta .meta-subnav-link.is-active .meta-subnav-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#tab-meta .meta-subnav-link.is-complete .meta-subnav-num {
  background: var(--mp-good-bg);
  border-color: transparent;
  color: var(--mp-good);
  font-size: 0;
}

#tab-meta .meta-subnav-link.is-complete .meta-subnav-num::after { content: '✓'; font-size: 12px; }

#tab-meta .meta-subnav-link.is-active.is-complete .meta-subnav-num {
  background: var(--mp-good);
  color: #fff;
}

.meta-subnav-state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

#tab-meta .meta-subnav-link.is-complete .meta-subnav-state { color: var(--mp-good); }

/* ── Production stage lives in the top bar; keep only the status and reset here ── */
#tab-meta .meta-workflow-banner {
  padding: 10px 16px !important;
  background: var(--mp-surface) !important;
  border: 1px solid var(--mp-border) !important;
  border-left: 3px solid var(--accent) !important;
  border-radius: var(--mp-radius-sm);
  box-shadow: none;
}

#tab-meta .meta-workflow-primary { display: none; }

#tab-meta .meta-workflow-row .workflow-meta-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

/* ── Sections ── */
#tab-meta .meta-content { counter-reset: meta-step; }

#tab-meta .meta-section { scroll-margin-top: 16px; }

#tab-meta .meta-section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 24px;
  padding-bottom: 0;
  border-bottom: 0;
  margin-bottom: 4px;
}

#tab-meta .meta-section-title::before {
  counter-increment: meta-step;
  content: counter(meta-step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  background: var(--rule);
  color: var(--paper);
  font-family: var(--mp-ui);
  font-size: 13px;
  font-weight: 700;
}

body.fs-theme-dark #tab-meta .meta-section-title::before { background: var(--accent); color: #fff; }

#tab-meta .meta-journal-profiles-card .meta-section-title::before { content: '·'; counter-increment: none; }

#tab-meta .meta-section-desc {
  margin: 0 0 18px 40px;
  font-size: 13px;
}

#tab-meta .meta-section-grid { gap: 18px; }

/* ── Cards ── */
#tab-meta .card {
  padding: 22px 24px;
  background: var(--mp-surface);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius);
  box-shadow: var(--mp-shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#tab-meta .card::before { display: none; }

#tab-meta .card:focus-within {
  border-color: var(--mp-border-strong);
  box-shadow: var(--mp-shadow), 0 0 0 4px var(--mp-ring);
}

#tab-meta .card-title {
  font-family: var(--mp-ui);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}

#tab-meta .card-hint {
  font-family: var(--mp-ui);
  font-size: 12.5px;
  font-style: normal;
  margin-bottom: 16px;
}

body.fs-density-compact #tab-meta .card { padding: 16px 18px; }

/* ── Labels and hints ── */
#tab-meta label,
#tab-meta .meta-field-label {
  font-family: var(--mp-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}

#tab-meta label { gap: 6px; }
#tab-meta label.block { margin-bottom: 0; }

#tab-meta .meta-field-label { display: block; }

#tab-meta .meta-field-hint {
  display: block;
  margin: -2px 0 2px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--muted);
}

#tab-meta .meta-required { color: var(--accent); }

#tab-meta .card > label.block + .meta-field-group,
#tab-meta .card > .meta-field + .meta-field-group { margin-top: 16px; }

#tab-meta .meta-field-group { gap: 16px; }

#tab-meta .meta-field-group--2col { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); }

/* ── Inputs ── */
#tab-meta input[type="text"],
#tab-meta input[type="email"],
#tab-meta input[type="url"],
#tab-meta input[type="date"],
#tab-meta select,
#tab-meta textarea {
  min-height: 42px;
  margin-top: 0;
  padding: 10px 13px;
  background: var(--mp-surface);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  font-family: var(--mp-ui);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
}

#tab-meta select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6358' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}

#tab-meta input::placeholder,
#tab-meta textarea::placeholder { color: var(--muted); opacity: 0.65; }

#tab-meta input:hover,
#tab-meta select:hover,
#tab-meta textarea:hover { border-color: var(--line-strong); }

#tab-meta textarea:focus,
#tab-meta input:focus,
#tab-meta select:focus,
#tab-meta .meta-rich-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--mp-ring);
}

#tab-meta #art-title {
  min-height: 64px;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.4;
}

#tab-meta .meta-rich-editor {
  padding: 13px 15px;
  background: var(--mp-surface);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  font-family: var(--font-serif);
  font-size: 15.5px;
  line-height: 1.65;
}

#tab-meta #art-doi,
#tab-meta #journal-issn { font-family: var(--font-mono); font-size: 13px; }

#tab-meta input[type="file"] {
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  background: var(--mp-surface-2);
  font-family: var(--mp-ui);
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted);
  cursor: pointer;
}

#tab-meta input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: 1px solid var(--mp-border-strong);
  border-radius: 8px;
  background: var(--mp-surface);
  font: 600 12.5px var(--mp-ui);
  color: var(--ink);
  cursor: pointer;
}

#tab-meta input[type="file"]:hover::file-selector-button { border-color: var(--accent); color: var(--accent); }

#tab-meta input[type="checkbox"],
#tab-meta input[type="radio"] { accent-color: var(--accent); }

#tab-meta .word-import-option {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

/* ── Buttons ── */
#tab-meta .btn-primary,
#tab-meta .btn-ghost,
#tab-meta .meta-toolbar .btn-primary,
#tab-meta .meta-toolbar .btn-ghost,
#tab-meta .meta-doi-actions .btn-ghost {
  min-height: 38px;
  padding: 8px 16px;
  border-radius: var(--mp-radius-sm);
  font-family: var(--mp-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

#tab-meta .btn-primary { box-shadow: 0 1px 2px rgba(26, 22, 17, 0.12); }

#tab-meta .btn-ghost {
  background: var(--mp-surface);
  border-color: var(--mp-border-strong);
}

#tab-meta .btn-ghost:hover { background: var(--mp-surface-2); }

#tab-meta .btn-sm { min-height: 32px; padding: 6px 12px; font-size: 12.5px; }

#tab-meta #add-author,
#tab-meta #add-affil {
  width: 100%;
  margin-top: 14px !important;
  background: transparent;
  color: var(--ink-soft);
  border: 1px dashed var(--mp-border-strong);
  box-shadow: none;
}

#tab-meta #add-author:hover,
#tab-meta #add-affil:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--mp-ring);
}

/* ── DOI ── */
#tab-meta .meta-chip {
  padding: 7px 14px;
  font-family: var(--mp-ui);
  font-size: 12.5px;
  font-weight: 500;
  background: var(--mp-surface);
  border-color: var(--mp-border-strong);
}

#tab-meta .meta-chip:has(input:checked) {
  color: var(--accent);
  background: var(--mp-ring);
  border-color: var(--accent);
}

#tab-meta .meta-chip input { accent-color: var(--accent); }

#tab-meta .meta-doi-format-row select { min-height: 40px; }
#tab-meta .meta-doi-row { gap: 10px; }

/* ── Authors and affiliations ── */
#tab-meta .author-row--display,
#tab-meta .affil-row--display {
  margin-bottom: 8px;
  padding: 12px 14px;
  background: var(--mp-surface-2);
  border: 1px solid var(--mp-border);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s;
}

#tab-meta .author-row--display:hover,
#tab-meta .affil-row--display:hover { border-color: var(--mp-border-strong); background: var(--mp-surface); }

#tab-meta .row-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--mp-ring);
  color: var(--accent);
  font-family: var(--mp-ui);
  font-size: 13px;
  font-weight: 700;
}

#tab-meta .row-summary-title { font-family: var(--mp-ui); font-size: 14px; font-weight: 600; }
#tab-meta .row-summary-meta { font-family: var(--mp-ui); font-size: 12px; letter-spacing: normal; }

#tab-meta .row-edit,
#tab-meta .row-remove {
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--mp-ui);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

/* ── Help toggles and the Advanced block ── */
#tab-meta .meta-help-toggle summary {
  font-family: var(--mp-ui);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

#tab-meta .meta-help-body {
  background: var(--mp-surface-2);
  border-color: var(--mp-border);
  border-radius: var(--mp-radius-sm);
  font-family: var(--mp-ui);
}

#tab-meta .meta-advanced-block {
  background: var(--mp-surface);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius);
  box-shadow: var(--mp-shadow);
}

#tab-meta .meta-advanced-block > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  font-family: var(--mp-ui);
  font-size: 14px;
  color: var(--ink);
}

#tab-meta .meta-advanced-block > summary::before {
  content: '';
  width: 8px;
  height: 8px;
  margin: 0 4px 0 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.2s;
}

#tab-meta .meta-advanced-block[open] > summary::before { transform: rotate(45deg); }

#tab-meta .meta-advanced-inner .card { background: var(--mp-surface-2); }

#tab-meta .citation-box,
#tab-meta .crossref-metadata-preview {
  border-radius: var(--mp-radius-sm);
  border: 1px solid var(--mp-border);
  background: var(--mp-surface-2);
}

#tab-meta .meta-content-tip {
  background: var(--mp-surface-2) !important;
  border-left: 3px solid var(--line-strong) !important;
}

/* ── Journal logo ── */
#tab-meta .journal-logo-upload {
  margin-top: 18px !important;
  padding-top: 16px;
  border-top: 1px solid var(--mp-border);
}

#tab-meta .journal-logo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  #tab-meta .meta-page { grid-template-columns: 1fr; }
  #tab-meta .meta-sidebar { position: static; }
  #tab-meta .meta-subnav { padding: 12px; border-bottom: 0; }
  #tab-meta .meta-subnav-link { border-bottom: 0; }
  .meta-subnav-state { display: none; }
}

@media (max-width: 720px) {
  #tab-meta .meta-field-group--2col { grid-template-columns: 1fr; }
  #tab-meta .meta-section-desc { margin-left: 0; }
  #tab-meta .meta-checklist-list { grid-template-columns: 1fr; }
}
