@import './tokens.css';

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

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1px solid var(--border-default);
  outline: none;
  transition: border-color var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* App Container */
#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-root);
}

/* ==========================================================================
   A.2 TOPBAR PRINCIPAL (64px)
   ========================================================================== */
.main-topbar {
  height: var(--topbar-height);
  width: 100%;
  background-color: var(--bg-root);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  flex-shrink: 0;
}

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

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.brand-logo-img {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(255, 90, 0, 0.25));
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 8px rgba(255, 90, 0, 0.35));
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.project-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.project-selector:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hover);
}

.project-icon {
  color: var(--accent-blue);
  display: flex;
}

.project-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.project-current {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Topbar Center (Busca Global) */
.topbar-center {
  flex: 1;
  max-width: 520px;
  margin: 0 24px;
}

.global-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 0 12px;
  height: 40px;
  transition: border-color var(--transition-fast);
}

.global-search-box:focus-within {
  border-color: var(--border-focus);
}

.global-search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
}

.global-search-input::placeholder {
  color: var(--text-muted);
}

.kbd-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-default);
  color: var(--text-muted);
}

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

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: 1px solid transparent;
  position: relative;
  transition: all var(--transition-fast);
}

.icon-button:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.icon-button.active {
  background-color: var(--accent-blue-hover);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.badge-num {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background-color: var(--accent-blue);
  color: #0A0E13;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.user-profile-menu:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-logout {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: 6px;
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-logout:hover {
  color: var(--health-red);
}

/* ==========================================================================
   ROTA A: APP PRINCIPAL (MAPA + SIDEBAR 4 ZONAS + DRAWER)
   ========================================================================== */
#view-main-app {
  display: flex;
  flex: 1;
  width: 100%;
  height: calc(100vh - var(--topbar-height));
  position: relative;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   A.3 SIDEBAR ESQUERDA (300px, 4 ZONAS)
   -------------------------------------------------------------------------- */
.sidebar-main {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  transition: width var(--transition-normal);
}

/* ZONA 1: Cabeçalho do Projeto (Seletor de Projeto + Drill-down) */
.sidebar-zone-1 {
  padding: 14px 16px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  flex-shrink: 0;
}

.project-selector {
  width: 100%;
  justify-content: space-between;
}

.badge-status-pill {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--health-green-subtle);
  color: var(--health-green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Scrollable Tree Container (ZONAS 2, 2.5, 3 e 5) */
.sidebar-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Títulos de Seção */
.sidebar-section-title {
  padding: 14px 16px 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.sidebar-section-sub {
  font-size: 10px;
  color: var(--text-disabled);
  font-weight: 400;
}

/* Health Dots (8px) */
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 8px;
  flex-shrink: 0;
}

.health-dot.green {
  background-color: var(--health-green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.health-dot.yellow {
  background-color: var(--health-yellow);
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.4);
}

.health-dot.red {
  background-color: var(--health-red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

/* ZONA 3: Camadas Visíveis */
.layers-zone {
  border-bottom: 1px solid var(--border-default);
  padding: 8px 12px 14px 12px;
}

.layer-item {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.layer-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

/* Checkbox Customizado 16x16 */
.custom-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid #4B5563;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.custom-checkbox.checked {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #0A0E13;
}

.layer-name-click {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.layer-name-click:hover {
  color: var(--text-primary);
}

.layer-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ZONA 4: Rodapé Sticky */
.sidebar-footer-zone {
  height: 40px;
  background-color: var(--bg-root);
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

/* ZONA 0: Usuário Logado & Sair (menu lateral) */
.sidebar-user-zone {
  height: 58px;
  background-color: var(--bg-root);
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 10px;
  flex-shrink: 0;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.sidebar-user-card:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hover);
}

.sidebar-user-card .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-card .user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-state-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--health-green);
}

.save-dot.pending {
  background-color: var(--health-yellow);
}

.btn-save-action {
  padding: 2px 8px;
  background-color: var(--accent-blue);
  color: #0A0E13;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  display: none;
}

.btn-save-action.visible {
  display: inline-block;
}

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

.undo-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.undo-btn.active {
  opacity: 1;
  cursor: pointer;
}

.undo-btn:hover.active {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.map-floating-toolbar .undo-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   A.4 PALCO DO MAPA
   -------------------------------------------------------------------------- */
.map-stage-container {
  flex: 1;
  position: relative;
  background-color: var(--bg-map);
  background-image: 
    linear-gradient(to right, var(--bg-map-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--bg-map-grid) 1px, transparent 1px);
  background-size: 40px 40px;
  overflow: hidden;
}

.map-gl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

/* Toolbar Flutuante Superior */
.map-floating-toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 30;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-btn {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

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

.toolbar-btn.active {
  background-color: var(--accent-blue-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.toolbar-btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.layer-icon-img {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background-color: var(--border-default);
  margin: 0 6px;
}

/* Zoom Controls Stack */
.map-zoom-stack {
  position: absolute;
  bottom: 44px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

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

.zoom-stack-gap {
  height: 6px;
}

/* Status Bar Inferior */
.map-statusbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--statusbar-height);
  background-color: var(--bg-root);
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  z-index: 25;
}

.statusbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.status-online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--health-green);
  display: inline-block;
  margin-right: 4px;
}

/* Mapa Visual Mockado (Nós e Cabos no Grid) */
.map-nodes-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.map-svg-cables {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-node-marker {
  position: absolute;
  cursor: pointer;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform var(--transition-fast);
}

.map-node-marker:hover {
  transform: translate(-50%, -50%) scale(1.15);
  z-index: 10;
}

.node-marker-body {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.marker-pop {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--layer-pop);
  color: #0A0E13;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
}

.marker-ceo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: var(--layer-ceo);
  color: #0A0E13;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.marker-cto {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background-color: var(--layer-cto);
  color: #0A0E13;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.marker-onu {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--layer-client);
  box-shadow: 0 0 8px rgba(217, 70, 239, 0.6);
}

.marker-label {
  margin-top: 6px;
  padding: 2px 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.map-node-marker.selected .node-marker-body::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  border: 2px solid var(--accent-blue);
  animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 0.4; }
  100% { transform: scale(0.95); opacity: 0.9; }
}

/* --------------------------------------------------------------------------
   A.5 DRAWER CONTEXTUAL DIREITO (340px)
   -------------------------------------------------------------------------- */
.context-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--statusbar-height);
  width: var(--drawer-width);
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.context-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.drawer-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--accent-blue-subtle);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.drawer-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-address {
  font-size: 11px;
  color: var(--text-muted);
}

.drawer-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.drawer-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.drawer-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex: 1;
}

/* Bloco de Ocupação */
.occupancy-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 12px;
}

.occupancy-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.occupancy-header strong {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.occupancy-bar-segmented {
  display: flex;
  height: 8px;
  width: 100%;
  border-radius: 4px;
  background-color: #1F2937;
  overflow: hidden;
  margin-bottom: 10px;
  gap: 1px;
}

.occupancy-legend {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Grid 2x2 Metadados */
.metadata-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.meta-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 10px;
}

.meta-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.meta-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Ações Primárias */
.drawer-actions-primary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.btn-action-blue {
  height: 34px;
  background-color: var(--accent-blue-subtle);
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-action-blue:hover {
  background-color: var(--accent-blue);
  color: #0A0E13;
}

/* Drawer Footer */
.drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-menu-actions {
  display: flex;
  gap: 8px;
}

.btn-secondary-action {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--transition-fast);
}

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

/* ==========================================================================
   ROTA B: CONFIGURAÇÕES (/settings)
   ========================================================================== */
#view-settings {
  display: none;
  flex: 1;
  width: 100%;
  height: calc(100vh - var(--topbar-height));
  position: relative;
  overflow: hidden;
  background-color: var(--bg-root);
}

.settings-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Sub-Sidebar (260px) */
.settings-sub-sidebar {
  width: var(--settings-sidebar-width);
  height: 100%;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
  padding: 16px 0;
  flex-shrink: 0;
}

.category-group {
  margin-bottom: 12px;
}

.category-header {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.category-header:hover {
  color: var(--text-primary);
}

.category-title-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-items-list {
  list-style: none;
  padding: 4px 0;
}

.category-item {
  height: 36px;
  padding: 0 16px 0 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
}

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

.category-item.active {
  background-color: var(--accent-blue-subtle);
  border-left-color: var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 600;
}

/* Área de Conteúdo de Settings */
.settings-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.settings-page-header {
  margin-bottom: 24px;
}

.settings-page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.settings-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.btn-primary-blue {
  height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  background-color: var(--accent-blue);
  color: #0A0E13;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color var(--transition-fast);
}

.btn-primary-blue:hover {
  background-color: var(--accent-blue-solid-hover);
}

.settings-filter-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  height: 38px;
  padding: 0 12px;
  width: 260px;
}

.settings-filter-box input {
  border: none;
  background: transparent;
  width: 100%;
  font-size: 12px;
}

/* Tabelas de Dados */
.settings-table-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

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

.data-table th {
  height: 40px;
  padding: 0 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  background-color: rgba(255, 255, 255, 0.01);
}

.data-table td {
  height: 48px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table tr:hover td {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

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

.cell-actions {
  text-align: right;
}

.action-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.action-menu-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.settings-table-footer {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
}

/* ==========================================================================
   MODAIS CENTRALIZADOS (480px, BACKDROP BLUR)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.open {
  display: flex;
}

.modal-container {
  width: 480px;
  max-width: 95vw;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-fade-in 150ms cubic-bezier(0, 0, 0.2, 1);
}

@keyframes modal-fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 70vh;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input, .form-select {
  height: 40px;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 13px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-default);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background-color: rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

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

/* ==========================================================================
   PAINEL DE CTO REESCRITO (380px) & SISTEMA UNIFILAR / VÍNCULO A CABO
   ========================================================================== */

/* Drawer Override para 380px */
.app-drawer {
  width: var(--drawer-width, 380px) !important;
  background-color: #0F1419 !important;
  border-left: 1px solid #1F2937 !important;
  display: flex;
  flex-direction: column;
}

/* Header Sticky 64px */
.drawer-header-64 {
  height: 64px;
  min-height: 64px;
  background-color: #0F1419;
  border-bottom: 1px solid #1F2937;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.drawer-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.drawer-header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.drawer-header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-cto-name {
  font-size: 14px;
  font-weight: 600;
  color: #F3F4F6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-header-subtitle {
  font-size: 12px;
  color: #9CA3AF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-top: 1px;
}

.drawer-header-meta {
  font-size: 11px;
  color: #6B7280;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.health-dot-8 {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.health-dot-8.green { background-color: #22C55E; box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.health-dot-8.yellow { background-color: #EAB308; box-shadow: 0 0 8px rgba(234,179,8,0.5); }
.health-dot-8.red { background-color: #EF4444; box-shadow: 0 0 8px rgba(239,68,68,0.5); }

/* Tabs 40px */
.drawer-tabs-nav {
  height: 40px;
  min-height: 40px;
  background-color: #0F1419;
  border-bottom: 1px solid #1F2937;
  display: flex;
  align-items: stretch;
  padding: 0 4px;
}

.drawer-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #9CA3AF;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0 8px;
}

.drawer-tab-btn:hover {
  color: #F3F4F6;
  background-color: rgba(255, 255, 255, 0.02);
}

.drawer-tab-btn.active {
  color: #38BDF8;
  background-color: rgba(56, 189, 248, 0.10);
  border-bottom: 2px solid #38BDF8;
}

/* Corpo com Rolagem e Fundo Escuro */
.drawer-tab-content-wrapper {
  flex: 1;
  overflow-y: auto;
  background-color: #0A0E13;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Pulse sutil para nó atual no Unifilar */
@keyframes ctoPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4);
    opacity: 0.92;
  }
  50% {
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4);
    opacity: 0.92;
  }
}

/* Feature 1 — Unifilar Flow */
.unifilar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.unifilar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9CA3AF;
}

