/* CCM Stakeholder Map - Refined Styles */

/* Custom animations */
@keyframes pulse-slow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.animate-pulse-slow {
  animation: pulse-slow 3s ease-in-out infinite;
}

/* Canvas SVG - disable Tailwind's "transition: all" which causes instability */
#map-canvas,
#canvas-transform,
#nodes-layer,
#connections-layer {
  transition: none !important;
}

/* Canvas node styles */
.stakeholder-node {
  cursor: move;
  user-select: none;
  /* IMPORTANT: Do NOT add transition or transform here - conflicts with SVG
     transform attribute and causes element instability during hover/click */
}

.stakeholder-node:hover .node-ring {
  stroke-width: 5;
  stroke-opacity: 0.8;
  transition: stroke-width 0.15s ease, stroke-opacity 0.15s ease;
}

.stakeholder-node:hover .node-circle {
  stroke-width: 4;
  transition: stroke-width 0.15s ease;
}

.stakeholder-node.selected .node-ring {
  stroke-width: 5;
  stroke-opacity: 0.8;
}

/* Category colors for nodes - refined palette */
.node-ally { fill: #2d9d5d; }
.node-advocate { fill: #4a7fc7; }
.node-decisionmaker { fill: #8b5fc7; }
.node-obstacle { fill: #cf5858; }
.node-dependency { fill: #d4874c; }
.node-opportunity { fill: #c4a82e; }

/* Ring colors */
.ring-ally { stroke: #2d9d5d; }
.ring-advocate { stroke: #4a7fc7; }
.ring-decisionmaker { stroke: #8b5fc7; }
.ring-obstacle { stroke: #cf5858; }
.ring-dependency { stroke: #d4874c; }
.ring-opportunity { stroke: #c4a82e; }

/* Connection line styles */
.connection-line {
  stroke: #8a8580;
  stroke-width: 2;
  fill: none;
  transition: stroke-width 0.15s ease;
}

.connection-line:hover {
  stroke: #1a1a1a;
  stroke-width: 3;
  cursor: pointer;
}

.connection-line.type-reports-to {
  stroke-dasharray: none;
}

.connection-line.type-influences {
  stroke-dasharray: 8 4;
}

.connection-line.type-blocks {
  stroke: #cf5858;
  stroke-dasharray: 4 4;
}

.connection-line.type-supports {
  stroke: #2d9d5d;
}

.connection-line.type-depends-on {
  stroke: #d4874c;
  stroke-dasharray: 12 4;
}

/* Connection labels */
.connection-label {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500;
  pointer-events: none;
  text-shadow:
    -1px -1px 0 white,
    1px -1px 0 white,
    -1px 1px 0 white,
    1px 1px 0 white,
    0 -1px 0 white,
    0 1px 0 white,
    -1px 0 0 white,
    1px 0 0 white;
}

/* Connection group hover effect */
.connection-group:hover .connection-line {
  stroke-width: 3;
}

.connection-group:hover .connection-label {
  font-weight: 600;
}

/* Node connect button */
.node-connect-btn {
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.stakeholder-node:hover .node-connect-btn {
  opacity: 1;
  pointer-events: auto;
}

.node-connect-btn:hover .connect-btn-circle {
  fill: #4a7fc7;
}

/* Connections panel */
#connections-panel {
  font-family: 'DM Sans', system-ui, sans-serif;
}

#connections-list::-webkit-scrollbar {
  width: 4px;
}

#connections-list::-webkit-scrollbar-track {
  background: transparent;
}

#connections-list::-webkit-scrollbar-thumb {
  background: #e8e4de;
  border-radius: 2px;
}

.connection-item {
  transition: background-color 0.15s ease;
}

/* Template cards */
.template-card {
  background: white;
  border: 1px solid #e8e4de;
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: #1a1a1a;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(26, 26, 26, 0.08);
}

.template-card .template-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}

/* Stakeholder list cards */
.stakeholder-card {
  background: white;
  border: 1px solid #e8e4de;
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stakeholder-card:hover {
  border-color: #1a1a1a;
  box-shadow: 0 8px 24px -4px rgba(26, 26, 26, 0.06);
}

/* Category badges */
.category-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 100px;
}

.category-ally {
  background: #e8f5ed;
  color: #1e7a45;
}

.category-advocate {
  background: #e6f0fa;
  color: #2d5a9e;
}

.category-decisionmaker {
  background: #f0e8f7;
  color: #6b3fa7;
}

.category-obstacle {
  background: #fceaea;
  color: #a63c3c;
}

.category-dependency {
  background: #faf0e6;
  color: #b06a32;
}

.category-opportunity {
  background: #faf8e6;
  color: #9a8420;
}

/* Canvas panning */
#map-canvas.panning {
  cursor: grabbing;
}

/* Node tooltip */
.node-tooltip {
  position: absolute;
  background: white;
  border: 1px solid #e8e4de;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 20px 40px -8px rgba(26, 26, 26, 0.15);
  max-width: 300px;
  z-index: 100;
  pointer-events: none;
  font-family: 'DM Sans', system-ui, sans-serif;
}

.node-tooltip h4 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
  color: #1a1a1a;
}

.node-tooltip p {
  font-size: 14px;
  color: #8a8580;
  margin-bottom: 8px;
}

/* Context menu */
.context-menu {
  position: absolute;
  background: white;
  border: 1px solid #e8e4de;
  border-radius: 12px;
  box-shadow: 0 20px 40px -8px rgba(26, 26, 26, 0.15);
  z-index: 100;
  min-width: 160px;
  overflow: hidden;
  font-family: 'DM Sans', system-ui, sans-serif;
}

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  color: #1a1a1a;
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.context-menu button:hover {
  background: #f5f3ef;
}

.context-menu button.danger {
  color: #cf5858;
}

.context-menu button.danger:hover {
  background: #fceaea;
}

/* Avatar placeholder */
.avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f5f3ef 0%, #e8e4de 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8a8580;
  font-weight: 600;
  font-size: 14px;
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }

  .page-break {
    page-break-before: always;
  }
}

/* Watermark for private maps */
.watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 60px;
  font-family: 'Source Serif 4', Georgia, serif;
  color: rgba(26, 26, 26, 0.03);
  white-space: nowrap;
  pointer-events: none;
  z-index: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Responsive canvas height */
.canvas-height {
  height: calc(100vh - 280px);
  min-height: 350px;
  max-height: 600px;
}

@media (min-width: 640px) {
  .canvas-height {
    height: 600px;
    max-height: none;
  }
}

/* Mobile-specific adjustments */
@media (max-width: 639px) {
  /* Ensure modals slide up from bottom */
  #stakeholder-modal > div:first-child,
  #new-map-modal > div:first-child,
  #connection-modal > div:first-child {
    align-items: flex-end;
  }

  /* Bottom toolbar safe area */
  #canvas-view {
    padding-bottom: 80px;
  }

  /* Legend mobile positioning */
  #canvas-legend {
    position: fixed;
    top: auto;
    bottom: 80px;
    left: 16px;
    right: 16px;
    max-width: none;
  }

  /* Stakeholder cards - more compact on mobile */
  .stakeholder-card {
    padding: 16px;
  }

  /* Template cards - smaller padding */
  .template-card {
    padding: 16px;
  }

  .template-card .template-icon {
    font-size: 24px;
    margin-bottom: 6px;
  }

  /* Node tooltip - full width on mobile */
  .node-tooltip {
    left: 16px !important;
    right: 16px !important;
    max-width: none;
    bottom: 100px;
    top: auto !important;
  }

  /* Context menu - centered on mobile */
  .context-menu {
    left: 50% !important;
    transform: translateX(-50%);
    min-width: 200px;
  }

  /* Improve tap targets */
  button,
  select,
  input[type="checkbox"] {
    min-height: 44px;
  }

  input[type="checkbox"] {
    min-height: auto;
    width: 20px;
    height: 20px;
  }

  /* Better touch scrolling */
  .overflow-y-auto {
    -webkit-overflow-scrolling: touch;
  }
}

/* Safe area insets for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 639px) {
    #export-menu > div:last-child > div:last-child {
      height: calc(24px + env(safe-area-inset-bottom));
    }

    .sm\\:hidden.fixed.bottom-4 {
      bottom: calc(16px + env(safe-area-inset-bottom));
    }
  }
}

/* Focus states for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #1a1a1a;
  outline-offset: 2px;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Selection color */
::selection {
  background: rgba(26, 26, 26, 0.15);
}

/* Form input refinements */
input::placeholder,
textarea::placeholder {
  color: #8a8580;
}

/* Influence badges */
.influence-high {
  background: #f0e8f7;
  color: #6b3fa7;
}

.influence-medium {
  background: #e6f0fa;
  color: #2d5a9e;
}

.influence-low {
  background: #f5f3ef;
  color: #8a8580;
}

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f5f3ef;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #e8e4de;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #8a8580;
}

/* Keyboard shortcut styling */
kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  padding: 2px 6px;
  background: #f5f3ef;
  border: 1px solid #e8e4de;
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* Help modal list styling */
#help-modal ol li::marker {
  color: #8a8580;
}

#help-modal ul li::before {
  content: "•";
  color: #8a8580;
  margin-right: 0.5rem;
}

/* Legend transition */
#legend-compact,
#legend-expanded {
  transition: opacity 0.15s ease;
}

/* Tooltip improvements for touch devices */
@media (hover: none) {
  [title] {
    position: relative;
  }
}
