/* ── PROFESSIONAL ENTERPRISE DESIGN SYSTEM (CLEAN B2B SAAS) ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Cores Base Neutras */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  
  /* Sidebar Profissional Escura (Slate 900) */
  --sidebar-bg: #0f172a;
  --sidebar-header-bg: #0b1120;
  --sidebar-nav-text: #94a3b8;
  --sidebar-nav-hover: #1e293b;
  --sidebar-nav-active: #334155;
  --sidebar-nav-active-text: #ffffff;
  --sidebar-section-title: #64748b;
  --sidebar-width: 240px;
  
  /* Cores Tipográficas */
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  
  /* Bordas Sutis & Sharp */
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-dark: #cbd5e1;
  
  /* Paleta de Ação (Refinada & Sóbria) */
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;
  --brand-accent-green: #059669;
  --brand-accent-green-hover: #047857;
  
  /* Cantos Retos e Elegantes (Sem efeito bolha/IA) */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;
  
  /* Sombras Naturais e Sutis */
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --header-height: 58px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── LAYOUT PRINCIPAL ── */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR SLATE */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  border-right: 1px solid #1e293b;
  user-select: none;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--sidebar-header-bg);
  border-bottom: 1px solid #1e293b;
}

.brand-logo-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: var(--radius-xs);
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-section-title);
  padding: 14px 10px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--sidebar-nav-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
  cursor: pointer;
}

.nav-link:hover {
  background-color: var(--sidebar-nav-hover);
  color: #f8fafc;
}

.nav-link.active {
  background-color: var(--sidebar-nav-active);
  color: #ffffff;
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

.nav-link.active .nav-icon {
  color: #ffffff;
}

/* ── SUBMENUS / CADASTROS (CONTROL ID STYLE) ── */
.nav-group {
  margin-top: 2px;
  margin-bottom: 4px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  color: var(--sidebar-nav-text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  user-select: none;
}

.nav-group-header:hover {
  background-color: var(--sidebar-nav-hover);
  color: #f8fafc;
}

.nav-group.active-parent .nav-group-header {
  color: #f8fafc;
}

.nav-group-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: transform 0.2s ease, color 0.15s ease;
}

.nav-group.open .nav-group-chevron {
  transform: rotate(180deg);
  color: #94a3b8;
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding-left: 14px;
  margin-top: 2px;
  position: relative;
}

.nav-group.open .nav-submenu {
  display: flex;
}

.nav-sublink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, padding-left 0.12s ease;
}

.nav-sublink:hover {
  color: #f8fafc;
  background-color: rgba(255, 255, 255, 0.05);
  padding-left: 15px;
}

.sublink-bullet {
  font-size: 14px;
  line-height: 1;
  color: #64748b;
  transition: color 0.12s ease;
}

.nav-sublink:hover .sublink-bullet {
  color: #38bdf8;
}

.nav-sublink.active {
  color: #ffffff;
  font-weight: 600;
  background-color: var(--sidebar-nav-active);
}

.nav-sublink.active .sublink-bullet {
  color: #ffffff;
}

