/* ==========================================================================
   GraphStudio Enterprise - Stylesheet Canónico
   Recluta 22: ag-graph-visualizer-22
   ========================================================================== */

:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #12141c;
  --bg-tertiary: #1a1e2b;
  --bg-acrylic: rgba(18, 20, 28, 0.85);
  
  --border-subtle: #252b3d;
  --border-bright: #3b82f6;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --shadow-hud: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);
  
  --header-height: 64px;
  --sidebar-left-width: 310px;
  --sidebar-right-width: 350px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* ==========================================================================
   1. App Header (Top HUD)
   ========================================================================== */
.app-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 100;
  position: relative;
}

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

.brand-logo-img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
  background: #ffffff;
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

.brand-info h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-info h1 span {
  color: var(--accent-cyan);
  font-weight: 300;
  font-size: 0.9rem;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.brand-info .subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Header Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  max-width: 650px;
  margin: 0 1.5rem;
}

.dataset-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dataset-selector-wrapper label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.hud-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-select:hover, .hud-select:focus {
  border-color: var(--accent-cyan);
}

.search-box {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.45rem 2rem 0.45rem 2rem;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.search-icon {
  position: absolute;
  left: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

#clearSearchBtn {
  position: absolute;
  right: 0.4rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 0.8rem;
}

.search-suggestions {
  position: absolute;
  top: 105%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: var(--shadow-hud);
  z-index: 1000;
  display: none;
}

.search-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.search-item:hover {
  background: var(--bg-tertiary);
  color: var(--accent-cyan);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-btn:hover {
  background: #232838;
  border-color: var(--accent-cyan);
}

.vault-btn {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.vault-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
}

.vault-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.vault-status-dot.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.vault-status-dot.offline {
  background-color: var(--text-muted);
}

.hud-btn-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.hud-btn-icon:hover {
  background: #232838;
  border-color: var(--accent-cyan);
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 105%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  min-width: 220px;
  border-radius: 8px;
  box-shadow: var(--shadow-hud);
  z-index: 1000;
  overflow: hidden;
}

.dropdown-content a {
  color: var(--text-primary);
  padding: 0.65rem 1rem;
  text-decoration: none;
  display: block;
  font-size: 0.82rem;
  transition: background 0.15s;
}

.dropdown-content a:hover {
  background: var(--bg-tertiary);
  color: var(--accent-cyan);
}

.dropdown.open .dropdown-content {
  display: block;
}

/* ==========================================================================
   2. App Layout (Main Grid)
   ========================================================================== */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-left-width) 1fr var(--sidebar-right-width);
  height: calc(100vh - var(--header-height));
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Sidebar Left & Right */
.sidebar-left, .sidebar-right {
  background: var(--bg-secondary);
  border-color: var(--border-subtle);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem;
}

.sidebar-left {
  border-right: 1px solid var(--border-subtle);
}

.sidebar-right {
  border-left: 1px solid var(--border-subtle);
}

/* Scrollbar estilizada */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: #2a3147;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3b4564;
}

