/* frontend/css/modules/lista-templates.css */

.nextlist-lista-templates {
  width: 100%;
  padding: 20px;
}

/* ─── Header ─────────────────────────────────────────────────── */
.nextlist-lista-templates .page-header {
  margin-bottom: 2rem;
}

.nextlist-lista-templates .header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.nextlist-lista-templates .header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nextlist-lista-templates .header-right {
  display: flex;
  gap: 0.75rem;
}

.nextlist-lista-templates .btn-link {
  background: none;
  border: none;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.nextlist-lista-templates .btn-link:hover {
  background-color: var(--surface-hover, #f3f4f6);
}

.nextlist-lista-templates .page-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nextlist-lista-templates .page-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary, #6b7280);
  margin: 0;
}

/* ─── Botões ─────────────────────────────────────────────────── */
.nextlist-lista-templates .btn {
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
}

.nextlist-lista-templates .btn-primary {
  background-color: var(--primary-color);
  color: var(--btn-secundary-text-color);
  border: var(--border-type);
}

.nextlist-lista-templates .btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.nextlist-lista-templates .btn-secondary {
  background-color: var(--btn-secundary-color);
  color: var(--btn-secundary-text-color);
  border: var(--border-type);
}

.nextlist-lista-templates .btn-secondary:hover {
  opacity: 0.9;
}

.nextlist-lista-templates .btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

/* ─── Barra de busca e filtros ───────────────────────────────── */
.nextlist-lista-templates .templates-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.nextlist-lista-templates .search-group {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.nextlist-lista-templates .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary, #6b7280);
  font-size: 0.875rem;
}

.nextlist-lista-templates .search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 14px;
  background-color: var(--input-bg, #ffffff);
  color: var(--text-primary, #1f2937);
  transition: all 0.2s;
  box-sizing: border-box;
}

.nextlist-lista-templates .search-input:focus {
  outline: none;
  border: 2px solid var(--primary-color);
  padding-left: 35px;
}

.nextlist-lista-templates .templates-count {
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
}

/* ─── Grid de templates ──────────────────────────────────────── */
.nextlist-lista-templates .templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

/* ─── Card de template ───────────────────────────────────────── */
.nextlist-lista-templates .template-card {
  background-color: var(--card-bg, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.nextlist-lista-templates .template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--primary-color);
}

.nextlist-lista-templates .template-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background-color: var(--surface-hover, #f9fafb);
}

.nextlist-lista-templates .template-code {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary, #6b7280);
  letter-spacing: 0.1em;
  font-family: monospace;
}

.nextlist-lista-templates .template-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #d97706;
  background-color: #fef3c7;
  padding: 3px 8px;
  border-radius: 20px;
}

.nextlist-lista-templates .template-body {
  padding: 1rem;
  flex: 1;
}

.nextlist-lista-templates .template-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
}

