@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@700&display=swap');

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

:root {
  --bg-primary: #3d3228;
  --bg-secondary: #2c2218;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.5);
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(160, 120, 60, 0.5);
  --gold: #8b6914;
  --gold-light: #c4981a;
  --gold-dim: rgba(139, 105, 20, 0.1);
  --text-primary: #2c2218;
  --text-secondary: #6b5c4c;
  --text-muted: #a89882;
  --accent: #8b6914;
  --danger: #9e2a2a;
  --shadow: 0 4px 20px rgba(44, 34, 24, 0.1);
  --shadow-gold: 0 4px 16px rgba(139, 105, 20, 0.15);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
}

body.connecting #board {
  cursor: crosshair;
}

/* Sidebar */
#sidebar {
  width: 280px;
  background: var(--bg-secondary);
  padding: 32px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  position: relative;
}

#sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, rgba(196, 152, 26, 0.2), transparent);
  pointer-events: none;
}

#sidebar, #sidebar * {
  color: #e8dfd3;
}

#sidebar h1 {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 4px;
}

#sidebar .subtitle {
  text-align: center;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #8a7b6a;
  margin-top: -8px;
  margin-bottom: 16px;
}

#new-session-btn {
  background: linear-gradient(135deg, var(--gold), #b8960c);
  color: #0a0a0f;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-gold);
}

#new-session-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(212, 175, 55, 0.25);
}

#new-session-btn:active {
  transform: translateY(0);
}

#session-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.session-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 400;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  border: 1px solid transparent;
  color: #a89882;
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  color: #e8dfd3;
}

.session-item.active {
  background: rgba(196, 152, 26, 0.12);
  border-color: rgba(196, 152, 26, 0.25);
  color: #c4981a;
  font-weight: 500;
}

.session-item .delete-session {
  opacity: 0;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  transition: opacity 0.2s;
  line-height: 1;
}

.session-item:hover .delete-session {
  opacity: 0.6;
}

.session-item:hover .delete-session:hover {
  opacity: 1;
}

#instructions {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: #6b5c4c;
  line-height: 2;
}

#instructions strong {
  color: #8a7b6a;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

#instructions span {
  color: #c4981a;
  opacity: 0.6;
}

/* Board */
#board {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #3d3228;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-size: 36px 36px;
}

#lines-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#lines-svg line {
  pointer-events: stroke;
  cursor: pointer;
  stroke-width: 2;
}

#lines-svg line:hover {
  stroke-opacity: 1 !important;
  filter: drop-shadow(0 0 4px rgba(139, 105, 20, 0.4));
}

#boxes-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* Boxes - NO transition on position to prevent drag lag */
.box {
  position: absolute;
  min-width: 160px;
  max-width: 320px;
  background: #4a3d31;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px 20px;
  padding-bottom: 24px;
  cursor: grab;
  user-select: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.box:hover {
  border-color: rgba(196, 152, 26, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.box.dragging {
  cursor: grabbing;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 100;
  border-color: var(--gold);
}

.box.connect-source {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(196, 152, 26, 0.2), 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Connect handle - dot at bottom center */
.connect-handle {
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-radius: 50%;
  cursor: crosshair;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.box:hover .connect-handle {
  opacity: 0.7;
}

.connect-handle:hover {
  opacity: 1 !important;
  transform: translateX(-50%) scale(1.4);
}

.box.connect-source .connect-handle {
  opacity: 1;
  animation: pulse-dot 1s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.5); }
}

/* When in connect mode, all boxes show a target cursor */
body.connecting .box {
  cursor: crosshair;
}

body.connecting .box:not(.connect-source):hover {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(139, 105, 20, 0.2);
}

.box-text {
  outline: none;
  min-height: 22px;
  font-size: 13px;
  line-height: 1.6;
  color: #e8dfd3;
  word-wrap: break-word;
  font-weight: 400;
}

.box-text:focus {
  cursor: text;
}

.box-text:empty::before {
  content: 'Type something...';
  color: #7a6d5e;
  font-style: italic;
}

/* Empty state */
#empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #7a6d5e;
  font-size: 16px;
  pointer-events: none;
  text-align: center;
  font-weight: 300;
  letter-spacing: 0.5px;
}

#empty-state::before {
  content: '+';
  display: block;
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
  font-weight: 200;
  color: #7a6d5e;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Selection */
::selection {
  background: rgba(139, 105, 20, 0.2);
}
