/* Reset e estilos globais */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  background: #0f0f1a;
  color: #ffffff;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Links */
a {
  color: inherit;
  text-decoration: none;
}

/* Utilitários */
.text-muted {
  color: rgba(255, 255, 255, 0.5);
}

.text-primary {
  color: #e94560;
}

/* PAGE HEADER */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 4px 0;
}

.page-header p,
.page-header .subtitle {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  margin: 0;
}

.page-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* BOTÕES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
}

.btn-primary {
  background: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(233, 69, 96, 0.35);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-danger {
  background: linear-gradient(135deg, #c62828 0%, #e53935 100%);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(198, 40, 40, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

.btn-secondary:disabled,
.btn-secondary.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-danger {
  background: rgba(255, 71, 87, 0.1);
  color: #ff6b6b;
  border: 1px solid rgba(255, 71, 87, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 71, 87, 0.2);
}

.btn-toggle {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.2);
}

.btn-toggle.active {
  background: rgba(0, 200, 83, 0.1);
  color: #00c853;
  border-color: rgba(0, 200, 83, 0.2);
}

.btn-cancel {
  padding: 14px 24px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

/* ESTADOS */
.loading-state,
.error-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
}

/* MENSAGENS */
.message {
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 24px;
}

.message.success {
  background: rgba(0, 200, 83, 0.1);
  color: #00c853;
  border: 1px solid rgba(0, 200, 83, 0.2);
}

.message.error {
  background: rgba(255, 71, 87, 0.1);
  color: #ff6b6b;
  border: 1px solid rgba(255, 71, 87, 0.2);
}

.message.warning {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.2);
}

/* FORMULÁRIOS */
.form-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  padding: 32px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: #ffffff;
  font-size: 15px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-group textarea {
  resize: vertical;
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-group select option {
  background: #1a1a2e;
  color: #ffffff;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #e94560;
  background: rgba(255, 255, 255, 0.05);
}

.form-group input.invalid,
.form-group textarea.invalid,
.form-group select.invalid {
  border-color: #ff4757;
}

.error-text {
  color: #ff6b6b;
  font-size: 12px;
}

.field-hint {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* CARDS */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  overflow: hidden;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.card-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.card-body {
  padding: 24px;
}

/* TABELAS */
.table-container {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  overflow: hidden;
}

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

.data-table th {
  padding: 16px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.8);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ACTION BUTTONS */
.actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.action-btn.edit {
  background: rgba(0, 217, 255, 0.1);
  color: rgba(0, 217, 255, 0.8);
}

.action-btn.edit:hover {
  background: rgba(0, 217, 255, 0.2);
  color: #00d9ff;
}

.action-btn.delete {
  background: rgba(255, 71, 87, 0.1);
  color: rgba(255, 71, 87, 0.8);
}

.action-btn.delete:hover {
  background: rgba(255, 71, 87, 0.2);
  color: #ff4757;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* BACK LINK */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 16px;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: #ffffff;
}

/* STATUS BADGES */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 71, 87, 0.1);
  color: #ff6b6b;
}

.status-badge.active {
  background: rgba(0, 200, 83, 0.1);
  color: #00c853;
}

/* Ainda na senha provisória — nem entrou no painel pela primeira vez. */
.status-badge.pending {
  background: rgba(255, 167, 38, 0.12);
  color: #ffa726;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Marca a conta do dono do sistema na listagem, que fora isso é idêntica à de
   um lojista — e não pode ser desativada. */
.role-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(233, 69, 96, 0.12);
  color: #e94560;
}

/* LAYOUT */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 24px;
}

.navbar-brand {
  font-size: 18px;
  font-weight: 700;
  color: #e94560;
}

.navbar-menu {
  display: flex;
  gap: 16px;
  align-items: center;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .page-header h1 {
    font-size: 24px;
  }

  .page-header-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .form-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .form-card {
    padding: 20px;
  }

  .form-actions {
    flex-direction: column;
    gap: 10px;
  }

  .form-actions .btn,
  .form-actions .btn-cancel {
    width: 100%;
    justify-content: center;
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table th,
  .data-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .action-btn {
    width: 32px;
    height: 32px;
  }

  .actions {
    gap: 6px;
  }

  .btn {
    padding: 12px 16px;
    font-size: 13px;
  }
}

/* BUSCA DE LOJISTAS */
.busca-lojistas {
  margin-bottom: 24px;
}

.busca-lojistas form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.busca-lojistas input {
  flex: 1;
  min-width: 240px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  font-size: 14px;
}

.busca-lojistas input:focus {
  outline: none;
  border-color: rgba(233, 69, 96, 0.6);
}

/* Reserva a altura mesmo vazio, para a tabela não pular quando o texto aparece. */
.busca-status {
  min-height: 1em;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  flex-basis: 100%;
}

/* MODAL DE CONFIRMAÇÃO */
.modal {
  padding: 0;
  border: none;
  background: transparent;
  max-width: 480px;
  width: calc(100% - 32px);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  background: #16213e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 28px;
  color: #ffffff;
}

.modal-title {
  font-size: 20px;
  margin-bottom: 12px;
}

.modal-body {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  line-height: 1.6;
}

.modal-body p + p {
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Senha provisória na mensagem de sucesso — precisa ser lida e copiada. */
.senha-provisoria {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  letter-spacing: 0.1em;
  user-select: all;
}
