/* ===== ADMIN PANEL STYLES ===== */

.admin-body {
  background: #F1F5F9;
  min-height: 100vh;
}

/* ========== LOGIN SCREEN ========== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,107,26,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255,143,74,0.1) 0%, transparent 50%),
    linear-gradient(135deg, #1A1A2E 0%, #16213E 50%, #0F3460 100%);
}
.login-card {
  background: white;
  padding: 48px;
  border-radius: 24px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.3);
  max-width: 440px;
  width: 100%;
  animation: popIn 0.5s;
}
.login-logo {
  height: 56px;
  margin: 0 auto 24px;
  display: block;
}
.login-card h1 {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  color: #1A1A2E;
}
.login-sub {
  text-align: center;
  color: #718096;
  margin-bottom: 28px;
  font-size: 0.95rem;
}
.login-notice {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-left: 4px solid #FF6B1A;
  padding: 14px 16px;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 0.85rem;
  color: #7C2D12;
}
.login-notice i {
  color: #FF6B1A;
  flex-shrink: 0;
  margin-top: 2px;
}
.login-form .form-group { margin-bottom: 18px; }
.login-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: #4A5568;
}
.login-form input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #E2E8F0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.login-form input:focus {
  outline: none;
  border-color: #FF6B1A;
  box-shadow: 0 0 0 3px rgba(255,107,26,0.1);
}
.login-back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding: 12px;
  color: #718096;
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 8px;
  transition: background 0.2s;
}
.login-back:hover {
  background: #F7FAFC;
  color: #FF6B1A;
}

/* Login error box */
.login-error {
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  border-left: 4px solid #E53E3E;
  padding: 12px 16px;
  border-radius: 8px;
  color: #991B1B;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  animation: shakeX 0.4s;
}
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Test credentials dropdown */
.test-credentials {
  margin-top: 16px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
}
.test-credentials summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: #4A5568;
  background: #F8FAFC;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}
