/* ==========================================================================
   Astra Study - Cosmic Constellation Mind Map Stylesheet (jsMind)
   ========================================================================== */

/* Fullscreen Study View Container */
#mindmap-view {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  background: #060814;
  overflow: hidden;
}

#mindmap-view.hidden {
  display: none !important;
}

/* Header & Toolbar */
.mindmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(13, 17, 38, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(139, 92, 246, 0.25);
  gap: 1rem;
  z-index: 10;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.mindmap-title-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.mindmap-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mindmap-back-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(139, 92, 246, 0.4);
}

.mindmap-title-input {
  background: rgba(20, 24, 45, 0.8);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 10px;
  color: #ffffff;
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  min-width: 220px;
  max-width: 320px;
  transition: all 0.25s ease;
}

.mindmap-title-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.mindmap-stat-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  border-radius: 9999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  white-space: nowrap;
}

/* Action Controls Strip */
.mindmap-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mindmap-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.mindmap-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(139, 92, 246, 0.4);
  color: #ffffff;
}

.mindmap-action-btn.btn-save {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.4);
}

.mindmap-action-btn.btn-save:hover {
  box-shadow: 0 0 22px rgba(124, 58, 237, 0.65);
  transform: translateY(-1px);
}

.mindmap-action-btn.btn-share {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.mindmap-action-btn.btn-share:hover {
  background: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}

.mindmap-action-btn.btn-export {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.mindmap-action-btn.btn-export:hover {
  background: rgba(245, 158, 11, 0.25);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.4);
}

/* Secondary Toolbar: Node Editing Controls */
.mindmap-node-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  background: rgba(9, 12, 28, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 0.75rem;
  flex-wrap: wrap;
  z-index: 9;
}

.node-tools-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.node-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.node-tool-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  color: #e2e8f0;
}

.node-tool-btn.danger-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.node-tool-separator {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 0.3rem;
}

/* Color Swatches */
.color-swatches-strip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-swatch:hover {
  transform: scale(1.25);
  border-color: #ffffff;
}

.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 10px currentColor;
}
/* Color Swatches Strip border fix for white swatch */
.color-swatch[data-color="default"],
.color-swatch[data-color="white"] {
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}

/* jsMind Container */
#jsmind_container {
  width: 100%;
  height: calc(100vh - 80px);
  flex: 1;
  background: radial-gradient(ellipse at center, #111428 0%, #08090f 100%);
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  touch-action: none;
}

/* Atmospheric Stardust overlay on the mindmap canvas */
.mindmap-cosmic-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: 
    radial-gradient(circle at 15% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
  z-index: 1;
}

/* ==========================================================================
   jsMind Core Theme Customizations (Cosmic Space Theme)
   ========================================================================== */

/* Nodes */
jmnode.theme-cosmic {
  background-color: rgba(20, 24, 40, 0.94) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(139, 92, 246, 0.45) !important;
  border-radius: 10px !important;
  padding: 10px 18px !important;
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.25) !important;
  font-family: inherit !important;
  font-weight: 500 !important;
  font-size: 0.9rem !important;
  transition: all 0.2s ease !important;
  cursor: pointer;
  user-select: none;
}

jmnode.theme-cosmic:hover {
  border-color: rgba(168, 85, 247, 0.8) !important;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4) !important;
  transform: scale(1.02);
}

jmnode.theme-cosmic.selected {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.5) !important;
  background-color: rgba(25, 34, 58, 0.96) !important;
}

/* Root Node Special Styling */
jmnode.theme-cosmic.root {
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.95), rgba(30, 27, 75, 0.95)) !important;
  border: 2px solid #a855f7 !important;
  color: #ffffff !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  box-shadow: 0 0 32px rgba(168, 85, 247, 0.5), inset 0 0 16px rgba(168, 85, 247, 0.25) !important;
  border-radius: 14px !important;
  padding: 14px 24px !important;
}

/* Constellation Connecting Lines */
jmcanvas.theme-cosmic {
  stroke: rgba(139, 92, 246, 0.5) !important;
  stroke-width: 2px !important;
}

svg.jsmind.theme-cosmic path {
  stroke: rgba(139, 92, 246, 0.55) !important;
  stroke-width: 2px !important;
}

/* Node editing input */
#jsmind_container input.jsmind-editor {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 2px solid #38bdf8 !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.6) !important;
  font-family: inherit !important;
  font-size: 0.95rem !important;
  outline: none !important;
}

