/* ==========================================================================
   Interactive Collaborative Meeting Whiteboard (协作画板)
   Dark theme, glassmorphism floating modal with drawing tools & chat sharing
   ========================================================================== */

:root {
  --wb-bg-modal: rgba(15, 23, 42, 0.96);
  --wb-bg-header: rgba(30, 41, 59, 0.85);
  --wb-bg-bar: rgba(30, 41, 59, 0.7);
  --wb-border: rgba(255, 255, 255, 0.12);
  --wb-border-light: rgba(255, 255, 255, 0.2);
  --wb-primary: #3b82f6;
  --wb-primary-hover: #2563eb;
  --wb-accent: #06b6d4;
  --wb-danger: #ef4444;
  --wb-text: #f8fafc;
  --wb-text-muted: #94a3b8;
  --wb-active: #2563eb;
}

/* Modal Overlay Backdrop */
.whiteboard-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: wbFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes wbFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* Main Floating Window */
.whiteboard-window {
  background: var(--wb-bg-modal);
  border: 1px solid var(--wb-border);
  border-radius: 16px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  width: 1040px;
  max-width: calc(100vw - 32px);
  height: 740px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: width 0.2s ease, height 0.2s ease, transform 0.2s ease;
}

.whiteboard-window.fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0;
  border: none;
}

/* Header & Drag Handle */
.whiteboard-header {
  height: 52px;
  background: var(--wb-bg-header);
  border-bottom: 1px solid var(--wb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  user-select: none;
  cursor: grab;
}

.whiteboard-header:active {
  cursor: grabbing;
}

.wb-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wb-header-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.wb-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--wb-text);
  letter-spacing: -0.2px;
}

.wb-context-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
  border-radius: 9999px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wb-sync-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.wb-sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: wbPulse 2s infinite;
}

@keyframes wbPulse {
  0% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0.4; transform: scale(0.9); }
}

.wb-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wb-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--wb-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wb-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--wb-text);
}

.wb-icon-btn.close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--wb-danger);
}

/* Toolbar */
.whiteboard-toolbar {
  background: var(--wb-bg-bar);
  border-bottom: 1px solid var(--wb-border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  user-select: none;
}

.wb-tools-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.wb-tool-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.5);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.wb-tool-btn {
  height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--wb-text-muted);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wb-tool-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.wb-tool-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--wb-text);
}

.wb-tool-btn.active {
  background: var(--wb-active);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* Stroke Thickness Selectors */
.wb-stroke-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.5);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.wb-stroke-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--wb-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.wb-stroke-btn:hover {
  background: rgba(255, 255, 255, 0.07);
}

.wb-stroke-btn.active {
  background: rgba(255, 255, 255, 0.15);
}

.wb-stroke-dot {
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.wb-stroke-btn.active .wb-stroke-dot {
  background-color: var(--wb-primary);
  box-shadow: 0 0 6px var(--wb-primary);
}

/* Color Swatches */
.wb-color-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wb-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.wb-color-swatch:hover {
  transform: scale(1.15);
}

.wb-color-swatch.active {
  border-color: #ffffff;
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.wb-color-picker-label {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.wb-color-picker-label:hover {
  transform: scale(1.15);
}

.wb-color-picker-label input[type=\"color\"] {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 44px;
  height: 44px;
  opacity: 0;
  cursor: pointer;
}

/* History (Undo / Redo / Clear) */
.wb-history-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.5);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.wb-action-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--wb-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.wb-action-icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--wb-text);
}

.wb-action-icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Canvas Background Chooser */
.wb-bg-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.5);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.wb-bg-btn {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--wb-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.wb-bg-btn:hover {
  color: var(--wb-text);
}

.wb-bg-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Primary Action Buttons (Send to Chat & Save PNG) */
.wb-export-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.wb-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
}

.wb-btn svg {
  width: 16px;
  height: 16px;
}

.wb-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--wb-text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.wb-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.wb-btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.wb-btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
}

.wb-btn-primary:active {
  transform: translateY(0);
}

.wb-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Canvas Stage */
.whiteboard-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  background-color: #0b1120;
}

.whiteboard-canvas-wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Canvas Background Themes */
.whiteboard-canvas-wrapper.bg-dark {
  background-color: #0f172a;
}

.whiteboard-canvas-wrapper.bg-light {
  background-color: #ffffff;
}

.whiteboard-canvas-wrapper.bg-grid {
  background-color: #0f172a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;
}

.whiteboard-canvas-wrapper.bg-light.bg-grid {
  background-color: #f8fafc;
  background-image: radial-gradient(rgba(15, 23, 42, 0.15) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Canvas Layers */
.wb-canvas-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.wb-canvas-main {
  z-index: 1;
}

.wb-canvas-overlay {
  z-index: 2;
  pointer-events: auto;
}

/* Dynamic Cursor States */
.wb-cursor-pen { cursor: crosshair !important; }
.wb-cursor-highlighter { cursor: crosshair !important; }
.wb-cursor-rect { cursor: crosshair !important; }
.wb-cursor-circle { cursor: crosshair !important; }
.wb-cursor-arrow { cursor: crosshair !important; }
.wb-cursor-text { cursor: text !important; }
.wb-cursor-eraser { cursor: cell !important; }

/* Inline Floating Text Input */
.wb-text-input-overlay {
  position: absolute;
  z-index: 10;
  min-width: 160px;
  min-height: 38px;
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px dashed var(--wb-primary);
  border-radius: 8px;
  padding: 6px 10px;
  outline: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  line-height: 1.35;
  resize: both;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}

.wb-text-input-overlay:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Status Toast inside Whiteboard */
.wb-toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  padding: 8px 18px;
  border-radius: 9999px;
  border: 1px solid var(--wb-border);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 30;
}

.wb-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.wb-toast.success {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.wb-toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Minimized Floating Widget */
.wb-minimized-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  height: 48px;
  padding: 0 18px;
  background: var(--wb-bg-modal);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 9999px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(59, 130, 246, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 1501;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.wb-minimized-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(59, 130, 246, 0.3);
}

.wb-minimized-pill .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 8px #3b82f6;
}

/* Remote Collaborator Cursor Badge */
.wb-remote-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 4px;
  transform: translate(-2px, -2px);
  transition: transform 0.08s linear;
}

.wb-remote-cursor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 6px currentColor;
}

.wb-remote-cursor-label {
  font-size: 10px;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .whiteboard-toolbar {
    padding: 8px 10px;
  }
  .wb-tool-btn span {
    display: none;
  }
  .wb-export-group {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
    margin-top: 4px;
  }
}
