/* Reset e Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  padding: 30px 0;
  border-bottom: 2px solid #1e293b;
  margin-bottom: 20px;
}

.header h1 {
  font-size: 2.5rem;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

.header p {
  color: #64748b;
}

/* Navegação */
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-btn {
  padding: 12px 24px;
  border: none;
  background: #1e293b;
  color: #94a3b8;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.3s;
}

.nav-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

.nav-btn.active {
  background: #3b82f6;
  color: white;
}

/* Tabs Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Cards */
.card {
  background: #1e293b;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid #334155;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.card h2, .card h3 {
  color: #f8fafc;
  margin-bottom: 15px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  border: 1px solid #334155;
  transition: transform 0.3s;
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-card h3 {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: #475569;
  color: white;
}

.btn-secondary:hover {
  background: #64748b;
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #cbd5e1;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #475569;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: 0.85rem;
}

/* Layout de duas colunas no form */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

/* Analytics Dashboard */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.analytics-card {
  padding: 20px;
}

.analytics-card.wide {
  grid-column: 1 / -1;
}

.analytics-card h3 {
  margin-bottom: 15px;
  color: #e2e8f0;
  font-size: 1.1rem;
  border-bottom: 1px solid #334155;
  padding-bottom: 10px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #1e293b;
}

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

.metric-label {
  color: #94a3b8;
  font-size: 0.95rem;
}

.metric-value {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 1.1rem;
}

.metric-value.success {
  color: #34d399;
}

.metric-value.error {
  color: #f87171;
}

.metric-value.warning {
  color: #fbbf24;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  margin: 10px 0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* Chart */
.chart-container {
  padding: 10px 0;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 150px;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #334155;
}

.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-radius: 4px 4px 0 0;
  min-width: 30px;
  transition: all 0.3s;
  position: relative;
}

.chart-bar:hover {
  background: linear-gradient(180deg, #60a5fa, #3b82f6);
}

.chart-bar::after {
  content: attr(data-value);
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: #94a3b8;
}

.chart-labels {
  display: flex;
  justify-content: space-around;
  gap: 10px;
  margin-top: 10px;
}

.chart-label {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
  min-width: 30px;
}

/* Servidores list */
.servidores-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.servidor-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #0f172a;
  border-radius: 6px;
}

.servidor-nome {
  color: #e2e8f0;
  font-size: 0.95rem;
}

/* =====================================================
   MELHORIAS VISUAIS - ANALYTICS PREMIUM
   ===================================================== */

/* Cards de estatísticas com gradiente */
.stat-card {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-color: #475569;
}

.stat-card h3 {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, #e2e8f0, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Grid de analytics melhorado */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.analytics-card {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s ease;
}

.analytics-card:hover {
  border-color: #475569;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.analytics-card h3 {
  font-size: 1rem;
  color: #e2e8f0;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Métricas estilizadas */
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #1e293b;
  transition: background 0.2s;
}

.metric-row:hover {
  background: rgba(59, 130, 246, 0.05);
  margin: 0 -12px;
  padding-left: 12px;
  padding-right: 12px;
  border-radius: 8px;
}

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

.metric-label {
  color: #94a3b8;
  font-size: 0.9rem;
}

.metric-value {
  font-weight: 700;
  font-size: 1.2rem;
  color: #e2e8f0;
}

.metric-value.success {
  color: #34d399;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

.metric-value.error {
  color: #f87171;
  text-shadow: 0 0 10px rgba(248, 113, 113, 0.3);
}

.metric-value.warning {
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

/* Barra de progresso animada */
.progress-bar {
  width: 100%;
  height: 10px;
  background: #0f172a;
  border-radius: 5px;
  margin: 15px 0;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
  border-radius: 5px;
  transition: width 1s ease-out;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Gráfico melhorado */
.chart-container {
  padding: 15px 0;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 160px;
  gap: 12px;
  padding-bottom: 15px;
  border-bottom: 1px solid #334155;
}

.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: 6px 6px 0 0;
  min-width: 35px;
  transition: all 0.3s ease;
  position: relative;
  cursor: pointer;
}

.chart-bar:hover {
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
  transform: scaleY(1.05);
}

.chart-bar::after {
  content: attr(data-value);
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  background: #1e293b;
  padding: 2px 8px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}

.chart-bar:hover::after {
  opacity: 1;
}

.chart-labels {
  display: flex;
  justify-content: space-around;
  gap: 12px;
  margin-top: 12px;
}

.chart-label {
  flex: 1;
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
  min-width: 35px;
  font-weight: 500;
}

/* Lista de servidores estilizada */
.servidores-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.servidor-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(145deg, #0f172a, #1e293b);
  border-radius: 10px;
  border: 1px solid #334155;
  transition: all 0.2s;
}

.servidor-item:hover {
  border-color: #475569;
  transform: translateX(4px);
}

.servidor-nome {
  color: #e2e8f0;
  font-size: 0.95rem;
  font-weight: 500;
}

/* Botões de navegação melhorados */
.nav-btn {
  padding: 12px 24px;
  border: 1px solid #334155;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  color: #94a3b8;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.nav-btn:hover {
  background: linear-gradient(145deg, #334155, #1e293b);
  color: #e2e8f0;
  border-color: #475569;
  transform: translateY(-2px);
}

.nav-btn.active {
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: white;
  border-color: #3b82f6;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* Cards gerais melhorados */
.card {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s ease;
}

.card:hover {
  border-color: #475569;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Badges com brilho */
.badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-ativo {
  background: linear-gradient(145deg, #064e3b, #065f46);
  color: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

.badge-expirado {
  background: linear-gradient(145deg, #78350f, #92400e);
  color: #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
}

.badge-sucesso {
  background: linear-gradient(145deg, #065f46, #047857);
  color: #6ee7b7;
  box-shadow: 0 0 10px rgba(110, 231, 183, 0.2);
}

.badge-erro {
  background: linear-gradient(145deg, #991b1b, #b91c1c);
  color: #fca5a5;
  box-shadow: 0 0 10px rgba(252, 165, 165, 0.2);
}

/* Animação de entrada suave */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card,
.analytics-card {
  animation: fadeInUp 0.5s ease-out;
}

/* Responsividade melhorada */
@media (max-width: 768px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-value {
    font-size: 2rem;
  }
  
  .nav-tabs {
    gap: 8px;
  }
  
  .nav-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
}

/* Botoes de variaveis no editor de template */
.variaveis-botoes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #334155;
}

.btn-var {
  padding: 6px 12px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #60a5fa;
  font-family: monospace;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-var:hover {
  background: #334155;
  border-color: #60a5fa;
  transform: translateY(-1px);
}

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

/* Preview de mensagem */
.preview-container {
  margin-top: 15px;
  padding: 15px;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #334155;
}

.preview-container label {
  display: block;
  margin-bottom: 8px;
  color: #94a3b8;
  font-size: 0.9rem;
}

.preview-box {
  padding: 12px;
  background: #1e293b;
  border-radius: 6px;
  border-left: 3px solid #3b82f6;
  color: #e2e8f0;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  min-height: 60px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #334155;
}

th {
  background: #0f172a;
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}

tr:hover {
  background: #252f47;
}

/* Status Badges */
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge-ativo {
  background: #064e3b;
  color: #34d399;
}

.badge-expirado {
  background: #78350f;
  color: #fbbf24;
}

.badge-convertido {
  background: #1e3a8a;
  color: #60a5fa;
}

.badge-perdido {
  background: #7f1d1d;
  color: #f87171;
}

.badge-sucesso {
  background: #065f46;
  color: #6ee7b7;
}

.badge-erro {
  background: #991b1b;
  color: #fca5a5;
}

/* Filters */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filters input,
.filters select {
  padding: 8px 12px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #0f172a;
  color: #e2e8f0;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #1e293b;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid #334155;
}

.modal-large .modal-content {
  max-width: 900px;
}

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

.modal-header h3 {
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.btn-close:hover {
  background: #334155;
  color: #e2e8f0;
}

.modal form {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 16px 24px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast.success {
  background: #10b981;
}

.toast.error {
  background: #ef4444;
}

.toast.info {
  background: #3b82f6;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Cliente Detalhes */
.cliente-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.info-group {
  background: #0f172a;
  padding: 16px;
  border-radius: 8px;
}

.info-group label {
  display: block;
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 5px;
}

.info-group value {
  color: #e2e8f0;
  font-size: 1.1rem;
  font-weight: 500;
}

/* Timeline */
.timeline {
  border-left: 2px solid #334155;
  padding-left: 20px;
  margin: 20px 0;
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3b82f6;
}

.timeline-item.success::before {
  background: #10b981;
}

.timeline-item.error::before {
  background: #ef4444;
}

.timeline-date {
  font-size: 0.85rem;
  color: #64748b;
}

.timeline-content {
  margin-top: 5px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #64748b;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

/* Responsive */
@media (max-width: 768px) {
  .header h1 {
    font-size: 1.8rem;
  }

  .nav-tabs {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters {
    width: 100%;
  }

  .filters input,
  .filters select {
    flex: 1;
  }

  table {
    font-size: 0.9rem;
  }

  th, td {
    padding: 8px;
  }
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: #64748b;
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid #334155;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
