/* ===== PAINEL ADMINISTRATIVO ===== */

/* Container principal */
.admin-container {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.admin-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-header h2 i {
  color: #a78bfa;
}

/* ===== CARDS DE METRICAS ===== */

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: rgba(30, 32, 50, 0.7);
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.15);
}

.metric-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.metric-icon.purple {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}
.metric-icon.blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}
.metric-icon.green {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
.metric-icon.red {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}
.metric-icon.amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.metric-icon.cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.metric-info h4 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary, #e2e8f0);
  margin: 0;
  line-height: 1;
}

.metric-info p {
  font-size: 0.78rem;
  color: var(--text-secondary, #94a3b8);
  margin: 4px 0 0;
}

/* ===== TABELA DE USUARIOS ===== */

.admin-table-section {
  background: rgba(30, 32, 50, 0.5);
  border: 1px solid rgba(139, 92, 246, 0.1);
  border-radius: 14px;
  overflow: hidden;
}

.admin-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.08);
  flex-wrap: wrap;
  gap: 12px;
}

.admin-table-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-table-header h3 i {
  color: #a78bfa;
}

.admin-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-filter-input {
  background: rgba(15, 17, 30, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  color: var(--text-primary, #e2e8f0);
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
  width: 200px;
}

.admin-filter-input:focus {
  border-color: #a78bfa;
}

.admin-filter-select {
  background: rgba(15, 17, 30, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  color: var(--text-primary, #e2e8f0);
  padding: 8px 10px;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}

.admin-filter-select option {
  background: #1e2032;
}

/* Tabela */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary, #94a3b8);
  text-align: left;
  background: rgba(15, 17, 30, 0.3);
  border-bottom: 1px solid rgba(139, 92, 246, 0.08);
}

.admin-table td {
  padding: 12px 16px;
  font-size: 0.87rem;
  color: var(--text-primary, #e2e8f0);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.admin-table tr:hover td {
  background: rgba(139, 92, 246, 0.04);
}

.admin-table .user-email {
  font-weight: 500;
}

.admin-table .user-company {
  font-size: 0.78rem;
  color: var(--text-secondary, #94a3b8);
}

/* Badges */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.admin-badge.company {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}
.admin-badge.member {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}
.admin-badge.admin {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.admin-badge.active {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}
.admin-badge.overdue {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}
.admin-badge.trial {
  background: rgba(6, 182, 212, 0.12);
  color: #22d3ee;
}
.admin-badge.cancelled {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}
.admin-badge.inactive {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}

/* Acoes */
.admin-actions {
  display: flex;
  gap: 6px;
}

.admin-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.admin-action-btn.view {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
}

.admin-action-btn.toggle {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.admin-action-btn.delete {
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
}

.admin-action-btn:hover {
  transform: scale(1.1);
}

/* Paginacao */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

.admin-page-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.15);
  background: rgba(15, 17, 30, 0.5);
  color: var(--text-primary, #e2e8f0);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.2s;
}

.admin-page-btn:hover {
  border-color: #a78bfa;
}
.admin-page-btn.active {
  background: #7c3aed;
  border-color: #7c3aed;
}
.admin-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.admin-page-info {
  font-size: 0.82rem;
  color: var(--text-secondary, #94a3b8);
}

/* ===== MODAL DE DETALHES ===== */

.admin-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.admin-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.admin-modal {
  background: #1e2032;
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 16px;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.admin-modal-overlay.active .admin-modal {
  transform: scale(1);
}

.admin-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.admin-modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
}

.admin-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.admin-detail-item {
  padding: 10px 14px;
  background: rgba(15, 17, 30, 0.4);
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.06);
}

.admin-detail-item label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.admin-detail-item span {
  font-size: 0.9rem;
  color: var(--text-primary, #e2e8f0);
  font-weight: 500;
}

.admin-detail-full {
  grid-column: 1 / -1;
}

.admin-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(139, 92, 246, 0.08);
}

.admin-modal-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-modal-btn.primary {
  background: #7c3aed;
  color: white;
}
.admin-modal-btn.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.admin-modal-btn.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.admin-modal-btn:hover {
  transform: translateY(-1px);
}

/* Loading */
.admin-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary, #94a3b8);
}

.admin-loading i {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
  color: #a78bfa;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== LIGHT MODE ===== */

/* Header */
[data-theme="light"] .admin-header h2 {
  color: #1e293b;
}

/* Cards de métricas */
[data-theme="light"] .metric-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .metric-card:hover {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
}

[data-theme="light"] .metric-info h4 {
  color: #1e293b;
}

[data-theme="light"] .metric-info p {
  color: #64748b;
}

/* Tabela */
[data-theme="light"] .admin-table-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .admin-table-header {
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .admin-table-header h3 {
  color: #1e293b;
}

[data-theme="light"] .admin-table th {
  background: #f1f5f9;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .admin-table td {
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
}

[data-theme="light"] .admin-table tr:hover td {
  background: #f8fafc;
}

[data-theme="light"] .admin-table .user-email {
  color: #1e293b;
}

[data-theme="light"] .admin-table .user-company {
  color: #64748b;
}

/* Filtros */
[data-theme="light"] .admin-filter-input,
[data-theme="light"] .admin-filter-select {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
}

[data-theme="light"] .admin-filter-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

[data-theme="light"] .admin-filter-input::placeholder {
  color: #94a3b8;
}

[data-theme="light"] .admin-filter-select option {
  background: #ffffff;
  color: #334155;
}

/* Badges — cores mais saturadas para light mode */
[data-theme="light"] .admin-badge.company {
  background: #dbeafe;
  color: #1e40af;
}

[data-theme="light"] .admin-badge.member {
  background: #ede9fe;
  color: #6d28d9;
}

[data-theme="light"] .admin-badge.admin {
  background: #fef3c7;
  color: #b45309;
}

[data-theme="light"] .admin-badge.active {
  background: #dcfce7;
  color: #166534;
}

[data-theme="light"] .admin-badge.overdue {
  background: #fee2e2;
  color: #b91c1c;
}

[data-theme="light"] .admin-badge.trial {
  background: #cffafe;
  color: #0e7490;
}

[data-theme="light"] .admin-badge.cancelled {
  background: #f1f5f9;
  color: #475569;
}

[data-theme="light"] .admin-badge.inactive {
  background: #fee2e2;
  color: #dc2626;
}

/* Botões de ação */
[data-theme="light"] .admin-action-btn.view {
  background: #dbeafe;
  color: #1d4ed8;
}

[data-theme="light"] .admin-action-btn.toggle {
  background: #fef3c7;
  color: #b45309;
}

[data-theme="light"] .admin-action-btn.delete {
  background: #fee2e2;
  color: #dc2626;
}

/* Paginação */
[data-theme="light"] .admin-page-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
}

[data-theme="light"] .admin-page-btn:hover {
  border-color: #7c3aed;
  background: #f5f3ff;
}

[data-theme="light"] .admin-page-btn.active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: white;
}

[data-theme="light"] .admin-page-info {
  color: #64748b;
}

/* Modal */
[data-theme="light"] .admin-modal {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .admin-modal-header h3 {
  color: #1e293b;
}

[data-theme="light"] .admin-modal-close {
  background: #fee2e2;
  color: #dc2626;
}

[data-theme="light"] .admin-detail-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

[data-theme="light"] .admin-detail-item label {
  color: #64748b;
}

[data-theme="light"] .admin-detail-item span {
  color: #1e293b;
}

[data-theme="light"] .admin-modal-actions {
  border-top-color: #e2e8f0;
}

[data-theme="light"] .admin-modal-btn.danger {
  background: #fee2e2;
  color: #dc2626;
}

[data-theme="light"] .admin-modal-btn.warning {
  background: #fef3c7;
  color: #b45309;
}

/* Loading */
[data-theme="light"] .admin-loading {
  color: #64748b;
}

/* ===== RESPONSIVO ===== */

@media (max-width: 768px) {
  .admin-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .admin-filters {
    width: 100%;
  }

  .admin-filter-input {
    width: 100%;
  }

  .admin-table {
    font-size: 0.8rem;
  }

  .admin-table th:nth-child(n + 4),
  .admin-table td:nth-child(n + 4) {
    display: none;
  }

  .admin-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== WEBHOOKS CRM ===== */

.wh-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #94a3b8);
}

.wh-empty i {
  font-size: 2.5rem;
  color: #a78bfa;
  margin-bottom: 12px;
  display: block;
  opacity: 0.5;
}

.wh-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.wh-card {
  background: rgba(15, 17, 30, 0.4);
  border: 1px solid rgba(139, 92, 246, 0.1);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
}

.wh-card:hover {
  border-color: rgba(139, 92, 246, 0.25);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
}

.wh-card.wh-inactive {
  opacity: 0.5;
}

.wh-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.wh-card-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  margin: 0 0 4px;
}

.wh-url {
  font-size: 0.78rem;
  color: #60a5fa;
  word-break: break-all;
}

.wh-card-events {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.wh-event-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.12);
  color: #a78bfa;
}

.wh-event-tag.wh-secret {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}

.wh-card-footer {
  display: flex;
  gap: 6px;
  border-top: 1px solid rgba(139, 92, 246, 0.06);
  padding-top: 10px;
}

/* Toggle switch */
.wh-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.wh-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.wh-toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(107, 114, 128, 0.4);
  border-radius: 24px;
  transition: 0.3s;
}

.wh-toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.wh-toggle input:checked + .wh-toggle-slider {
  background: #7c3aed;
}

.wh-toggle input:checked + .wh-toggle-slider::before {
  transform: translateX(20px);
}

/* Form */
.wh-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wh-form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.wh-events-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.wh-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(15, 17, 30, 0.4);
  border: 1px solid rgba(139, 92, 246, 0.08);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-primary, #e2e8f0);
  cursor: pointer;
  transition: all 0.2s;
}

.wh-checkbox:hover {
  border-color: rgba(139, 92, 246, 0.3);
}

.wh-checkbox input[type="checkbox"] {
  accent-color: #7c3aed;
  width: 16px;
  height: 16px;
}

/* Logs */
.wh-logs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.wh-log-item {
  padding: 10px 14px;
  border-radius: 10px;
  border-left: 3px solid transparent;
}

.wh-log-success {
  background: rgba(34, 197, 94, 0.06);
  border-left-color: #4ade80;
}

.wh-log-error {
  background: rgba(239, 68, 68, 0.06);
  border-left-color: #f87171;
}

.wh-log-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wh-log-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
}

.wh-log-date {
  font-size: 0.75rem;
  color: var(--text-secondary, #94a3b8);
  margin-left: auto;
}

.wh-log-error-msg {
  font-size: 0.78rem;
  color: #f87171;
  margin-top: 6px;
  font-family: monospace;
}

/* ===== WEBHOOKS LIGHT MODE ===== */

[data-theme="light"] .wh-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .wh-card:hover {
  border-color: #c4b5fd;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.08);
}

[data-theme="light"] .wh-card-info h4 {
  color: #1e293b;
}

[data-theme="light"] .wh-url {
  color: #2563eb;
}

[data-theme="light"] .wh-event-tag {
  background: #ede9fe;
  color: #6d28d9;
}

[data-theme="light"] .wh-event-tag.wh-secret {
  background: #dcfce7;
  color: #166534;
}

[data-theme="light"] .wh-checkbox {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #334155;
}

[data-theme="light"] .wh-log-success {
  background: #f0fdf4;
}

[data-theme="light"] .wh-log-error {
  background: #fef2f2;
}

[data-theme="light"] .wh-log-status {
  color: #1e293b;
}

[data-theme="light"] .wh-log-date {
  color: #64748b;
}
