/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;
  background: #e0e0e0;
  touch-action: manipulation;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

#canvas {
  display: block;
  background: white;
  cursor: crosshair;
  touch-action: none;
}

/* Floating Controls */
.floating-controls {
  position: fixed;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  z-index: 1000;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 6px 10px;
  height: 44px;
  max-width: calc(100vw - 16px);
  opacity: 1;
  transform: translateY(0);
}

.floating-controls.hidden {
  opacity: 0;
  transform: translateY(60px);
  pointer-events: none;
}

/* Expand Toggle Button */
.expand-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #3498db !important;
  color: white;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  touch-action: manipulation;
  flex-shrink: 0;
  margin-left: auto;
  margin-right: 6px;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.expand-toggle-btn:hover {
  background: #2980b9 !important;
  transform: scale(1.05);
}

.expand-toggle-btn.active {
  transform: scale(1.1);
  background: #2980b9 !important;
}

/* Toolbar */
.main-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Tool Buttons */
.tool-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: #ecf0f1;
  color: #2c3e50;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  touch-action: manipulation;
  flex-shrink: 0;
}

.tool-btn.active {
  background: #3498db;
  color: white;
  border-color: #2980b9;
  transform: scale(1.05);
}

.tool-btn:hover:not(.active) {
  background: #d5dbdb;
}

/* Color/Size Picker */
.color-size-picker {
  position: fixed;
  bottom: 60px;
  right: 12px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  padding: 10px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 1001;
  max-width: calc(100vw - 24px);
}

.color-size-picker.visible {
  display: flex;
}

/* Color Palette */
.color-palette {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: center;
  max-width: 200px;
}

.color-btn {
  width: 22px;
  height: 22px;
  border: 2px solid #ccc;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  flex-shrink: 0;
}

.color-btn.active {
  border-color: #fff;
  border-width: 3px;
  transform: scale(1.08);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

/* Size Control */
.size-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.size-slider {
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: #ddd;
  outline: none;
  -webkit-appearance: none;
}

.size-slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.size-slider::-webkit-slider-thumb:hover {
  background: #2980b9;
  transform: scale(1.1);
}

.size-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.size-slider::-moz-range-thumb:hover {
  background: #2980b9;
  transform: scale(1.1);
}

.size-display {
  font-size: 16px;
  color: #666;
  min-width: 16px;
  text-align: center;
  font-weight: 500;
}

/* Utilities Menu */
.utilities-menu {
  position: fixed;
  bottom: 60px;
  left: 12px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 1001;
  transition: all 0.3s ease;
  min-width: 80px;
}

.utilities-menu.visible {
  display: flex;
}

.utilities-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.utility-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 10px;
  color: #2c3e50;
  min-height: 48px;
}

.utility-btn:hover {
  background: rgba(52, 152, 219, 0.1);
  transform: translateY(-1px);
}

.utility-btn.active {
  background: rgba(52, 152, 219, 0.2);
  color: #3498db;
}

.utility-btn i {
  font-size: 16px;
  margin-bottom: 2px;
}

.utility-btn span {
  font-weight: 500;
}

/* Status Square */
.status-circle {
  width: 40px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: bold;
  color: white;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
  cursor: pointer;
  pointer-events: auto;
  z-index: 1000;
}

.status-circle i {
  font-size: 12px;
}

.status-circle.connecting {
  background: #f39c12;
}

.status-circle.connected {
  background: #2ecc71;
}

.status-circle.disconnected {
  background: #e74c3c;
}

/* Tool Popup */
.tool-popup {
  position: fixed;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 1001;
  transition: all 0.3s ease;
  min-width: 140px;
}

.tool-popup.visible {
  display: flex;
}

.tool-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #2c3e50;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  text-align: left;
}

.tool-option:hover {
  background: rgba(52, 152, 219, 0.1);
}

.tool-option.active {
  background: rgba(52, 152, 219, 0.2);
  color: #3498db;
}

.tool-option i {
  width: 16px;
  text-align: center;
}

/* Zoom Controls */
.zoom-controls-popup {
  position: fixed;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  padding: 8px;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 1001;
}

.zoom-controls-popup.visible {
  display: flex;
}

.zoom-btn {
  width: 24px;
  height: 24px;
  border: none !important;
  border-radius: 50%;
  background: #3498db !important;
  color: white !important;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  outline: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-shadow: none !important;
  padding: 0;
  margin: 0;
  text-decoration: none;
}

.zoom-btn:hover {
  background: #2980b9 !important;
  transform: scale(1.1);
}