.unifilar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.unifilar-tree-flow {
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 4px 0;
}

.unifilar-node-card {
  background-color: #0A0E13;
  border: 1px solid #1F2937;
  border-radius: 8px;
  padding: 10px 12px;
  position: relative;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.unifilar-node-card:hover {
  background-color: rgba(255, 255, 255, 0.02);
  border-color: #374151;
}

.unifilar-node-card.current-node {
  border: 2px solid #38BDF8 !important;
  background: rgba(56, 189, 248, 0.04);
  animation: ctoPulse 2s infinite ease-in-out;
}

.unifilar-node-card.health-green { border-color: #22C55E; }
.unifilar-node-card.health-yellow { border-color: #EAB308; }
.unifilar-node-card.health-red { border-color: #EF4444; }

.unifilar-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.unifilar-node-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unifilar-node-name {
  font-size: 13px;
  font-weight: 600;
  color: #F3F4F6;
}

.unifilar-node-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.unifilar-node-sub {
  font-size: 11px;
  color: #9CA3AF;
}

.unifilar-node-metric {
  font-size: 11px;
  font-family: var(--font-mono);
  color: #38BDF8;
  margin-top: 4px;
}

.current-node-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #38BDF8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 6px;
}

/* Conector de Cabo entre nós */
.unifilar-cable-connector {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
}

.unifilar-cable-connector::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background-color: #1F2937;
  transform: translateX(-50%);
  z-index: 1;
}

.unifilar-cable-badge {
  position: relative;
  z-index: 2;
  background: #0F1419;
  border: 1px solid #1F2937;
  border-radius: 12px;
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #9CA3AF;
  font-family: var(--font-mono);
  cursor: help;
  transition: all var(--transition-fast);
}

.unifilar-cable-badge:hover {
  border-color: #38BDF8;
  color: #F3F4F6;
  background-color: #1A222D;
}

/* Bloco Orçamento Óptico */
.orcamento-card {
  background: #0F1419;
  border: 1px solid #1F2937;
  border-radius: 8px;
  padding: 12px;
}

.orcamento-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9CA3AF;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.orcamento-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--font-mono);
}

