/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0a0a0f; color: #e0e0e0; }

/* ===== SCREEN TOGGLE ===== */
.screen-hidden { display: none !important; }

/* ===== JOIN SCREEN ===== */
#join-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100%; padding: 20px;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 70%);
}

.join-card {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 40px 32px; max-width: 400px; width: 100%;
  text-align: center; backdrop-filter: blur(10px);
}

.join-card h1 {
  font-size: 1.8rem; font-weight: 700; margin-bottom: 8px;
  background: linear-gradient(135deg, #7C3AED, #a78bfa); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}

.join-card .subtitle { color: #888; margin-bottom: 24px; font-size: 0.95rem; }

#join-form { display: flex; flex-direction: column; gap: 12px; }

#join-form input {
  padding: 14px 16px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08); color: #fff; font-size: 1rem;
  outline: none; transition: border-color 0.2s;
}
#join-form input:focus { border-color: #7C3AED; }
#join-form input::placeholder { color: #666; }

#join-btn {
  padding: 14px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, #7C3AED, #6D28D9); color: #fff;
  font-size: 1.05rem; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
#join-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(124,58,237,0.4); }
#join-btn:active { transform: translateY(0); }
#join-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.error { color: #ef4444; font-size: 0.85rem; margin-top: 8px; }

/* ===== GRAPH SCREEN ===== */
#graph-screen { position: relative; height: 100%; width: 100%; }

#graph-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  touch-action: none;
}

/* ===== COUNTER OVERLAY ===== */
#counter-overlay {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  padding: 8px 20px; border-radius: 20px;
  font-size: 0.9rem; color: #ccc; pointer-events: none;
  border: 1px solid rgba(255,255,255,0.08);
}
#node-count { font-weight: 700; color: #a78bfa; }

/* ===== CONTROLS ===== */
#controls {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  padding: 12px 20px; border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
}

#color-picker-wrap { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
#color-picker {
  -webkit-appearance: none; appearance: none; width: 36px; height: 36px;
  border: 2px solid rgba(255,255,255,0.2); border-radius: 50%;
  background: none; cursor: pointer; padding: 0;
}
#color-picker::-webkit-color-swatch-wrapper { padding: 2px; }
#color-picker::-webkit-color-swatch { border-radius: 50%; border: none; }
#color-picker::-moz-color-swatch { border-radius: 50%; border: none; }

.control-btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid rgba(124,58,237,0.4);
  background: rgba(124,58,237,0.15); color: #a78bfa;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.control-btn:hover { background: rgba(124,58,237,0.3); }

.link-btn {
  background: linear-gradient(135deg, #7C3AED, #6D28D9); color: #fff;
  border-color: #7C3AED;
}
.link-btn:hover { background: linear-gradient(135deg, #6D28D9, #5B21B6); }

/* ===== MY NODE INFO ===== */
#my-node-info {
  position: absolute; top: 16px; right: 16px;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  padding: 8px 16px; border-radius: 12px;
  font-size: 0.85rem; color: #aaa;
  border: 1px solid rgba(255,255,255,0.08);
}

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}

/* FIX: hidden attribute was overridden by display:flex above */
.modal-overlay[hidden] { display: none !important; }

.modal-card {
  background: #1a1a2e; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px; padding: 32px 28px; max-width: 400px; width: 100%;
  text-align: center;
}
.modal-card h2 {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 8px;
  background: linear-gradient(135deg, #7C3AED, #a78bfa); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.modal-card .subtitle { color: #888; margin-bottom: 20px; font-size: 0.9rem; }

.modal-card form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.modal-card label { color: #aaa; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.modal-card input[type="text"],
.modal-card input[type="email"] {
  padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08); color: #fff; font-size: 1rem;
  outline: none; transition: border-color 0.2s;
}
.modal-card input:focus { border-color: #7C3AED; }

.modal-actions {
  display: flex; gap: 10px; margin-top: 16px; justify-content: center;
}
.modal-btn-primary {
  padding: 12px 24px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, #7C3AED, #6D28D9); color: #fff;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.modal-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(124,58,237,0.4); }
.modal-btn-secondary {
  padding: 12px 24px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15); background: transparent;
  color: #aaa; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.modal-btn-secondary:hover { background: rgba(255,255,255,0.05); }

/* ===== LINK MODAL ===== */
.link-modal-card {
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.link-section {
  padding: 16px 0;
}
.link-section-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}
.link-section-title {
  font-size: 1rem; font-weight: 700; color: #e0e0e0;
  margin-bottom: 4px;
}
.link-section-desc {
  font-size: 0.85rem; color: #888;
  margin-bottom: 12px;
}

.bump-action-btn {
  width: 100%; max-width: 240px;
}
.bump-action-btn.listening {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #10b981;
  animation: pulse-btn 2s ease-in-out infinite;
}
@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
}

.bump-status {
  font-size: 0.8rem; color: #fbbf24;
  margin-top: 8px;
}

.link-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 0; color: #555; font-size: 0.8rem;
}
.link-divider::before, .link-divider::after {
  content: ""; flex: 1; height: 1px;
  background: rgba(255,255,255,0.1);
}

/* QR code canvas */
#link-qr-canvas-wrap {
  display: flex; justify-content: center; margin: 12px 0 4px;
}
#link-qr-canvas-wrap canvas {
  border-radius: 12px; border: 4px solid #7C3AED;
}
.qr-url-text {
  color: #666; font-size: 0.7rem; word-break: break-all;
  margin-bottom: 4px; font-family: monospace;
}

/* ===== ADMIN PANEL (localhost only) ===== */
#admin-panel {
  position: absolute; top: 60px; left: 16px;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(10px);
  padding: 14px 18px; border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 0.8rem; color: #ccc;
  max-width: 320px; z-index: 100;
}
.admin-title {
  font-weight: 700; color: #ef4444; margin-bottom: 10px;
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.admin-row:last-child { margin-bottom: 0; }
.admin-row label { color: #999; font-size: 0.75rem; }
.admin-row input[type="text"] {
  padding: 6px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08); color: #fff; font-size: 0.75rem;
  outline: none; flex: 1; min-width: 120px;
}
#admin-panel button {
  padding: 6px 12px; border-radius: 6px; border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.15); color: #fca5a5;
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
#admin-panel button:hover { background: rgba(239, 68, 68, 0.3); }
#admin-bump-status {
  font-size: 0.7rem; color: #fbbf24;
}

/* ===== PROJECTOR MODE ===== */
body.projector #controls,
body.projector #my-node-info,
body.projector #admin-panel { display: none !important; }
body.projector #counter-overlay { font-size: 1.2rem; padding: 12px 28px; }

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  .join-card { padding: 28px 20px; }
  .join-card h1 { font-size: 1.5rem; }
  #controls { padding: 10px 14px; gap: 8px; flex-wrap: wrap; justify-content: center; }
  .control-btn { padding: 8px 12px; font-size: 0.8rem; }
  #admin-panel { max-width: calc(100% - 32px); }
  .modal-card { padding: 24px 20px; }
  .link-modal-card { max-height: 85vh; }
  #link-qr-canvas-wrap canvas { max-width: 180px; max-height: 180px; }
}
