/* ============================================================
   PAINEL ADMINISTRATIVO – Estilos
   ============================================================ */

/* LAYOUT GERAL */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
  padding-top: 70px;
  background: #F1F5F9;
}

/* SIDEBAR */
.admin-sidebar {
  width: 240px;
  min-width: 240px;
  background: white;
  border-right: 1px solid var(--border);
  height: calc(100vh - 70px);
  position: sticky;
  top: 70px;
  overflow-y: auto;
  transition: width 0.3s ease;
  flex-shrink: 0;
}

.admin-sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.admin-sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.admin-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.admin-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}

.admin-role {
  font-size: 0.75rem;
  color: var(--text-light);
}

.admin-nav {
  padding: 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.admin-nav-section {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  padding: 0.8rem 0.7rem 0.3rem;
  margin-top: 0.3rem;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.admin-nav-item i {
  width: 16px;
  text-align: center;
  font-size: 0.85rem;
}

.admin-nav-item:hover {
  background: var(--gray-light);
  color: var(--text);
}

.admin-nav-item.active {
  background: rgba(10,36,99,0.08);
  color: var(--primary);
  font-weight: 700;
}

/* MAIN */
.admin-main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem;
  overflow-x: hidden;
}

/* TOPBAR */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle-btn {
  width: 36px;
  height: 36px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
  background: var(--gray-light);
  color: var(--text);
}

.admin-page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Montserrat', sans-serif;
}

.admin-topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light);
}

.admin-filter select {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text);
  background: white;
  outline: none;
  cursor: pointer;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* LOADING */
.loading-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* VIEWS */
.admin-view { display: none; }
.admin-view.active { display: block; }

/* KPI CARDS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: center;
  transition: all 0.3s ease;
}

.kpi-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.kpi-card.kpi-wide { /* Para view de indicadores */ }

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  margin: 0 auto 0.8rem;
}

.kpi-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  font-family: 'Montserrat', sans-serif;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 500;
  line-height: 1.3;
}

/* CHARTS */
.charts-row {
  display: flex;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.chart-card-header h4 {
  font-size: 0.92rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 7px;
}

.chart-card-header h4 i {
  color: var(--primary-light);
  font-size: 0.85rem;
}

/* TABELAS */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.admin-table th {
  padding: 10px 12px;
  background: #F8FAFC;
  border-bottom: 2px solid var(--border);
  color: var(--text-light);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.admin-table tr:hover td {
  background: #FAFBFD;
}

.table-empty {
  text-align: center !important;
  color: var(--text-light);
  padding: 2.5rem !important;
  font-size: 0.9rem;
}

/* TAGS / BADGES */
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag-success { background: rgba(16,185,129,0.12); color: var(--success); }
.tag-danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.tag-warning { background: rgba(245,158,11,0.1); color: #D97706; }
.tag-info-badge { background: rgba(10,36,99,0.08); color: var(--primary-light); }
.tag-muted { background: var(--gray-light); color: var(--text-light); }

/* BUNDLE CHECKS */
.bundle-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
}

.bundle-check.ok { background: rgba(16,185,129,0.15); color: var(--success); }
.bundle-check.fail { background: rgba(239,68,68,0.1); color: var(--danger); }

/* AÇÕES */
.btn-action {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 0.2s;
  margin-right: 4px;
}

.btn-action:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-action.btn-del:hover { background: var(--danger); border-color: var(--danger); }

/* PAGINAÇÃO */
.table-pagination {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--text-light);
}

.page-info { font-weight: 500; }

.page-btn {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}

.page-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* VIEW HEADER */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.view-header h2 {
  font-size: 1.3rem;
  color: var(--primary);
}

.view-header-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.search-input {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
  width: 260px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(27,79,191,0.1);
}

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h3 {
  font-size: 1.05rem;
  color: var(--primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-light);
  border-radius: 6px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover { background: var(--danger); color: white; }

.modal-body { padding: 1.5rem; }

.modal-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.modal-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-field-value {
  font-size: 0.88rem;
  color: var(--text);
}

/* RESPONSIVE */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    left: -240px;
    top: 70px;
    z-index: 900;
    transition: left 0.3s ease;
  }
  .admin-sidebar.open {
    left: 0;
  }
  .charts-row { flex-direction: column; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-main { padding: 1rem; }
  .search-input { width: 180px; }
  .modal-fields { grid-template-columns: 1fr; }
}
