/* Smart Board Stylesheet - v2.1 (Accessibility updated: WCAG AA contrast) */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f0f0;
  overflow: hidden;
  height: 100vh;
}

.smartboard-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Toolbar */
.toolbar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  max-height: 120px;
}

.toolbar-section {
  display: flex;
  gap: 6px;
  align-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  padding-right: 12px;
}

.toolbar-section:last-child {
  border-right: none;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.tool-btn.active {
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.color-picker-wrapper input {
  width: 40px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  cursor: pointer;
}

.width-slider {
  width: 80px;
  height: 4px;
  cursor: pointer;
}

select,
label {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

select option {
  background: #667eea;
  color: white;
}

label {
  background: transparent;
  border: none;
  padding: 0;
  margin-right: 4px;
  font-size: 12px;
  font-weight: 500;
}

#zoomLevel {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  min-width: 50px;
  text-align: center;
}

/* Canvas */
.canvas-wrapper {
  flex: 1;
  background: white;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

canvas {
  background: white;
  cursor: crosshair;
  box-shadow: none;
  border-radius: 0;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Fabric stacks a transparent "upper canvas" over the drawing surface.
   The generic `canvas { background: white }` rule above painted it opaque,
   hiding every committed stroke on the lower canvas. Keep it transparent. */
.canvas-container .upper-canvas {
  background: transparent !important;
  box-shadow: none;
}

canvas.eraser-mode {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><rect x="4" y="6" width="16" height="12" fill="red" opacity="0.5"/></svg>')
    12 12,
    auto;
}

/* Page Navigator */
.page-navigator {
  background: #f8f9fa;
  border-top: 1px solid #ddd;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
}

.page-nav-btn {
  background: #5a67d8;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.2s;
}

.page-nav-btn:hover {
  background: #4c51bf;
}

.page-indicator {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: #666;
  font-weight: 500;
  min-width: 80px;
}

.page-thumbnail {
  display: inline-block;
  width: 40px;
  height: 30px;
  border: 2px solid #ddd;
  margin: 0 2px;
  cursor: pointer;
  border-radius: 2px;
  overflow: hidden;
  background: white;
  transition: all 0.2s;
}

.page-thumbnail:hover {
  border-color: #667eea;
  box-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
}

.page-thumbnail.active {
  border-color: #667eea;
  box-shadow: 0 0 12px rgba(102, 126, 234, 0.5);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: #333;
  color: white;
  padding: 12px 20px;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Grid Background */
canvas[data-background='grid'] {
  background-image:
    linear-gradient(0deg, #f0f0f0 1px, transparent 1px),
    linear-gradient(90deg, #f0f0f0 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Ruled Background */
canvas[data-background='ruled'] {
  background:
    repeating-linear-gradient(0deg, transparent, transparent 29px, #f0f0f0 29px, #f0f0f0 30px),
    white;
}

/* Responsive */
@media (max-width: 1024px) {
  .toolbar {
    font-size: 12px;
  }

  .toolbar-section {
    gap: 4px;
    padding-right: 8px;
  }

  .tool-btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  canvas {
    max-width: 95vw;
    max-height: 70vh;
  }
}

/* Footer */
.smartboard-footer {
  background: #f8f9fa;
  border-top: 1px solid #ddd;
  padding: 8px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: #666;
}

.smartboard-footer a {
  color: #667eea;
  text-decoration: none;
  transition: color 0.2s;
}

.smartboard-footer a:hover {
  color: #764ba2;
  text-decoration: underline;
}

.smartboard-footer .separator {
  color: #ddd;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  min-width: 400px;
  max-width: 90%;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1999;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #ddd;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 30px;
  height: 30px;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
}

.modal-body {
  padding: 20px;
}

.modal-body h3 {
  margin-top: 15px;
  margin-bottom: 10px;
  color: #667eea;
  font-size: 16px;
}

.modal-body p {
  margin: 5px 0;
  font-size: 14px;
  color: #555;
  line-height: 1.4;
}

.modal-body strong {
  color: #333;
}

.modal-body label {
  display: block;
  font-weight: 500;
  margin-bottom: 10px;
  color: #333;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-group label {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  font-weight: 400;
}

.radio-group input[type="radio"] {
  margin-right: 8px;
}

.modal-body input[type="text"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

.modal-btn {
  background: #5a67d8;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.modal-btn:hover {
  background: #4c51bf;
}

/* Print Styles */
@media print {
  .toolbar,
  .page-navigator,
  .smartboard-footer {
    display: none;
  }

  canvas {
    box-shadow: none;
  }
}