.sidebar-section {
  background: rgba(26, 30, 43, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
}

.hud-btn-mini {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.hud-btn-mini:hover {
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

/* Layout Buttons */
.layout-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.layout-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.6rem 0.5rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.layout-btn .icon {
  font-size: 1.1rem;
}

.layout-btn:hover {
  background: #222738;
  color: var(--text-primary);
  border-color: rgba(56, 189, 248, 0.4);
}

.layout-btn.active {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Control Rows */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label-with-value {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.metric-val {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-size: 0.75rem;
}

input[type="range"] {
  appearance: none;
  background: #252c40;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Toggles */
.control-row-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #252c40;
  transition: .3s;
  border-radius: 18px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent-cyan);
}

input:checked + .toggle-slider:before {
  transform: translateX(14px);
}

.toggle-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Group Badges */
.group-header-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.group-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.group-badge-chip {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.group-badge-chip .color-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.group-badge-chip.active {
  border-color: currentColor;
  box-shadow: 0 0 6px currentColor;
}

/* ==========================================================================
   3. Central Canvas (D3 Graph & HUD Overlay)
   ========================================================================== */
.canvas-container {
  position: relative;
  background: radial-gradient(circle at center, #111422 0%, #08090e 100%);
  overflow: hidden;
  height: 100%;
  width: 100%;
}

.main-graph-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-hud-overlay {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 10;
}

.hud-chip {
  background: var(--bg-acrylic);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hud-chip span {
  color: var(--accent-cyan);
  font-weight: 700;
}

.hud-chip.info-chip {
  color: var(--accent-emerald);
}

/* Mini-map */
.minimap-wrapper {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  background: var(--bg-acrylic);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.minimap-title {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.3);
}

#minimapCanvas {
  display: block;
  background: #090a10;
}

/* Zoom Floating Bar */
.zoom-floating-bar {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--bg-acrylic);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 3px;
  box-shadow: var(--shadow-hud);
  z-index: 10;
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background 0.15s;
}

.zoom-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent-cyan);
}

/* ==========================================================================
   4. Sidebar Right (Inspector & Global Metrics)
   ========================================================================== */
.inspector-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.inspector-header {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.node-avatar-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
  flex-shrink: 0;
}

.node-header-details h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.type-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.2);
  margin-top: 3px;
}

.inspector-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.empty-state-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
  padding: 1.5rem 0.5rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.stat-box {
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.stat-box .title {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.stat-box .number {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-top: 2px;
}

.stat-box .number.cyan { color: var(--accent-cyan); }
.stat-box .number.purple { color: var(--accent-purple); }
.stat-box .number.emerald { color: var(--accent-emerald); }
.stat-box .number.pink { color: var(--accent-pink); }

.detail-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.combos-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.combo-pill {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #c084fc;
  padding: 2px 7px;
  border-radius: 4px;
}

/* Global Metrics Card */
.global-metrics-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
}

.global-metrics-card h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-tiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.metric-tile {
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 0.6rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.tile-title {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.tile-number {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-top: 3px;
}

.tile-number.highlight {
  color: var(--accent-rose);
}

/* AI Assistant Card */
.ai-assistant-card {
  background: var(--bg-tertiary);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ai-header h3 {
  font-size: 0.85rem;
  color: var(--accent-purple);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ai-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.ai-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ai-input-wrapper textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0.5rem;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  resize: vertical;
  outline: none;
}

.ai-input-wrapper textarea:focus {
  border-color: var(--accent-purple);
}

.ai-send-btn {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #fff;
  border: none;
  font-weight: 600;
  justify-content: center;
}

.ai-response-box {
  background: var(--bg-secondary);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #e2e8f0;
  max-height: 200px;
  overflow-y: auto;
}

/* ==========================================================================
   5. Modal & Vault Styles (Zero-Knowledge)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  width: 90%;
  max-width: 540px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalAppear 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalAppear {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-with-icon {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-shield-icon {
  font-size: 1.6rem;
}

.modal-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-header p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}
.close-modal-btn:hover { color: var(--text-primary); }

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.security-guarantee-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.guarantee-icon {
  font-size: 1.2rem;
  color: var(--accent-emerald);
}

.guarantee-text {
  font-size: 0.75rem;
  color: #a7f3d0;
  line-height: 1.45;
}

.guarantee-text code {
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.modal-select {
  width: 100%;
}

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

.password-wrapper input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0.55rem 2.5rem 0.55rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
}

.password-wrapper input:focus {
  border-color: var(--accent-emerald);
}

.toggle-show-btn {
  position: absolute;
  right: 0.6rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

.input-helper {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.vault-status-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.status-bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-bullet.offline { background: var(--text-muted); }
.status-bullet.online { background: var(--accent-emerald); box-shadow: 0 0 8px var(--accent-emerald); }

.modal-footer {
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-right {
  display: flex;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--accent-emerald);
  color: #022c22;
  font-weight: 700;
  border: none;
}
.btn-primary:hover {
  background: #34d399;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
  border-color: #fb7185;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  background: var(--bg-acrylic);
  border: 1px solid var(--border-bright);
  color: var(--text-primary);
  padding: 0.6rem 1.25rem;
  border-radius: 20px;
  font-size: 0.82rem;
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(10px);
  animation: toastFade 0.25s ease-out;
}

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

/* ==========================================================================
   6. SVG D3 Elements Styling
   ========================================================================== */
.graph-link {
  stroke-opacity: 0.4;
  transition: stroke-opacity 0.2s, stroke-width 0.2s;
}

.graph-link.highlighted {
  stroke-opacity: 0.95;
  stroke-width: 2.5px;
}

.graph-link.faded {
  stroke-opacity: 0.05;
}

.graph-edge-label {
  font-size: 9px;
  fill: var(--text-muted);
  font-family: var(--font-mono);
  pointer-events: none;
  opacity: 0.7;
}

.graph-node-group {
  cursor: grab;
  transition: transform 0.1s ease-out;
}

.graph-node-group:active {
  cursor: grabbing;
}

.graph-node-circle {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1.5px;
  transition: r 0.2s, stroke-width 0.2s, filter 0.2s;
}

.graph-node-group:hover .graph-node-circle,
.graph-node-group.selected .graph-node-circle {
  stroke: #ffffff;
  stroke-width: 3px;
  filter: drop-shadow(0 0 10px currentColor);
}

.graph-node-group.faded {
  opacity: 0.15;
}

.ai-forge-btn {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.3));
  border-color: rgba(168, 85, 247, 0.4);
  color: #c084fc;
}
.ai-forge-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(168, 85, 247, 0.5));
  border-color: #c084fc;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

.modal-card-large {
  max-width: 680px;
}

.hud-input, .hud-textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0.6rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.hud-input:focus, .hud-textarea:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.2);
}

.hud-textarea {
  resize: vertical;
  line-height: 1.45;
}

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

.btn-primary-ai {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
  font-weight: 700;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.3);
}

.btn-primary-ai:hover {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.5);
  transform: translateY(-1px);
}

