/* Design System & Reset */
:root {
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Color Palette (SOU Clube Theme) */
  --bg-app: #2C3333;
  --bg-card: rgba(20, 87, 68, 0.15);
  --bg-card-hover: rgba(20, 87, 68, 0.3);
  --border-color: rgba(230, 222, 216, 0.15);
  --border-color-hover: rgba(230, 222, 216, 0.3);
  --text-primary: #FAFAFA;
  --text-secondary: #E6DED8;
  --text-muted: #9DAF9B;

  /* Accents & Roles */
  --primary-color: #145744;
  --primary-glow: rgba(20, 87, 68, 0.35);

  --role-gestor-bg: linear-gradient(135deg, #145744, #0B2F28);
  --role-gestor-glow: rgba(20, 87, 68, 0.25);

  --role-parceiro-bg: linear-gradient(135deg, #D97A62, #b5624d);
  --role-parceiro-glow: rgba(217, 122, 98, 0.25);

  --role-indicador-bg: linear-gradient(135deg, #7E8767, #656d51);
  --role-indicador-glow: rgba(126, 135, 103, 0.25);

  --danger-color: #D97A62;
  --danger-glow: rgba(217, 122, 98, 0.3);
  --success-color: #145744;
  --success-glow: rgba(20, 87, 68, 0.3);

  /* Layout sizes */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 25px var(--primary-glow);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  background-image:
    radial-gradient(at 0% 0%, rgba(217, 122, 98, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(20, 87, 68, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Custom Scrollbar */
::-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: var(--radius-sm);
}

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

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
  gap: 1.5rem;
  min-height: 100vh;
}

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1.25rem 2rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
  line-height: 1;
  background: linear-gradient(135deg, #D97A62, #145744);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 10px rgba(217, 122, 98, 0.3);
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-area .divider {
  color: var(--border-color);
  font-weight: 300;
  font-size: 1.25rem;
}

.logo-area .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.backup-group {
  display: flex;
  gap: 0.5rem;
  border-left: 1px solid var(--border-color);
  padding-left: 0.75rem;
  margin-left: 0.25rem;
}

/* Filter & Search Bar */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
  background: rgba(0, 0, 0, 0.35);
}

.filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.select-input {
  padding: 0.65rem 2rem 0.65rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  transition: var(--transition-fast);
}

.select-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.results-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(139, 92, 246, 0.15);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  border: 1px solid rgba(139, 92, 246, 0.25);
  margin-left: auto;
}

/* Main Content Workspace */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 968px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* Card Styles (Glassmorphism) */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: border-color var(--transition-normal);
}

.card:hover {
  border-color: var(--border-color-hover);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

/* Help Tooltip */
.help-tooltip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: help;
  border: 1px solid var(--border-color);
  transition: var(--transition-fast);
}

.help-tooltip:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

/* Tree Viewer Specific Styles */
.tree-container {
  min-height: 500px;
}

.tree-root {
  overflow-y: auto;
  max-height: 650px;
  padding-right: 0.5rem;
}

/* Rendering the hierarchical structure with lines */
.tree-list {
  list-style: none;
  position: relative;
  padding-left: 1.5rem;
}

.tree-root>.tree-list {
  padding-left: 0;
}

.tree-item {
  position: relative;
  margin: 0.5rem 0;
}

/* Connectors using pseudoelements */
.tree-list:not(.root-list)::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0.5rem;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.08);
}

.tree-item::before {
  content: "";
  position: absolute;
  top: 1.15rem;
  left: -1rem;
  width: 1rem;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.tree-root>.tree-list>.tree-item::before {
  display: none;
  /* No connector for root item */
}

/* Tree Node Card design */
.tree-node-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tree-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-normal);
  flex-grow: 1;
  max-width: 480px;
}

.tree-node:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateX(2px);
}

.tree-node.selected {
  background: rgba(139, 92, 246, 0.08);
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

/* Node Contents */
.node-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.node-info-text {
  display: flex;
  flex-direction: column;
}

.node-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.node-title-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Toggle Expand/Collapse */
.node-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  z-index: 2;
}

.node-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.node-toggle-btn svg {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-normal);
}

.node-toggle-btn.expanded svg {
  transform: rotate(90deg);
}

/* Actions inline for node */
.node-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.tree-node:hover .node-actions {
  opacity: 1;
}

/* Badge colors for roles */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.badge-gestor {
  background: var(--role-gestor-bg);
  box-shadow: 0 0 10px var(--role-gestor-glow);
}

.badge-parceiro {
  background: var(--role-parceiro-bg);
  box-shadow: 0 0 10px var(--role-parceiro-glow);
}

