/* =====================================================
   FILLER 5.0 — Estilos
   ===================================================== */

/* ── Variables globales ── */
:root {
  --accent: #00695c;
  --bg: #fafbfc;
  --fg: #222;
  --border: #e0e0e0;
  --radius: 8px;
}

/* ── Base ── */
body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  margin: 32px auto;
  max-width: 900px;
  line-height: 1.6;
}

h2 {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 0.5em;
  font-weight: 600;
}

/* ── Formulario ── */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 1.5em;
  margin-bottom: 1.5em;
  box-shadow: none;
}

legend {
  font-weight: 600;
  color: var(--accent);
  padding: 0 0.5em;
}

label {
  font-size: 1em;
  font-weight: 500;
  margin-bottom: 0.25em;
  display: block;
}

input,
select {
  width: 100%;
  padding: 0.6em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
  font-size: 1em;
  margin-bottom: 1em;
  box-sizing: border-box;
}

/* ── Botones ── */
button {
  border: none;
  border-radius: var(--radius);
  padding: 0.7em 1.2em;
  font-size: 1em;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-right: 0.5em;
  margin-bottom: 0.5em;
  transition: background 0.2s;
}

button:active {
  opacity: 0.9;
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ── Log / Código ── */
pre {
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1em;
  font-family: ui-monospace, monospace;
  font-size: 0.98em;
  overflow-x: auto;
  max-height: 200px;
}

/* ── Utilidades ── */
.small {
  font-size: 0.92em;
  color: #666;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

.hidden {
  display: none;
}

/* =====================================================
   TABLA DINÁMICA
   ===================================================== */
.table-wrapper {
  overflow-x: auto;
  width: 100%;
  padding-bottom: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

#tabla-dinamica {
  table-layout: auto;
  width: max-content;
  border-collapse: collapse;
  margin-bottom: 0;
}

#tabla-dinamica th,
#tabla-dinamica td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
  font-size: 0.9em;
  white-space: nowrap;
}

#tabla-dinamica th {
  background-color: #e0e0e0;
  color: var(--fg);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85em;
}

#tabla-dinamica input,
#tabla-dinamica select {
  padding: 5px;
  margin-bottom: 0;
}

#tabla-dinamica th:last-child,
#tabla-dinamica td:last-child {
  width: 90px;
}

/* ── Botones de acción en la tabla ── */
.action-cell {
  display: flex;
  gap: 4px;
}

.iconbtn {
  padding: 0.4em 0.6em;
  line-height: 1;
  margin: 0;
  display: inline-block;
  text-align: center;
  cursor: pointer;
  font-size: 1.1em;
}

.iconbtn-delete {
  background: #d32f2f;
  color: white;
}

.iconbtn-delete:hover {
  background: #c62828;
}

.iconbtn-preview {
  background: #0288d1;
  color: white;
}

.iconbtn-preview:hover {
  background: #0277bd;
}

/* =====================================================
   MODO "UN SOLO REGISTRO" (vista vertical)
   ===================================================== */
.table-wrapper.single-record-mode {
  border-style: solid;
}

.table-wrapper.single-record-mode #tabla-dinamica {
  width: 100%;
}

.table-wrapper.single-record-mode thead {
  display: none;
}

.table-wrapper.single-record-mode tbody tr {
  display: block;
}

.table-wrapper.single-record-mode tbody tr td {
  display: block;
  border: none;
  padding: 6px 8px 10px;
  white-space: normal;
}

.table-wrapper.single-record-mode tbody tr td:last-child {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
}

.table-wrapper.single-record-mode .dyn-label {
  display: block;
  font-size: 0.9em;
  font-weight: 500;
  margin-bottom: 2px;
  color: #444;
}

.table-wrapper:not(.single-record-mode) .dyn-label {
  display: none;
}

.table-wrapper.single-record-mode #tabla-dinamica th:last-child,
.table-wrapper.single-record-mode #tabla-dinamica td:last-child {
  width: auto;
}

/* =====================================================
   MODAL DE PREVISUALIZACIÓN
   ===================================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-content {
  background-color: #fefefe;
  margin: 2% auto;
  padding: 20px;
  border: 1px solid #888;
  border-radius: var(--radius);
  width: 90%;
  height: 90%;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.close-btn {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 0.8;
}

.close-btn:hover,
.close-btn:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

#preview-container {
  flex-grow: 1;
  overflow: auto;
  border: 1px solid #ddd;
  background: #e9e9e9;
  padding: 20px;
}

.docx-wrapper {
  background: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  padding: 0 !important;
  margin: 0 auto;
}

/* =====================================================
   PANEL DE MEMORIA
   ===================================================== */
#memoryArea {
  margin-top: 28px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

#memoryArea h3 {
  margin: 0 0 8px 0;
  font-size: 0.95em;
  font-weight: 600;
  opacity: 0.85;
}

#memoryList {
  max-height: 220px;
  overflow: auto;
}

.memory-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 6px;
  background: #fcfcfc;
  font-size: 0.9em;
}

.memory-item b {
  color: var(--accent);
}

.memory-actions {
  margin-top: 4px;
  display: flex;
  gap: 6px;
}

.memory-actions button {
  font-size: 0.8em;
  padding: 0.25em 0.6em;
  opacity: 0.9;
}

.memory-delete-btn {
  opacity: 0.65;
}

/* =====================================================
   BANNER DE TRANSFERENCIA DE CONTEXTO
   ===================================================== */
#banner-transferencia {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-left: 4px solid #2e7d32;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.95em;
  color: #1b5e20;
  animation: slideDown 0.3s ease;
}

#banner-transferencia button {
  background: transparent;
  color: #2e7d32;
  border: none;
  font-size: 1.1em;
  padding: 0 4px;
  margin: 0;
  cursor: pointer;
  opacity: 0.7;
}

#banner-transferencia button:hover {
  opacity: 1;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