.orcamento-table td {
  padding: 4px 0;
}

.orcamento-table td:first-child {
  color: #9CA3AF;
}

.orcamento-table td:last-child {
  text-align: right;
  color: #D1D5DB;
}

.orcamento-table tr.total-row {
  border-top: 1px solid #1F2937;
  border-bottom: 1px solid #1F2937;
  font-weight: 600;
}

.orcamento-table tr.total-row td {
  padding: 6px 0;
  color: #F3F4F6;
}

.orcamento-margin-val {
  font-weight: 600;
}
.orcamento-margin-val.green { color: #22C55E; }
.orcamento-margin-val.yellow { color: #EAB308; }
.orcamento-margin-val.red { color: #EF4444; }

/* Feature 2: Ocupação e Grid de Portas (4x4) */
.ports-occupancy-card {
  background: #0F1419;
  border: 1px solid #1F2937;
  border-radius: 8px;
  padding: 12px;
}

.ports-occ-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.ports-occ-title {
  font-size: 11px;
  font-weight: 600;
  color: #9CA3AF;
  text-transform: uppercase;
}

.ports-occ-percent {
  font-size: 13px;
  font-weight: 700;
  color: #F3F4F6;
  font-family: var(--font-mono);
}

.ports-progress-track {
  height: 8px;
  background-color: #1F2937;
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0;
  display: flex;
}

.ports-progress-bar {
  height: 100%;
  transition: width var(--transition-normal);
}
.ports-progress-bar.blue { background-color: #38BDF8; }
.ports-progress-bar.yellow { background-color: #EAB308; }
.ports-progress-bar.red { background-color: #EF4444; }

.ports-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 6px;
}

.ports-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ports-grid-4x4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.port-box-btn {
  width: 100%;
  height: 48px;
  border-radius: 6px;
  border: 1.5px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  position: relative;
}

.port-box-btn:focus-visible {
  outline: 2px solid #38BDF8;
  outline-offset: 1px;
}

.port-num {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}

.port-subicon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
}

/* Cores de Portas Conforme Especificado */
.port-box-btn.livre {
  border-color: #374151;
  background-color: #0A0E13;
  color: #9CA3AF;
}
.port-box-btn.livre:hover {
  border-color: #4B5563;
  background-color: rgba(255, 255, 255, 0.04);
}
.port-box-btn.livre .port-subicon { background-color: #6B7280; }

.port-box-btn.ativa {
  border-color: #38BDF8;
  background-color: rgba(56, 189, 248, 0.12);
  color: #38BDF8;
}
.port-box-btn.ativa:hover {
  background-color: rgba(56, 189, 248, 0.20);
}
.port-box-btn.ativa .port-subicon { background-color: #38BDF8; }

.port-box-btn.reservada {
  border-color: #EAB308;
  background-color: rgba(234, 179, 8, 0.12);
  color: #EAB308;
}
.port-box-btn.reservada:hover {
  background-color: rgba(234, 179, 8, 0.20);
}
.port-box-btn.reservada .port-subicon { background-color: #EAB308; }

.port-box-btn.quebrada {
  border-color: #EF4444;
  background-color: rgba(239, 68, 68, 0.12);
  color: #EF4444;
}
.port-box-btn.quebrada:hover {
  background-color: rgba(239, 68, 68, 0.20);
}
.port-box-btn.quebrada .port-subicon { background-color: #EF4444; }

.port-box-btn.desativada {
  border-color: #1F2937;
  background-color: #05070A;
  color: #4B5563;
  cursor: not-allowed;
}
.port-box-btn.desativada .port-subicon { background-color: #1F2937; }

/* Mini-Card Interativo de Porta Selecionada */
.port-popover-card {
  background-color: #0F1419;
  border: 1px solid #38BDF8;
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
  animation: fadeIn 0.15s ease-out;
}

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

/* Feature 3: Tab Rede */
.network-chain-box {
  background: #0F1419;
  border: 1px solid #1F2937;
  border-radius: 8px;
  padding: 12px;
}

.network-chain-tree {
  font-size: 12px;
  color: #D1D5DB;
  font-family: var(--font-mono);
  line-height: 1.8;
}

/* Feature 4: Tab Histórico */
.timeline-event-item {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}

.timeline-event-item:not(:last-child)::before {
  content: '';
  position: absolute;
  top: 14px;
  bottom: 0;
  left: 6px;
  width: 2px;
  background-color: #1F2937;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 2;
}
.timeline-dot.green { background-color: #22C55E; }
.timeline-dot.yellow { background-color: #EAB308; }
.timeline-dot.red { background-color: #EF4444; }

.timeline-info {
  display: flex;
  flex-direction: column;
}

.timeline-time {
  font-size: 11px;
  color: #9CA3AF;
  margin-bottom: 2px;
}

.timeline-title {
  font-size: 12px;
  font-weight: 500;
  color: #F3F4F6;
}

.timeline-author {
  font-size: 11px;
  color: #6B7280;
  margin-top: 2px;
}

/* Rodapé Sticky 56px */
.drawer-footer-56 {
  height: 56px;
  min-height: 56px;
  background-color: #0F1419;
  border-top: 1px solid #1F2937;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: sticky;
  bottom: 0;
  z-index: 20;
}

/* Menu Dropdown de Mais Ações */
.actions-dropdown-menu {
  position: absolute;
  bottom: 60px;
  right: 16px;
  background-color: #0F1419;
  border: 1px solid #1F2937;
  border-radius: 8px;
  padding: 6px;
  width: 220px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #D1D5DB;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
}

.dropdown-item-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #F3F4F6;
}

.dropdown-item-btn.danger {
  color: #EF4444;
}

.dropdown-item-btn.danger:hover {
  background-color: rgba(239, 68, 68, 0.12);
  color: #EF4444;
}

/* Sidebar Alert Banner para Vínculo de Cabos */
.sidebar-alert-banner {
  background: rgba(234, 179, 8, 0.10);
  border: 1px solid rgba(234, 179, 8, 0.25);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-alert-banner:hover {
  background: rgba(234, 179, 8, 0.18);
  border-color: #EAB308;
}

.sidebar-alert-text {
  font-size: 12px;
  font-weight: 600;
  color: #EAB308;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Modal de Vínculo de Cabo & Lote */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content-card {
  background: #0F1419;
  border: 1px solid #1F2937;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #1F2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #F3F4F6;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #1F2937;
  background-color: #0A0E13;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Card de Seleção de Cabo */
.cable-select-card {
  background: #0A0E13;
  border: 1px solid #1F2937;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cable-select-card:hover {
  border-color: #374151;
}

.cable-select-card.selected {
  border-color: #38BDF8;
  background: rgba(56, 189, 248, 0.04);
}

/* Slider / Posição no Cabo */
.cable-track-visualizer {
  background: #1F2937;
  height: 12px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.cable-track-fill {
  background: #38BDF8;
  height: 100%;
  border-radius: 6px 0 0 6px;
}

.cable-track-pointer {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: #FFF;
  border: 2px solid #38BDF8;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Estados Vazios */
.empty-state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 16px;
  gap: 12px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: #6B7280;
}

.empty-state-title {
  font-size: 14px;
  font-weight: 600;
  color: #F3F4F6;
}

.empty-state-desc {
  font-size: 12px;
  color: #9CA3AF;
  line-height: 1.5;
  max-width: 280px;
}

/* ==========================================================================
   MENU DE CONTEXTO (BOTÃO DIREITO DO MOUSE) & EDIÇÃO DE VÉRTICES / CABOS
   ========================================================================== */

/* Menu de Contexto Flutuante */
.map-context-menu {
  position: fixed;
  z-index: 10000;
  background-color: #0F1419;
  border: 1px solid #1F2937;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  min-width: 220px;
  padding: 6px;
  animation: contextMenuPop 0.12s cubic-bezier(0, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@keyframes contextMenuPop {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu-header {
  padding: 6px 10px 8px 10px;
  border-bottom: 1px solid #1F2937;
  margin-bottom: 4px;
}

.context-menu-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #38BDF8;
  font-family: var(--font-mono);
}

.context-menu-header-title {
  font-size: 12px;
  font-weight: 600;
  color: #F3F4F6;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.context-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: #D1D5DB;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
}

.context-menu-item:hover {
  background-color: rgba(56, 189, 248, 0.12);
  color: #F3F4F6;
}

.context-menu-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-menu-item.danger {
  color: #EF4444;
}

.context-menu-item.danger:hover {
  background-color: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

.context-menu-divider {
  height: 1px;
  background-color: #1F2937;
  margin: 4px 0;
}

/* Barra Flutuante de Edição de Vértices do Cabo */
.vertex-editor-toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #0F1419;
  border: 1px solid #38BDF8;
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  z-index: 50;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.vertex-editor-text {
  font-size: 12px;
  color: #F3F4F6;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Marcador de Vértice Arrastável no Mapa */
.cable-vertex-handle {
  width: 14px;
  height: 14px;
  background-color: #38BDF8;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5);
  cursor: grab;
  transition: transform 0.1s ease;
}

.cable-vertex-handle:hover {
  transform: scale(1.3);
  background-color: #0ea5e9;
}

.cable-vertex-handle:active {
  cursor: grabbing;
  transform: scale(1.4);
}

/* Banner Flutuante de Movimentação de Elemento */
.element-move-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #0F1419;
  border: 1px solid #EAB308;
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  z-index: 50;
  font-size: 12px;
  color: #F3F4F6;
  animation: slideDown 0.2s ease-out;
}

/* ==========================================================================
   RESPONSIVIDADE (até 1366px)
   ========================================================================== */
@media (max-width: 1366px) {
  :root {
    --sidebar-width: 260px;
  }
}

/* ==========================================================================
   TELA DE LOGIN (FULL-SCREEN, TEMA MAIS FIBRA)
   ========================================================================== */
.login-view {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(255, 90, 0, 0.14), transparent 60%),
    radial-gradient(1000px 700px at 90% 110%, rgba(56, 189, 248, 0.10), transparent 55%),
    var(--bg-root);
  overflow-y: auto;
  padding: 24px;
}

.login-view-inner {
  width: 400px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;
}

.login-logo {
  width: 100%;
  display: flex;
  justify-content: center;
}

.login-logo img {
  height: 46px;
  width: auto;
  filter: drop-shadow(0 4px 16px rgba(255, 90, 0, 0.25));
}

.login-subtitle {
  margin: 14px 0 30px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

.login-form {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 24px 24px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 12px;
  display: flex;
  color: var(--text-muted);
  pointer-events: none;
}

.login-input {
  width: 100%;
  height: 42px;
  border-radius: 6px;
  padding: 0 40px;
  font-size: 13px;
  font-family: var(--font-sans);
  background-color: var(--bg-input);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.login-input::placeholder {
  color: var(--text-disabled);
}

.login-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.login-password-toggle {
  position: absolute;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.login-password-toggle:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.06);
}

.login-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  background-color: var(--health-red-subtle);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  font-size: 12px;
  line-height: 1.45;
}

.login-error[hidden] {
  display: none;
}

.login-error svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.login-submit-btn {
  height: 44px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-family: var(--font-sans);
  color: #FFFFFF;
  background: linear-gradient(135deg, #FFA133, #FF5A00);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter var(--transition-fast), transform var(--transition-fast);
  box-shadow: 0 8px 24px rgba(255, 90, 0, 0.28);
}

.login-submit-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.login-submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.login-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.login-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: login-spin 700ms linear infinite;
}

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

.login-footer {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.login-footer-dot {
  color: var(--text-disabled);
}

@media (max-width: 480px) {
  .login-view { padding: 16px; }
  .login-form { padding: 20px 16px 16px; }
}