/* Expander handles */
jmexpander {
  color: #c084fc !important;
  background: #1e1b4b !important;
  border: 1px solid rgba(139, 92, 246, 0.5) !important;
  border-radius: 50% !important;
  width: 14px !important;
  height: 14px !important;
  line-height: 12px !important;
  font-size: 11px !important;
  text-align: center !important;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.4) !important;
}

jmexpander:hover {
  background: #38bdf8 !important;
  color: #0f172a !important;
  border-color: #38bdf8 !important;
}

/* ==========================================================================
   Preset Custom Node Colors (Luminous High-Contrast Neon Space Glow)
   ========================================================================== */

jmnode[data-cosmic-color="purple"] {
  background: rgba(88, 28, 135, 0.95) !important;
  color: #ffffff !important;
  border: 1.5px solid #c084fc !important;
  box-shadow: 0 0 22px rgba(192, 132, 252, 0.75), inset 0 0 8px rgba(255, 255, 255, 0.25) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

jmnode[data-cosmic-color="cyan"] {
  background: rgba(14, 116, 144, 0.95) !important;
  color: #ffffff !important;
  border: 1.5px solid #22d3ee !important;
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.75), inset 0 0 8px rgba(255, 255, 255, 0.25) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

jmnode[data-cosmic-color="gold"] {
  background: rgba(180, 83, 9, 0.95) !important;
  color: #ffffff !important;
  border: 1.5px solid #fbbf24 !important;
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.75), inset 0 0 8px rgba(255, 255, 255, 0.25) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

jmnode[data-cosmic-color="rose"] {
  background: rgba(190, 18, 60, 0.95) !important;
  color: #ffffff !important;
  border: 1.5px solid #fb7185 !important;
  box-shadow: 0 0 22px rgba(251, 113, 133, 0.75), inset 0 0 8px rgba(255, 255, 255, 0.25) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

jmnode[data-cosmic-color="emerald"] {
  background: rgba(4, 120, 87, 0.95) !important;
  color: #ffffff !important;
  border: 1.5px solid #34d399 !important;
  box-shadow: 0 0 22px rgba(52, 211, 153, 0.75), inset 0 0 8px rgba(255, 255, 255, 0.25) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

jmnode[data-cosmic-color="blue"] {
  background: rgba(29, 78, 216, 0.95) !important;
  color: #ffffff !important;
  border: 1.5px solid #60a5fa !important;
  box-shadow: 0 0 22px rgba(96, 165, 250, 0.75), inset 0 0 8px rgba(255, 255, 255, 0.25) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

/* ==========================================================================
   Modals: Saved Constellations & Share Dialog
   ========================================================================== */

.mindmap-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(5, 7, 18, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.mindmap-modal-card {
  width: 100%;
  max-width: 620px;
  background: rgba(15, 20, 38, 0.96);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(139, 92, 246, 0.2);
  padding: 1.75rem;
  position: relative;
  animation: modalEnter 0.25s ease-out;
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.mindmap-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.85rem;
}

.mindmap-modal-header h3 {
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
}

.mindmap-modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.mindmap-modal-close:hover {
  color: #ffffff;
}

.mindmap-list-container {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.35rem;
}

.mindmap-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: all 0.2s ease;
}

.mindmap-list-item:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.35);
}

.mindmap-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mindmap-item-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #f8fafc;
}

.mindmap-item-meta {
  font-size: 0.75rem;
  color: #94a3b8;
}

.mindmap-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mindmap-item-btn {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.mindmap-item-btn.open-btn {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.mindmap-item-btn.open-btn:hover {
  background: rgba(56, 189, 248, 0.28);
}

.mindmap-item-btn.delete-btn {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.mindmap-item-btn.delete-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Share URL Card */
.share-url-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(9, 12, 26, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  margin: 1.25rem 0;
}

.share-url-box input {
  flex: 1;
  background: none;
  border: none;
  color: #38bdf8;
  font-family: monospace;
  font-size: 0.85rem;
  outline: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .mindmap-header {
    padding: 0.6rem 0.85rem;
    gap: 0.5rem;
  }
  .mindmap-title-input {
    min-width: 160px;
    font-size: 0.9rem;
  }
  .mindmap-action-btn span:not(.btn-icon) {
    display: none;
  }
  .node-tool-btn span:not(.tool-icon) {
    display: none;
  }
  #jsmind_container {
    height: calc(100vh - 120px);
  }
}