.ai-loading-box {
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #d8b4fe;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(168, 85, 247, 0.3);
  border-top-color: #c084fc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   7. Arquitectura Móvil & Capas Responsive (Mobile-First Layered Design)
   ========================================================================== */

/* Reglas por defecto de visibilidad en escritorio */
.mobile-only {
  display: none !important;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-drawer-header {
  display: none;
}

.mobile-menu-drawer {
  display: none;
}

.drawer-backdrop {
  display: none;
}

.mobile-search-bar {
  display: none;
}

/* ==========================================================================
   MEDIA QUERY: Teléfonos Móviles y Tablets Compactas (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --header-height: 56px;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  html, body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
  }

  /* Cabecera ultra-compacta */
  .app-header {
    height: var(--header-height);
    padding: 0 0.85rem;
    width: 100%;
    max-width: 100%;
  }

  .brand-logo-img {
    width: 34px;
    height: 34px;
  }

  .brand-info h1 {
    font-size: 0.95rem;
  }

  .brand-info .subtitle {
    display: none;
  }

  /* Grid pasa a ser lienzo 100% full screen */
  .app-layout {
    display: block !important;
    position: relative !important;
    height: calc(100vh - var(--header-height) - 64px) !important;
    height: calc(100dvh - var(--header-height) - 64px) !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }

  .canvas-container {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    bottom: 0 !important; right: 0 !important;
  }

  /* HUD superior compacto */
  .canvas-hud-overlay {
    top: 0.6rem;
    left: 0.6rem;
    gap: 0.35rem;
    flex-wrap: wrap;
    max-width: 90vw;
  }

  .hud-chip {
    padding: 0.25rem 0.55rem;
    font-size: 0.68rem;
  }

  .density-chip {
    display: none; /* Ahorrar espacio en pantalla angosta */
  }

  /* Minimap reducido */
  .minimap-wrapper {
    bottom: 0.75rem;
    left: 0.75rem;
    transform: scale(0.85);
    transform-origin: bottom left;
  }

  /* Zoom controls */
  .zoom-floating-bar {
    bottom: 0.75rem;
    right: 0.75rem;
  }

  /* Barra de búsqueda flotante en móvil */
  .mobile-search-bar {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--accent-cyan);
    padding: 0.6rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1300;
    box-shadow: 0 10px 20px rgba(0,0,0,0.6);
  }

  .mobile-search-bar input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.55rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
  }

  /* Paneles laterales transformados en DRAWERS / BOTTOM SHEETS */
  .sidebar-left,
  .sidebar-right,
  .mobile-menu-drawer {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 84vh !important;
    max-height: 84dvh !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    background: rgba(18, 20, 28, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.9) !important;
    border-top: 2px solid var(--accent-cyan) !important;
    border-left: none !important;
    border-right: none !important;
    transform: translateY(120%) !important;
    pointer-events: none !important;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 1500 !important;
    overflow-y: auto !important;
    padding: 0.75rem 1.25rem 3rem 1.25rem !important;
  }

  .sidebar-left.open,
  .sidebar-right.open,
  .mobile-menu-drawer.open {
    transform: translateY(0) !important;
    pointer-events: auto !important;
  }

  /* Encabezado y Asidero del Drawer (Bottom Sheet) */
  .mobile-drawer-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    position: sticky;
    top: 0;
    background: rgba(18, 20, 28, 0.98);
    padding-top: 0.25rem;
    z-index: 10;
  }

  .drawer-drag-handle {
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
  }

  .drawer-title-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
  }

  .drawer-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .close-drawer-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
  }

  /* Telón de fondo (Backdrop) */
  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1350;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-out;
  }

  .drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Barra de navegación inferior móvil (BOTTOM NAV BAR) */
  .mobile-bottom-nav {
    display: grid;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(14, 16, 24, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-subtle);
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    justify-items: center;
    z-index: 1200;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .nav-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    min-width: 48px;
    width: 100%;
    cursor: pointer;
    transition: color 0.2s;
  }

  .nav-tab-btn .tab-icon {
    font-size: 1.25rem;
  }

  .nav-tab-btn .tab-label {
    font-size: 0.68rem;
    font-weight: 600;
  }

  .nav-tab-btn.active {
    color: var(--accent-cyan);
  }

  .nav-tab-btn.active .tab-icon {
    filter: drop-shadow(0 0 8px var(--accent-cyan));
  }

  /* Contenido del Drawer de Ajustes Móviles */
  .mobile-menu-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 0.5rem;
  }

  .mobile-menu-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    padding: 0.85rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
  }

  .menu-item-icon {
    font-size: 1.4rem;
  }

  .menu-item-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .menu-item-text strong {
    font-size: 0.85rem;
    color: var(--text-primary);
  }

  .menu-item-text span {
    font-size: 0.72rem;
    color: var(--text-muted);
  }

  .menu-arrow {
    color: var(--text-muted);
    font-size: 1.25rem;
  }

  .mobile-menu-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.25rem;
  }

  .mobile-menu-section label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
  }

  .mobile-export-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .mobile-export-grid .hud-btn {
    min-height: 44px;
    justify-content: center;
  }

  /* Modales en móvil: ancho completo */
  .modal-card {
    width: 95% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }

  .form-row-dual {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
}