.nextlist-lista-templates .template-description {
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 0.75rem 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nextlist-lista-templates .template-unidade {
  font-size: 0.8125rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 0.5rem;
}

.nextlist-lista-templates .template-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border, #e5e7eb);
  background-color: var(--surface-hover, #f9fafb);
}

.nextlist-lista-templates .template-meta {
  display: flex;
  gap: 0.75rem;
}

.nextlist-lista-templates .meta-item {
  font-size: 0.8125rem;
  color: var(--text-secondary, #6b7280);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Loading ────────────────────────────────────────────────── */
.nextlist-lista-templates .templates-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
  color: var(--text-secondary, #6b7280);
  font-size: 0.95rem;
}

.nextlist-lista-templates .templates-loading i {
  font-size: 2rem;
  color: var(--primary-color);
}

/* ─── Empty state ────────────────────────────────────────────── */
.nextlist-lista-templates .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  text-align: center;
  background-color: var(--card-bg, #ffffff);
  border: 2px dashed var(--border, #e5e7eb);
  border-radius: 12px;
}

.nextlist-lista-templates .empty-icon {
  font-size: 3rem;
  color: var(--primary-color);
  opacity: 0.5;
  margin-bottom: 1rem;
}

.nextlist-lista-templates .empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin: 0 0 0.5rem 0;
}

.nextlist-lista-templates .empty-message {
  font-size: 0.95rem;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 1.5rem 0;
}

/* ─── Preview modal ──────────────────────────────────────────── */
.nextlist-lista-templates .modal-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.nextlist-lista-templates .modal-container,
.modal-container {
  background-color: var(--card-bg, #ffffff);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-container.modal-lg {
  max-width: 760px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background-color: var(--surface-hover, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border, #e5e7eb);
}

/* Preview sections */
.preview-template-info {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.preview-code {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary, #6b7280);
  letter-spacing: 0.1em;
  font-family: monospace;
}

.preview-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin: 0 0 0.5rem 0;
}

.preview-description {
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 0.75rem 0;
}

.preview-meta {
  display: flex;
  gap: 1rem;
}

.preview-section {
  background-color: var(--surface-hover, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.preview-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--card-bg, #ffffff);
  border-bottom: 1px solid var(--border, #e5e7eb);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary, #1f2937);
}

.preview-section-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-secondary, #6b7280);
  font-weight: 400;
}

.preview-section-fields {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem 0.75rem;
  background-color: var(--card-bg, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
}

.preview-field-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-primary, #1f2937);
  font-weight: 500;
}

.preview-field-type {
  font-size: 0.75rem;
  color: var(--text-secondary, #6b7280);
  margin-left: 1.25rem;
}

.field-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.badge-required {
  background-color: #fee2e2;
  color: #dc2626;
}

.no-fields {
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  text-align: center;
  padding: 0.5rem;
  margin: 0;
}

.preview-empty,
.preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary, #6b7280);
}

/* ─── Dark theme ─────────────────────────────────────────────── */
html.dark-theme .nextlist-lista-templates .page-title,
html.dark-theme .nextlist-lista-templates .template-title,
html.dark-theme .nextlist-lista-templates .empty-title {
  color: #f0f0f0;
}

html.dark-theme .nextlist-lista-templates .page-subtitle,
html.dark-theme .nextlist-lista-templates .template-description,
html.dark-theme .nextlist-lista-templates .meta-item,
html.dark-theme .nextlist-lista-templates .template-code,
html.dark-theme .nextlist-lista-templates .templates-count,
html.dark-theme .nextlist-lista-templates .empty-message {
  color: #b0b0b0;
}

html.dark-theme .nextlist-lista-templates .template-card,
html.dark-theme .nextlist-lista-templates .empty-state {
  background-color: #2c2c2c;
  border-color: #555555;
}

html.dark-theme .nextlist-lista-templates .template-header,
html.dark-theme .nextlist-lista-templates .template-footer {
  background-color: #242424;
  border-color: #555555;
}

html.dark-theme .nextlist-lista-templates .search-input {
  background-color: #1e1e1e;
  color: #f0f0f0;
  border-color: #555555;
}

html.dark-theme .nextlist-lista-templates .btn-link:hover {
  background-color: #3a3a3a;
}

html.dark-theme .modal-container {
  background-color: #2c2c2c;
  border-color: #555555;
}

html.dark-theme .modal-header,
html.dark-theme .modal-footer {
  border-color: #555555;
}

html.dark-theme .modal-title,
html.dark-theme .preview-title,
html.dark-theme .preview-section-header {
  color: #f0f0f0;
}

html.dark-theme .preview-section {
  background-color: #242424;
  border-color: #555555;
}

html.dark-theme .preview-section-header,
html.dark-theme .preview-field {
  background-color: #2c2c2c;
  border-color: #555555;
}

html.dark-theme .modal-close:hover {
  background-color: #3a3a3a;
}

/* ─── Responsivo ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nextlist-lista-templates {
    padding: 15px;
  }

  .nextlist-lista-templates .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .nextlist-lista-templates .header-right {
    width: 100%;
  }

  .nextlist-lista-templates .btn {
    width: 100%;
    justify-content: center;
  }

  .nextlist-lista-templates .templates-grid {
    grid-template-columns: 1fr;
  }

  .nextlist-lista-templates .templates-toolbar {
    flex-direction: column;
  }

  .nextlist-lista-templates .search-group {
    width: 100%;
  }

  .modal-container {
    max-height: 95vh;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

.nextlist-lista-templates .templates-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
}