.badge-indicador {
  background: var(--role-indicador-bg);
  box-shadow: 0 0 10px var(--role-indicador-glow);
}

/* Collapsible submenu transition styles */
.tree-children {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--transition-normal), opacity var(--transition-normal);
}

.tree-children.visible {
  max-height: 2000px;
  /* high value to allow expansion */
  opacity: 1;
}

/* Search Highlighting */
.tree-node.highlighted {
  border-color: var(--success-color);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.05);
}

.tree-node.highlighted-dimmed {
  opacity: 0.4;
}

/* Detail Section & Forms */
.detail-container {
  position: sticky;
  top: 1.5rem;
}

.no-selection-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.panel-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.no-selection-state p {
  font-size: 0.9rem;
  max-width: 280px;
}

/* Profile Content Panel Details */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.profile-avatar {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.profile-avatar.Gestor {
  background: var(--role-gestor-bg);
  box-shadow: 0 0 15px var(--role-gestor-glow);
}

.profile-avatar.Parceiro {
  background: var(--role-parceiro-bg);
  box-shadow: 0 0 15px var(--role-parceiro-glow);
}

.profile-avatar.Indicador {
  background: var(--role-indicador-bg);
  box-shadow: 0 0 15px var(--role-indicador-glow);
}

.profile-title-group h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.profile-details-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Button UI Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.btn-primary:hover {
  background: #7c3aed;
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.btn-success {
  background: var(--success-color);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  background: #059669;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.2);
  color: var(--danger-color);
}

.btn-danger:hover {
  background: var(--danger-color);
  color: white;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.2);
  transform: translateY(-1px);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.w-100 {
  width: 100%;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-fast);
  padding: 0 0.5rem;
}

.btn-close:hover {
  color: var(--text-primary);
}

/* Forms Styling */
.form-group {
  margin-bottom: 1.25rem;
}

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

@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

select option {
  background-color: #1e293b;
  color: var(--text-primary);
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.error-msg {
  display: none;
  font-size: 0.75rem;
  color: var(--danger-color);
  margin-top: 0.25rem;
  font-weight: 500;
}

input.is-invalid,
select.is-invalid {
  border-color: var(--danger-color);
}

input.is-invalid+.error-msg,
select.is-invalid+.error-msg {
  display: block;
}

.form-actions-sticky {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

/* Modals Overlay & Content */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 7, 13, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
  animation: fadeIn var(--transition-fast);
}

.modal-content {
  width: 100%;
  max-width: 540px;
  animation: scaleUp var(--transition-normal) cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
}

.max-w-md {
  max-width: 460px;
}

.modal-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Parent Selection List inside Move Modal */
.parent-selection-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.15);
  margin-bottom: 1rem;
}

.parent-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-fast);
}

.parent-select-item:last-child {
  border-bottom: none;
}

.parent-select-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.parent-select-item.selected {
  background: rgba(139, 92, 246, 0.12);
  border-left: 3px solid var(--primary-color);
}

.parent-select-name {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Strategy/Delete Options */
.strategy-warning {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.strategy-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.01);
}

.strategy-option:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-color-hover);
}

.strategy-option input[type="radio"] {
  margin-top: 0.25rem;
  accent-color: var(--primary-color);
}

.option-details {
  display: flex;
  flex-direction: column;
}

.option-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.option-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.strategy-option.danger input[type="radio"] {
  accent-color: var(--danger-color);
}

.strategy-option.danger:hover {
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.02);
}

.mt-lg {
  margin-top: 2rem;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--primary-color);
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.2);
  color: white;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideInRight var(--transition-normal);
}

.toast.success {
  border-color: var(--success-color);
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
}

.toast.error {
  border-color: var(--danger-color);
  box-shadow: 0 10px 30px rgba(244, 63, 94, 0.2);
}

/* Loading Spinners */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

/* Utilities / Animations */
.fade-in {
  animation: fadeIn var(--transition-normal);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleUp {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

/* WhatsApp and Email status specific styles */
.detail-value-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.btn-whatsapp-link:hover {
  transform: scale(1.15);
  filter: drop-shadow(0 0 6px rgba(37, 211, 102, 0.5));
}

.email-status-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 2px;
}

/* ==========================================================================
   Módulo de Clientes e Propostas (Abas, Listas e Uploads)
   ========================================================================== */

/* Tabs Styling */
.tabs-container {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
  gap: 0.25rem;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--text-primary);
  background: var(--primary-color);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

/* Tab panes switching */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Client List inside Tab 2 */
.clients-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  padding-right: 0.25rem;
}

.client-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: var(--transition-fast);
}