.zoom-btn:focus {
  background: #3498db !important;
  outline: none !important;
  box-shadow: none !important;
}

.zoom-btn:active {
  background: #2980b9 !important;
  transform: scale(0.95);
}

.zoom-display {
  font-size: 10px;
  font-weight: bold;
  color: #2c3e50;
  min-width: 32px;
  text-align: center;
}


/* User List Popup */
.user-list-popup {
  position: fixed;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  z-index: 1001;
  min-width: 200px;
  max-width: 300px;
  max-height: 300px;
}

.user-list-popup.visible {
  display: flex !important;
}

.user-list-header {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
  font-weight: bold;
  color: #2c3e50;
  text-align: center;
}

.user-list-content {
  padding: 8px;
  overflow-y: auto;
  max-height: 250px;
}

.user-list-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-list-item:hover {
  background: #f0f0f0;
}

.user-list-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}

.user-list-name {
  flex: 1;
  font-size: 14px;
  color: #2c3e50;
}

.user-list-location {
  font-size: 11px;
  color: #7f8c8d;
  margin-left: auto;
}

/* Drawing Preview */
.drawing-preview {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  z-index: 999;
  display: none;
}

.drawing-preview.eraser {
  background: rgba(255, 153, 204, 0.3);
  border-color: rgba(204, 51, 153, 0.6);
}

.drawing-preview.pencil {
  background: rgba(52, 152, 219, 0.2);
  border-color: rgba(52, 152, 219, 0.6);
}

.drawing-preview.highlighter {
  background: rgba(255, 255, 0, 0.3);
  border-color: rgba(255, 193, 7, 0.6);
}

/* Board Badge */
.board-badge {
  position: fixed;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  z-index: 999;
  transition: opacity 0.3s ease;
  pointer-events: none;
  user-select: none;
}

.board-badge.hidden {
  opacity: 0;
}

.board-badge.public {
  background: rgba(46, 204, 113, 0.8);
}

.board-badge.private {
  background: rgba(155, 89, 182, 0.8);
}

.horizontal-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* User ID Badge */
.user-id-badge {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  white-space: nowrap;
}

.user-id-badge.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
  pointer-events: none;
}

/* Help Button */
.help-button {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  opacity: 1;
  transform: translateY(0);
}

.help-button:hover {
  background: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.help-button i {
  color: var(--text-primary);
  font-size: 18px;
}

.help-button:hover i {
  color: white;
}

.help-button.hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

/* Tutorial Overlay */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  pointer-events: none;
}

.tutorial-backdrop {
  display: none;
}

.tutorial-spotlight {
  position: fixed;
  border: 3px solid #e74c3c;
  border-radius: 8px;
  z-index: 10001;
  pointer-events: none;
  background: transparent;
  box-shadow: 
    0 0 0 9999px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(231, 76, 60, 0.8);
  transition: all 0.3s ease;
  display: none;
}

.tutorial-content {
  position: relative;
  background: white;
  border-radius: 12px;
  width: 400px;
  height: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 20000;
  overflow: hidden;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
}

.tutorial-header {
  position: relative;
  padding: 16px 20px;
  background: #3498db;
  color: white;
  height: 24px;
  display: flex;
  align-items: center;
}

.tutorial-progress {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.tutorial-close {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.tutorial-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.tutorial-body {
  padding: 24px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tutorial-title {
  margin: 0 0 12px 0;
  color: #333;
  font-size: 20px;
  font-weight: 600;
}

.tutorial-text {
  margin: 0;
  color: #666;
  font-size: 16px;
  line-height: 1.5;
}

.tutorial-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f8f9fa;
  gap: 20px;
}

.tutorial-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 70px;
}

.tutorial-btn-primary {
  background: #e74c3c;
  color: white;
}

.tutorial-btn-primary:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

.tutorial-btn-secondary {
  background: transparent;
  color: #666;
  border: 1px solid #ddd;
}

.tutorial-btn-secondary:hover {
  background: #f0f0f0;
  color: #333;
}

.tutorial-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .tutorial-content {
    width: calc(100% - 40px);
    max-width: 400px;
    height: 300px;
  }
  
  .tutorial-footer {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .tutorial-btn {
    flex: 1;
    min-width: 0;
  }
  
  .help-button {
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
  }
  
  .help-button i {
    font-size: 16px;
  }
  
  .user-id-badge {
    top: 15px;
    font-size: 12px;
    padding: 6px 12px;
  }
}
