/* ==========================================================================
   Admin Styles — Zari Running Control Panel
   ========================================================================== */
/* Tokens e paleta de cores são importados via theme-zari.css */

/* RESET & BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg-body);
  color: var(--color-text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'tnum';
  font-size: 14px;
  line-height: 1.5;
}

/* APP SHELL & LAYOUT */
.app-layout, .app-container, .admin-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--color-bg-body);
}

/* SIDEBAR ESQUERDA */
.sidebar {
  width: 285px;
  background-color: var(--color-bg-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
  border-right: 1px solid var(--sidebar-borda-suave);
}

.sidebar-header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-border-subtle);
  flex-shrink: 0;
  min-height: 64px;
}

.sidebar-brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  overflow: hidden;
}

.sidebar-full-logo {
  max-height: 38px;
  max-width: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--sidebar-bg-subtle-08);
  border: 1px solid var(--sidebar-border-subtle-12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 15px;
  font-family: var(--font-heading);
  flex-shrink: 0;
  box-shadow: var(--sombra-avatar-dark);
  overflow: hidden;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-bg-surface);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-menu,
.sidebar-nav {
  padding: 16px 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav::-webkit-scrollbar,
.sidebar-menu::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track,
.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.sidebar-menu::-webkit-scrollbar-thumb {
  background: var(--sidebar-bg-subtle-15);
  border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover,
.sidebar-menu::-webkit-scrollbar-thumb:hover {
  background: var(--sidebar-bg-subtle-25);
}

.menu-category {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-sidebar-muted);
  padding: 12px 14px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--color-sidebar-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--color-bg-surface);
  background: var(--color-sidebar-hover);
}

.nav-item.active {
  color: var(--color-bg-surface);
  background: var(--color-sidebar-active);
  font-weight: 600;
  border-left: 3px solid var(--color-primary);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

/* CARD DO USUÁRIO LOGADO NO RODAPÉ DA SIDEBAR */
.sidebar-footer {
  margin: 12px 14px 16px 14px;
  padding: 12px 14px;
  background: var(--sidebar-bg-subtle-04);
  border: 1px solid var(--sidebar-border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sidebar-card-gradient);
  border: 1px solid var(--sidebar-border-subtle-14);
  color: var(--color-bg-surface);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: var(--sombra-avatar-dark);
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-bg-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--color-sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--color-sidebar-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* ÁREA DE CONTEÚDO PRINCIPAL */
.main-content, .main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--color-bg-body);
}

/* TOPBAR */
.topbar {
  height: 68px;
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-sizing: border-box;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-left .page-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.01em;
}

.impersonation-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

/* Quando Todas as Assessorias (Visão Master / Global) está selecionada */
.impersonation-bar.is-all-selected {
  background: var(--enxoval-card-gradient);
  border: 1.5px solid var(--enxoval-card-border);
  padding: 4px 10px;
  box-shadow: var(--enxoval-card-shadow);
}

.impersonation-bar.is-all-selected .impersonation-label {
  color: var(--zari-navy);
  font-weight: 700;
}

/* Quando uma assessoria específica está ativa */
.impersonation-bar.is-impersonating {
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-bg-surface));
  border: 1.5px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
  padding: 4px 10px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--color-primary) 12%, transparent);
}

.impersonation-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.impersonation-bar.is-impersonating .impersonation-label {
  color: var(--color-primary);
  font-weight: 700;
}

.impersonation-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.impersonation-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  padding: 8px 36px 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-main);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 290px;
}

.impersonation-select:hover {
  border-color: var(--zari-teal);
  background: var(--color-bg-surface);
}

.impersonation-select:focus {
  border-color: var(--zari-teal);
  box-shadow: var(--enxoval-focus-ring);
  background: var(--color-bg-surface);
}

/* Destaque quando Todas as Assessorias selecionadas */
.impersonation-select.is-all-selected {
  background: var(--color-bg-surface);
  border: 1.5px solid var(--zari-teal);
  color: var(--zari-navy);
  font-weight: 700;
  box-shadow: var(--enxoval-card-badge-shadow);
}

.impersonation-select.is-all-selected:hover {
  border-color: var(--zari-teal-dark);
  box-shadow: var(--enxoval-card-badge-hover-shadow);
}

.impersonation-select.is-all-selected + .select-chevron-icon {
  color: var(--zari-teal);
}

/* Destaque vivo com a cor primária da assessoria quando individual selecionada */
.impersonation-select.is-impersonating {
  background: var(--color-bg-surface);
  border: 2px solid var(--color-primary);
  color: var(--color-text-main);
  font-weight: 700;
  box-shadow: 0 1px 6px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.impersonation-select.is-impersonating:hover,
.impersonation-select.is-impersonating:focus {
  border-color: var(--color-primary-hover);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 22%, transparent);
}

.select-chevron-icon {
  position: absolute;
  right: 12px;
  pointer-events: none;
  color: var(--color-text-muted);
}

.impersonation-select.is-impersonating + .select-chevron-icon {
  color: var(--color-primary);
}

.btn-reset-impersonation {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-reset-impersonation:hover {
  background: var(--color-border-light);
  border-color: var(--zari-teal);
  color: var(--zari-navy);
}

.impersonation-bar.is-impersonating .btn-reset-impersonation {
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
}

.impersonation-bar.is-impersonating .btn-reset-impersonation:hover {
  background: color-mix(in srgb, var(--color-primary) 10%, var(--color-bg-surface));
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* CORPO DE CONTEÚDO (COM RESPIROS E ALINHAMENTO PERFEITO) */
.content-body {
  padding: 32px 36px 60px 36px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* CARDS & METRICS */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  width: 100%;
  margin-bottom: 28px;
}

@media (max-width: 1200px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.metric-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  transition: all 0.2s ease;
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.metric-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.metric-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-text-main);
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 6px;
}

.metric-delta {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.metric-delta.delta-up {
  color: var(--color-primary);
}

/* DATA TABLES & CARDS */
.data-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 28px;
}

.data-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
}

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

.data-table th {
  background: var(--color-bg-subtle);
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 13.5px;
  color: var(--color-text-main);
}

.data-table tbody tr:hover {
  background: var(--color-bg-subtle);
}

/* SUBTABS NAVEGAÇÃO */
.subtabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
}

.subtab-btn {
  padding: 10px 18px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.subtab-btn:hover {
  color: var(--color-text-main);
}

.subtab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.subtab-pane, .subtab-pane-planos, .subtab-pane-termos, .subtab-pane-cat, .subtab-pane-mtdl, .subtab-pane-ia, .subtab-pane-conv, .subtab-pane-nar, .subtab-pane-acomp {
  display: none;
  animation: fadeIn 0.15s ease;
}

.subtab-pane.active, .subtab-pane-planos.active, .subtab-pane-termos.active, .subtab-pane-cat.active, .subtab-pane-mtdl.active, .subtab-pane-ia.active, .subtab-pane-conv.active, .subtab-pane-nar.active, .subtab-pane-acomp.active {
  display: block !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