.client-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-color-hover);
}

.client-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.client-item-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0;
}

.client-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.client-meta-label {
  color: var(--text-muted);
}

.client-meta-val {
  font-weight: 500;
  color: var(--text-secondary);
}

.client-item-actions {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.75rem;
  flex-wrap: wrap;
}

/* Client status badges */
.badge-status {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

.badge-status.pendente {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.badge-status.proposta_gerada {
  background: rgba(234, 179, 8, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge-status.proposta_aceita {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.contrato_gerado {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Unidades Consumidoras Table Rows styling */
.uc-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 1.2fr 40px;
  gap: 0.5rem;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
}

@media (max-width: 768px) {
  .uc-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

.uc-row input,
.uc-row select {
  padding: 0.5rem;
  font-size: 0.85rem;
}

.btn-remove-uc {
  height: 34px;
  width: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: var(--danger-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-remove-uc:hover {
  background: var(--danger-color);
  color: white;
}

/* Document upload status list styles */
.uploaded-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-top: 0.25rem;
  font-size: 0.85rem;
}

.uploaded-file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.uploaded-file-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}

.uploaded-file-link:hover {
  text-decoration: underline;
}

.btn-delete-file {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  transition: var(--transition-fast);
}

.btn-delete-file:hover {
  color: var(--danger-color);
}

.max-w-2xl {
  max-width: 960px;
}

.max-w-xl {
  max-width: 600px;
}

/* Estilos extras para emissão de contrato */
.badge-status.sem_acesso {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.section-subtitle-modal {
  font-family: var(--font-family);
}

/* Novo layout para lista de distribuidores de UCs */
.contract-uc-distributor-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.contract-uc-distributor-row span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

.contract-uc-distributor-row input {
  flex: 2;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

/* Ponytail: CSS-based form toggling */
.client-pj-fields { display: none; }
.is-pj .client-pj-fields { display: block; }
.is-pj .client-pf-fields { display: none; }

/* Sidebar & Layout */
body { margin: 0; }
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.sidebar-logo {
  max-width: 150px;
  margin-bottom: 16px;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-nav a {
  text-decoration: none;
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  transition: background-color 0.2s, color 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background-color: var(--primary-color);
  color: #FAFAFA;
}
.sidebar-nav a.logout-btn {
  margin-top: auto;
  color: var(--danger-color);
}
.sidebar-nav a.logout-btn:hover {
  background-color: var(--danger-glow);
  color: var(--danger-color);
}
.main-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  overflow-y: auto;
}
.app-container {
  min-height: auto;
}

/* Dashboard Header & Controls */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}
.dashboard-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}
.view-toggle {
  display: flex;
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--border-color);
}
.btn-view {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-view.active {
  background-color: var(--primary-color);
  color: #FAFAFA;
}

/* Kanban View */
#kanban-view {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
}
.kanban-col {
  min-width: 280px;
  width: 280px;
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-color);
}
.kanban-col-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.kanban-col-count {
  background-color: var(--primary-color);
  color: #FAFAFA;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}
.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Client Card */
.client-card {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.client-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}
.client-type {
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.type-pf { background-color: var(--role-indicador-glow); color: var(--text-primary); }
.type-pj { background-color: var(--role-parceiro-glow); color: var(--text-primary); }
.client-date { color: var(--text-muted); }
.client-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.client-partner {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* List View */
.list-section {
  margin-bottom: 24px;
  background-color: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.list-section-header {
  background-color: var(--primary-color);
  padding: 12px 16px;
  color: #FAFAFA;
}
.list-section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.list-section-content {
  display: flex;
  flex-direction: column;
}
.client-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}
.client-list-item:last-child {
  border-bottom: none;
}
.cli-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 2;
}
.cli-main .client-name {
  margin: 0;
}
.cli-info, .cli-date {
  flex: 1;
  font-size: 14px;
  color: var(--text-secondary);
}
.client-list-item .client-partner {
  flex: 1.5;
}
 / *   M o d a l   T a b s   * / 
 . m o d a l - t a b s   { 
     d i s p l a y :   f l e x ; 
     g a p :   1 . 5 r e m ; 
     p a d d i n g :   0   1 . 5 r e m ; 
     b o r d e r - b o t t o m :   1 p x   s o l i d   v a r ( - - b o r d e r - c o l o r ) ; 
     b a c k g r o u n d :   v a r ( - - b g - c a r d ) ; 
 } 
 . t a b - b t n   { 
     b a c k g r o u n d :   n o n e ; 
     b o r d e r :   n o n e ; 
     p a d d i n g :   1 r e m   0 ; 
     c o l o r :   v a r ( - - t e x t - s e c o n d a r y ) ; 
     f o n t - w e i g h t :   5 0 0 ; 
     f o n t - s i z e :   0 . 9 5 r e m ; 
     c u r s o r :   p o i n t e r ; 
     b o r d e r - b o t t o m :   2 p x   s o l i d   t r a n s p a r e n t ; 
     t r a n s i t i o n :   a l l   0 . 2 s   e a s e ; 
 } 
 . t a b - b t n : h o v e r   { 
     c o l o r :   v a r ( - - t e x t - p r i m a r y ) ; 
 } 
 . t a b - b t n . a c t i v e   { 
     c o l o r :   v a r ( - - p r i m a r y - c o l o r ) ; 
     b o r d e r - b o t t o m - c o l o r :   v a r ( - - p r i m a r y - c o l o r ) ; 
 } 
 . t a b - p a n e   { 
     d i s p l a y :   n o n e ; 
 } 
 . t a b - p a n e . a c t i v e   { 
     d i s p l a y :   b l o c k ; 
 } 
  
 
 / *   V e r t i c a l   T i m e l i n e   S t y l e s   * / 
 . v e r t i c a l - t i m e l i n e   { 
     p o s i t i o n :   r e l a t i v e ; 
     m a r g i n - t o p :   1 r e m ; 
 } 
 . v e r t i c a l - t i m e l i n e : : b e f o r e   { 
     c o n t e n t :   ' ' ; 
     p o s i t i o n :   a b s o l u t e ; 
     t o p :   0 ; 
     b o t t o m :   0 ; 
     l e f t :   6 p x ; 
     w i d t h :   2 p x ; 
     b a c k g r o u n d :   v a r ( - - b o r d e r - c o l o r ) ; 
 } 
 . t i m e l i n e - i t e m   { 
     p o s i t i o n :   r e l a t i v e ; 
     p a d d i n g - l e f t :   1 . 8 r e m ; 
 } 
 . t i m e l i n e - d o t   { 
     p o s i t i o n :   a b s o l u t e ; 
     l e f t :   0 ; 
     t o p :   5 p x ; 
     w i d t h :   1 4 p x ; 
     h e i g h t :   1 4 p x ; 
     b o r d e r - r a d i u s :   5 0 % ; 
     b a c k g r o u n d :   v a r ( - - b g - c a r d ) ; 
     b o r d e r :   3 p x   s o l i d   v a r ( - - p r i m a r y - c o l o r ) ; 
     b o x - s h a d o w :   0   0   8 p x   v a r ( - - p r i m a r y - c o l o r ) ; 
 } 
 . t i m e l i n e - i t e m . a c t i v e   . t i m e l i n e - d o t   { 
     b a c k g r o u n d :   v a r ( - - p r i m a r y - c o l o r ) ; 
 } 
 . t i m e l i n e - c o n t e n t   { 
     d i s p l a y :   f l e x ; 
     f l e x - d i r e c t i o n :   c o l u m n ; 
     g a p :   0 . 2 r e m ; 
 } 
 . t i m e l i n e - s t a g e   { 
     f o n t - w e i g h t :   6 0 0 ; 
     f o n t - s i z e :   0 . 9 5 r e m ; 
     c o l o r :   v a r ( - - t e x t - p r i m a r y ) ; 
 } 
 . t i m e l i n e - t i m e   { 
     f o n t - s i z e :   0 . 7 8 r e m ; 
     c o l o r :   v a r ( - - t e x t - s e c o n d a r y ) ; 
 } 
  
 
 / *   A l e r t e d   C l i e n t   s t y l e s   * / 
 . c l i e n t - c a r d . h a s - a l e r t   { 
     b o r d e r :   1 . 5 p x   s o l i d   v a r ( - - a c c e n t - c o r a l )   ! i m p o r t a n t ; 
     b o x - s h a d o w :   0   0   1 2 p x   r g b a ( 2 1 7 ,   1 2 2 ,   9 8 ,   0 . 2 5 )   ! i m p o r t a n t ; 
     b a c k g r o u n d :   r g b a ( 2 1 7 ,   1 2 2 ,   9 8 ,   0 . 0 3 )   ! i m p o r t a n t ; 
 } 
 . c l i e n t - l i s t - i t e m . h a s - a l e r t   { 
     b o r d e r - l e f t :   5 p x   s o l i d   v a r ( - - a c c e n t - c o r a l )   ! i m p o r t a n t ; 
     b a c k g r o u n d :   r g b a ( 2 1 7 ,   1 2 2 ,   9 8 ,   0 . 0 2 )   ! i m p o r t a n t ; 
 } 
  
 