/**
 * Estilos Modernos para Sistema de Tags com IA
 * Design atual e responsivo
 */

/* ========== CONTAINER PRINCIPAL ========== */
.modern-tags-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px;
  font-family: var(--font-sans, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
}

/* ========== HEADER ========== */
.tags-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.tags-header-left {
  flex: 1;
  min-width: 200px;
}

.tags-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-color, #1a1a1a);
  margin: 0 0 2px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tags-title .material-icons {
  font-size: 1.35rem;
  color: #8b5cf6;
}

.tags-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted, #6b7280);
  margin: 0;
}

.tags-header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ========== BOTÕES ========== */
.btn-primary {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--card-bg, white);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.4);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 4px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted, #6b7280);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #8b5cf6;
}

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.link-btn {
  background: none;
  border: none;
  color: #8b5cf6;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  padding: 2px 0;
  transition: all 0.2s ease;
}

.link-btn:hover {
  color: #a78bfa;
  text-decoration: underline;
}

.link-btn .material-icons {
  font-size: 14px;
}

/* ========== DASHBOARD DE ESTATÍSTICAS ========== */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--card-bg, #0d1117);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.25 ease;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.15);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon .material-icons {
  font-size: 20px;
  color: white;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-color, #1a1a1a);
  line-height: 1.1;
  margin-bottom: 2px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  font-weight: 500;
}

/* Card de Top Tags (mais largo) */
.top-tags-card {
  grid-column: 1 / -1;
  flex-direction: column;
  align-items: stretch;
}

.stat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-color, #1a1a1a);
  margin-bottom: 8px;
}

.stat-header .material-icons {
  color: #8b5cf6;
  font-size: 1.1rem;
}

.top-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.top-tag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--card-hover-bg, #f9fafb);
  border: 1px solid var(--border-color, rgba(255,255,255,0.06));
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 0.8rem;
}

.top-tag-item:hover {
  background: rgba(139, 92, 246, 0.1);
}

.tag-rank {
  font-size: 0.85rem;
  font-weight: 700;
  color: #8b5cf6;
  min-width: 24px;
}

.tag-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-color, #1a1a1a);
}

.tag-count,
.tag-confidence {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
  padding: 2px 6px;
  background: var(--card-bg, white);
  border-radius: 4px;
  font-weight: 500;
}

/* ========== FILTROS ========== */
.tags-filters {
  background: var(--card-bg, white);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--card-hover-bg, #f3f4f6);
  border: 1px solid transparent;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  color: var(--text-color, #1a1a1a);
}

.filter-btn.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: #8b5cf6;
  color: #8b5cf6;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card-hover-bg, #f9fafb);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  padding: 4px 10px;
  min-width: 200px;
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: #8b5cf6;
  background: var(--card-bg, white);
}

.search-box .material-icons {
  color: var(--text-muted, #9ca3af);
  font-size: 16px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-color, #1a1a1a);
}

.search-box input::placeholder {
  color: var(--text-muted, #9ca3af);
}

/* ========== GRID DE TAGS ========== */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.tag-card-modern {
  background: var(--card-bg, #0d1117);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
  overflow: hidden;
}

.tag-card-modern:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.15);
}

.tag-card-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
}

.tag-badge {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.tag-actions {
  display: flex;
  gap: 4px;
}

.tag-card-body {
  padding: 14px 16px;
}

.tag-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.04));
}

.tag-info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 0.8rem;
  color: var(--text-muted, #8b949e);
  font-weight: 500;
}

.info-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-badge.clientes {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.info-badge.nao_clientes {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.info-badge.ambos {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-stats-mini {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
  display: flex;
  gap: 14px;
}

.stat-mini {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted, #8b949e);
}

.stat-mini .material-icons {
  font-size: 16px;
  color: #8b5cf6;
}

.tag-no-usage {
  margin-top: 12px;
  padding: 10px;
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  text-align: center;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ========== ESTADOS VAZIOS ========== */
.empty-state {
  text-align: center;
  padding: 20px;
  color: var(--text-muted, #8b949e);
  font-size: 0.85rem;
}

.empty-state-large {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  background: var(--card-bg, #0d1117);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  color: var(--text-color, #e6edf3);
}

.empty-state-large .material-icons {
  font-size: 56px;
  color: #8b5cf6;
  margin-bottom: 14px;
}

.empty-state-large h3 {
  font-size: 1.2rem;
  color: var(--text-color, #e6edf3);
  margin: 0 0 6px 0;
}

.empty-state-large p {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}

.stats-card.loading {
  justify-content: center;
  align-items: center;
  color: #9ca3af;
  font-size: 14px;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-content-modern {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

.modal-content-modern.small {
  max-width: 400px;
}

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

.modal-header {
  padding: 24px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h3 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #9ca3af;
  transition: all 0.2s ease;
  border-radius: 6px;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #1a1a1a;
}

#tagForm {
  padding: 24px;
}

/* Preview da Tag */
.tag-preview {
  text-align: center;
  padding: 24px;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  border-radius: 12px;
  margin-bottom: 24px;
}

#tagPreview {
  display: inline-flex;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Form Groups */
.form-group {
  margin-bottom: 20px;
}

.form-group.half {
  flex: 1;
  min-width: 150px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.form-group label .material-icons {
  font-size: 18px;
  color: #667eea;
}

.label-help {
  font-size: 12px;
  font-weight: 400;
  color: #9ca3af;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-color {
  width: 100%;
  height: 50px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.form-color:hover {
  border-color: #667eea;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 6px;
}

.form-hint .material-icons {
  font-size: 16px;
  color: #667eea;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #f3f4f6;
}

/* Keywords Modal */
.keywords-list {
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.keyword-chip {
  padding: 6px 14px;
  background: #ede9fe;
  color: #667eea;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ========== RESPONSIVIDADE ========== */
@media (max-width: 768px) {
  .modern-tags-container {
    padding: 16px;
  }

  .tags-header {
    flex-direction: column;
    align-items: stretch;
  }

  .tags-header-right {
    justify-content: space-between;
  }

  .tags-title {
    font-size: 24px;
  }

  .stats-dashboard {
    grid-template-columns: 1fr;
  }

  .tags-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-buttons {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .search-box {
    width: 100%;
  }

  .tags-grid {
    grid-template-columns: 1fr;
  }

  .modal-content-modern {
    max-width: 100%;
    margin: 10px;
  }

  .form-row {
    flex-direction: column;
  }
}

/* ========== SCROLLBAR CUSTOMIZADO ========== */
.modal-content-modern::-webkit-scrollbar,
.keywords-list::-webkit-scrollbar {
  width: 8px;
}

.modal-content-modern::-webkit-scrollbar-track,
.keywords-list::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

.modal-content-modern::-webkit-scrollbar-thumb,
.keywords-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.modal-content-modern::-webkit-scrollbar-thumb:hover,
.keywords-list::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}