.test-credentials summary:hover {
  background: #F1F5F9;
}
.test-credentials summary::-webkit-details-marker { display: none; }
.test-credentials summary::after {
  content: '▼';
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.test-credentials[open] summary::after {
  transform: rotate(180deg);
}
.test-credentials-content {
  padding: 16px;
  background: white;
  border-top: 1px solid #E2E8F0;
}
.credentials-help {
  font-size: 0.8rem;
  color: #718096;
  margin-bottom: 12px;
}
.credential-item {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.credential-item:hover {
  border-color: #FF6B1A;
  background: #FFF7ED;
  transform: translateY(-1px);
}
.credential-item:last-child { margin-bottom: 0; }
.cred-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.cred-header strong {
  font-size: 0.9rem;
  color: #1A1A2E;
}
.cred-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-admin { background: #FEE2E2; color: #991B1B; }
.badge-gerente { background: #E9D5FF; color: #6B21A8; }
.badge-comercial { background: #DBEAFE; color: #1E40AF; }
.badge-visualizador { background: #F1F5F9; color: #475569; }
.cred-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: #64748B;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}
.cred-details i {
  width: 14px;
  color: #94A3B8;
}

/* ========== LAYOUT ========== */
.admin-wrapper {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.admin-sidebar {
  background: #1A1A2E;
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  padding: 12px;
  margin-bottom: 32px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 24px;
}
.sidebar-logo img {
  height: 40px;
  filter: brightness(0) invert(1);
}
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  position: relative;
}
.sidebar-link i {
  width: 20px;
  text-align: center;
}
.sidebar-link:hover:not(.disabled) {
  background: rgba(255,255,255,0.08);
  color: white;
}
.sidebar-link.active {
  background: #FF6B1A;
  color: white;
  box-shadow: 0 4px 12px rgba(255,107,26,0.4);
}
.sidebar-link.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.badge-soon {
  margin-left: auto;
  font-size: 0.65rem;
  background: rgba(255,255,255,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.logout-btn {
  color: #FCA5A5 !important;
}
.logout-btn:hover {
  background: rgba(252,165,165,0.1) !important;
}

/* ========== MAIN ========== */
.admin-main {
  padding: 32px 40px;
  overflow-x: auto;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}
.admin-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: #1A1A2E;
  margin-bottom: 4px;
}
.admin-breadcrumb {
  color: #718096;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.admin-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-info {
  text-align: right;
}
.user-name {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: #1A1A2E;
}
.user-role {
  font-size: 0.75rem;
  color: #718096;
}
.user-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #FF6B1A, #FF8F4A);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(255,107,26,0.3);
}

/* ========== STATS ========== */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-box {
  background: white;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--c);
  transition: transform 0.2s;
}
.stat-box:hover { transform: translateY(-2px); }
.stat-icon {
  width: 52px;
  height: 52px;
  background: color-mix(in srgb, var(--c) 15%, transparent);
  color: var(--c);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-box-number {
  font-size: 1.8rem;
  font-weight: 900;
  color: #1A1A2E;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-box-label {
  font-size: 0.85rem;
  color: #718096;
  font-weight: 600;
}

/* ========== FILTERS ========== */
.admin-filters {
  background: white;
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08);
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 24px;
}
.filter-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4A5568;
  margin-bottom: 6px;
}
.filter-group input,
.filter-group select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #E2E8F0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.2s;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #FF6B1A;
}
.btn-outline-dark {
  background: white;
  color: #4A5568;
  border: 2px solid #E2E8F0;
  padding: 10px 20px;
}
.btn-outline-dark:hover {
  background: #F7FAFC;
  border-color: #FF6B1A;
  color: #FF6B1A;
}

/* ========== TABLE ========== */
.admin-table-wrap {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08);
  overflow: hidden;
}
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #E2E8F0;
}
.table-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1A1A2E;
  display: flex;
  align-items: center;
  gap: 10px;
}
.table-header h2 i { color: #FF6B1A; }
.table-count {
  background: #F1F5F9;
  color: #4A5568;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.table-responsive {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
}
.admin-table thead {
  background: #F8FAFC;
}
.admin-table th {
  padding: 14px 20px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.admin-table td {
  padding: 16px 20px;
  font-size: 0.9rem;
  border-top: 1px solid #F1F5F9;
  color: #2D3748;
  vertical-align: middle;
}
.admin-table tbody tr {
  transition: background 0.15s;
}
.admin-table tbody tr:hover {
  background: #FAFBFC;
}
.loading-row, .empty-row {
  text-align: center !important;
  padding: 40px !important;
  color: #718096 !important;
}

.cell-primary {
  font-weight: 600;
  color: #1A1A2E;
  margin-bottom: 2px;
}
.cell-secondary {
  font-size: 0.8rem;
  color: #718096;
}
.cell-email {
  color: #3182CE;
  text-decoration: none;
  font-size: 0.85rem;
}
.cell-email:hover { text-decoration: underline; }
.cell-phone {
  font-size: 0.8rem;
  color: #718096;
  display: block;
  margin-top: 2px;
}
.uf-badge {
  display: inline-block;
  background: #FF6B1A;
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 6px;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status-novo {
  background: #EBF5FF;
  color: #1E40AF;
}
.status-em_analise {
  background: #FEF3C7;
  color: #92400E;
}
.status-contatado {
  background: #E9D5FF;
  color: #6B21A8;
}
.status-aprovado {
  background: #D1FAE5;
  color: #065F46;
}
.status-recusado {
  background: #FEE2E2;
  color: #991B1B;
}

/* Action buttons */
.action-btn {
  background: transparent;
  border: 1px solid #E2E8F0;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #4A5568;
  transition: all 0.2s;
  margin-right: 4px;
}
.action-btn:hover {
  background: #FF6B1A;
  color: white;
  border-color: #FF6B1A;
}
.action-btn.delete:hover {
  background: #E53E3E;
  border-color: #E53E3E;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state i {
  font-size: 3rem;
  color: #CBD5E0;
  margin-bottom: 16px;
}
.empty-state h3 {
  color: #4A5568;
  margin-bottom: 8px;
}
.empty-state p {
  color: #718096;
  margin-bottom: 20px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s; }
.modal-box {
  background: white;
  border-radius: 20px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px;
  position: relative;
  animation: popIn 0.3s;
}
.modal-lg { max-width: 800px; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #F1F5F9;
  cursor: pointer;
  color: #4A5568;
  transition: all 0.2s;
}
.modal-close:hover {
  background: #E2E8F0;
  transform: rotate(90deg);
}
.modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1A1A2E;
  margin-bottom: 8px;
}
.modal-subtitle {
  color: #718096;
  margin-bottom: 28px;
  font-size: 0.9rem;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.detail-item {
  background: #F8FAFC;
  padding: 16px;
  border-radius: 10px;
  border-left: 3px solid #FF6B1A;
}
.detail-label {
  font-size: 0.72rem;
  color: #718096;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.detail-value {
  color: #1A1A2E;
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-word;
}
.detail-full { grid-column: 1 / -1; }

/* Pontas A/B no modal */
.endpoint-detail {
  border-left: 4px solid;
  padding: 18px !important;
}
.endpoint-a-detail {
  border-left-color: #FF6B1A;
  background: linear-gradient(135deg, #FFF7ED, #F8FAFC) !important;
}
.endpoint-b-detail {
  border-left-color: #1E88E5;
  background: linear-gradient(135deg, #EFF6FF, #F8FAFC) !important;
}
.endpoint-detail .detail-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem !important;
  margin-bottom: 10px !important;
}
.endpoint-badge-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: none;
  letter-spacing: 0;
}
.endpoint-a-sm { background: linear-gradient(135deg, #FF6B1A, #FF8F4A); }
.endpoint-b-sm { background: linear-gradient(135deg, #1E88E5, #42A5F5); }
.endpoint-value {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}
.endpoint-value i {
  color: #94A3B8;
  width: 16px;
  margin-right: 4px;
}

/* Observação de coordenadas */
.coord-obs {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(255, 107, 26, 0.08);
  border-left: 3px solid #FF6B1A;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #4A5568;
  line-height: 1.5;
}
.coord-obs i {
  color: #FF6B1A !important;
  width: auto !important;
  margin-right: 6px !important;
}
.coord-obs strong {
  color: #1A1A2E;
  font-weight: 700;
}

/* Rota na tabela (célula compacta) */
.route-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.route-arrow {
  color: #FF6B1A;
  font-size: 0.75rem;
  margin: 0 2px;
}
.detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid #E2E8F0;
}
.detail-actions select {
  padding: 10px 14px;
  border: 2px solid #E2E8F0;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: white;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 968px) {
  .admin-wrapper {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
  }
  .sidebar-logo {
    margin-bottom: 0;
    border-bottom: none;
    padding: 0;
    margin-right: 16px;
    border-right: 1px solid rgba(255,255,255,0.1);
    padding-right: 16px;
  }
  .sidebar-logo img { height: 32px; }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
  }
  .sidebar-link span { display: none; }
  .sidebar-link i { font-size: 1.1rem; }
  .badge-soon { display: none; }
  .sidebar-footer {
    border-top: none;
    padding-top: 0;
    flex-direction: row;
    margin-left: auto;
  }
  .admin-main { padding: 20px; }
  .admin-filters {
    grid-template-columns: 1fr;
  }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .admin-main { padding: 16px; }
  .modal-box { padding: 24px; }
  .admin-header { flex-direction: column; align-items: flex-start; }
}