.sidebar-footer {
  padding: 12px 14px;
  background-color: var(--sidebar-header-bg);
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: #334155;
  color: #f8fafc;
  font-weight: 600;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-details {
  overflow: hidden;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 10px;
  color: var(--sidebar-nav-text);
  text-transform: capitalize;
}

/* MAIN WRAPPER */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

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

.user-header-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.user-header-avatar {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  background: var(--brand-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
}

/* BREADCRUMB & HEADER */
.page-top-nav {
  padding: 16px 24px 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}
.breadcrumbs a:hover {
  color: var(--brand-primary);
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

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

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.header-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* CONTENT BODY */
.content-body {
  padding: 0 24px 24px;
  flex: 1;
}

/* ── COMPONENTES CORPORATIVOS LIMPOS ── */

/* CARDS */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

/* BOTÕES LIMPOS (SEM BUBBLE EFFECT) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.4;
}

.btn-green {
  background-color: var(--brand-accent-green);
  color: #ffffff;
}
.btn-green:hover {
  background-color: var(--brand-accent-green-hover);
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--brand-primary-hover);
}

.btn-outline {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border-dark);
}
.btn-outline:hover {
  background-color: var(--bg-surface-subtle);
  border-color: #94a3b8;
}

.btn-danger {
  background-color: #ffffff;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger:hover {
  background-color: #fef2f2;
  border-color: #dc2626;
}

.btn-link {
  background: transparent;
  color: var(--brand-primary);
  padding: 4px 8px;
}
.btn-link:hover {
  text-decoration: underline;
}

/* ── DROPDOWN / POPOVER DE AÇÕES (ESTILO CONTROL ID / MENU FLUTUANTE) ── */
.actions-dropdown-container {
  position: relative;
  display: inline-block;
}

.btn-more-options {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-more-options:hover {
  background-color: #f1f5f9;
  color: var(--brand-primary);
  border-color: #cbd5e1;
}

.btn-more-options:active {
  background-color: #e2e8f0;
}

.actions-popover-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.12), 0 6px 12px -3px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  padding: 8px 0;
  animation: popoverFadeIn 0.15s ease-out;
}

.actions-popover-menu.show {
  display: block;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.popover-arrow {
  position: absolute;
  top: -6px;
  right: 11px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  border-top: 1px solid #e2e8f0;
  transform: rotate(45deg);
  z-index: 1001;
}

.popover-group-title {
  font-size: 11px;
  font-weight: 700;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 16px 4px 16px;
  user-select: none;
}

.popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  background: transparent;
  border: none;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  box-sizing: border-box;
  font-family: inherit;
}

.popover-item:hover {
  background-color: #f8fafc;
  color: var(--brand-primary);
}

.popover-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  flex-shrink: 0;
  transition: color 0.12s ease;
}

.popover-item:hover .popover-item-icon {
  color: var(--brand-primary);
}

.popover-divider {
  height: 1px;
  background-color: #f1f5f9;
  margin: 6px 0;
  border: none;
}

.popover-item-danger {
  color: #dc2626;
}

.popover-item-danger:hover {
  background-color: #fef2f2;
  color: #b91c1c;
}

.popover-item-danger:hover .popover-item-icon {
  color: #dc2626;
}

/* KPI STAT BOXES (CLEAN ENTERPRISE) */
.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-card);
}

.kpi-stat-icon-wrapper {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: var(--text-muted);
}

.kpi-stat-content {
  flex: 1;
}

.kpi-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* SHIMMER SKELETON */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 12px;
  margin-bottom: 6px;
  width: 80%;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-md);
}

.skeleton-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

/* AVATAR UPLOAD COMPONENT */
.avatar-upload-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.avatar-preview-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #e2e8f0;
}

.avatar-upload-info {
  flex: 1;
}

.avatar-upload-btn {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border-dark);
}
.avatar-upload-btn:hover {
  background: #f8fafc;
}

/* PAGINAÇÃO */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 0;
  border-top: 1px solid var(--border-color);
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border-dark);
  background: #ffffff;
  color: var(--text-main);
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.page-btn:hover:not(:disabled) {
  background: var(--bg-surface-subtle);
}
.page-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* FORMULÁRIOS */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.form-control {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
  background-color: var(--bg-surface);
  color: var(--text-main);
}
.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* TABELAS */
.table-responsive { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
.data-table th { padding: 10px 12px; background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--border-color); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-color); color: var(--text-main); vertical-align: middle; }
.data-table tr:hover td { background-color: #f8fafc; }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; font-size: 11px; font-weight: 500; border-radius: var(--radius-xs); border: 1px solid transparent; }
.badge-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.badge-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge-default { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

/* MODAIS */
.modal-backdrop { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.active { display: flex; }
.modal-content { background: var(--bg-surface); border-radius: var(--radius-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-modal); border: 1px solid var(--border-color); }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 14px; font-weight: 700; color: var(--text-main); }
.modal-body { padding: 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 8px; }

/* TOAST */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 6px; }
.toast { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 14px; color: var(--text-main); font-size: 12px; font-weight: 500; box-shadow: var(--shadow-modal); display: flex; align-items: center; gap: 8px; }
.toast.success { border-left: 3px solid var(--brand-accent-green); }
.toast.error   { border-left: 3px solid #ef4444; }
.toast.info    { border-left: 3px solid var(--brand-primary); }

@media print {
  .sidebar, .topbar, .page-top-nav, .organograma-toolbar, .btn, #toast-container { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .content-body { padding: 0 !important; }
}

@media (max-width: 1024px) {
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
