/* ============= GLOBAL STYLES ============= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background-color: #CCCCCC;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============= SIDEBAR STYLES ============= */
.sidebar {
  width: 20%;
  background: #ffffff;
  color: #000;
  padding: 20px 15px;
  overflow-y: auto;
  border-right: 1px solid #cccccc;
  z-index: 1000;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: flex-start;
}

.sidebar h1 {
  grid-column: 1 / -1;
  font-size: 16px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #cccccc;
  color: #000000;
  text-align: center;
  font-weight: 400;
}

.back-link {
  grid-column: 1 / -1;
  display: inline-block;
  color: #000000;
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid #000000;
  border-radius: 50px;
  margin-bottom: 15px;
  font-size: 11px;
  transition: all 0.2s;
  text-align: center;
}

.back-link:hover {
  background: #000000;
  color: #ffffff;
}

/* ============= TOOLS GRID CONTAINER ============= */
.tools-grid-container {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ============= TOOL ITEM STYLES ============= */
.tool-item {
  width: 100%;
  aspect-ratio: 1;
  background: #f5f5f5;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  padding: 8px;
}

/* Floating animation keyframes - Plays on hover */
@keyframes float {
  0% {
    transform: translateY(0px) translateX(0px) rotate(0deg);
  }
  25% {
    transform: translateY(-15px) translateX(8px) rotate(3deg);
  }
  50% {
    transform: translateY(-8px) translateX(-8px) rotate(-2deg);
  }
  75% {
    transform: translateY(-20px) translateX(5px) rotate(2deg);
  }
  100% {
    transform: translateY(0px) translateX(0px) rotate(0deg);
  }
}

.tool-item:hover {
  border-color: #999999;
  background: #e0e0e0;
  animation: float 1s ease-in-out;
}

.tool-item.selected {
  background: #000000;
  border-color: #000000;
}

.tool-item svg {
  width: 80%;
  height: 80%;
  margin-bottom: 4px;
}

.tool-item img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.tool-name {
  display: none;
}

/* ============= INSTRUCTIONS PANEL ============= */
.instructions {
  grid-column: 1 / -1;
  background: #f5f5f5;
  padding: 15px;
  border: 1px solid #cccccc;
  font-size: 11px;
  line-height: 1.4;
  color: #666666;
}

.instructions strong {
  color: #000000;
  display: block;
  margin-bottom: 5px;
}

/* ============= EXPORT BUTTONS ============= */
.export-section {
  grid-column: 1 / -1;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #cccccc;
}

.export-section h2 {
  font-size: 13px;
  color: #000000;
  margin-bottom: 15px;
  text-align: center;
  font-weight: 400;
}

.export-btn {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid #000000;
  border-radius: 50px;
  background: #ffffff;
  color: #000;
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.export-btn:hover {
  background: #000000;
  color: #ffffff;
}

.export-btn:active {
  transform: none;
}

.export-btn.processing {
  opacity: 0.6;
  cursor: wait;
}

/* ============= HIDE OLD CONTROLS ============= */
.mode-switcher,
.page-tabs,
.controls-panel {
  display: none !important;
}

/* Show image controls by default */
.image-controls {
  grid-column: 1 / -1;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #cccccc;
}

/* ============= DROP ZONE ============= */
.drop-zone {
  border: 1px dashed #999999;
  padding: 30px;
  text-align: center;
  margin-bottom: 20px;
  cursor: pointer;
  transition: all 0.2s;
  background: #f5f5f5;
}

.drop-zone:hover {
  background: #e0e0e0;
  border-color: #666666;
}

.drop-zone.drag-over {
  background: #e0e0e0;
  border-color: #000000;
}

.drop-zone-text {
  color: #666666;
  font-size: 12px;
  margin-bottom: 8px;
}

.drop-zone-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

/* ============= FILTER CONTROLS ============= */
.filter-group {
  margin-bottom: 15px;
}

.filter-tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.filter-tool {
  width: 100%;
  aspect-ratio: 1;
  background: #f5f5f5;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  padding: 8px;
}

.filter-tool:hover {
  border-color: #999999;
  background: #e0e0e0;
  animation: float 1s ease-in-out;
}

.filter-tool img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.filter-btn {
  width: 100%;
  padding: 10px;
  margin: 5px 0;
  border: 1px solid #cccccc;
  border-radius: 50px;
  background: #f5f5f5;
  color: #666666;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: #000000;
  border-color: #000000;
  color: #ffffff;
}

.filter-btn:active {
  transform: none;
}

/* ============= CONTROL GROUP STYLES ============= */
.control-group {
  margin-bottom: 15px;
}

.control-group label {
  display: block;
  font-size: 11px;
  font-weight: 400;
  margin-bottom: 8px;
  color: #666666;
}

.control-group input[type="range"] {
  width: 100%;
  height: 2px;
  background: #cccccc;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #000000;
  cursor: pointer;
  transition: all 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  background: #333333;
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #000000;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
  background: #333333;
}

.value-display {
  float: right;
  color: #000000;
  font-weight: 400;
}

.btn-reset {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border: 1px solid #999999;
  border-radius: 50px;
  background: #f5f5f5;
  color: #666666;
  cursor: pointer;
  font-size: 11px;
  font-weight: 400;
  transition: all 0.2s;
}

.btn-reset:hover {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
}

.btn-reset:active {
  transform: none;
}

/* ============= MAIN CONTENT AREA ============= */
.main-content {
  width: 80%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ============= PREVIEW AREA ============= */
.preview-container {
  flex: 1;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* ============= PAGE SPREAD ============= */
.spread {
  display: block;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-width: 100%;
  max-height: 100%;
  height: calc(100vh - 40px);
  aspect-ratio: 230 / 185; /* Custom doublespread: 230mm × 185mm (115mm × 185mm per page) */
  position: relative;
  background: white;
  border: 1px solid #ddd;
  overflow: visible;
}

/* Visual center line to show page separation */
.spread::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e8e8e8;
  pointer-events: none;
  z-index: 1;
}

/* Hide center line when spread has background (from spray can tool) */
.spread[style*="background"]::after {
  display: none;
}

/* Hide center line during canvas capture */
.spread.capturing::after {
  display: none;
}

.page-content {
  display: none; /* Hide the old page divs */
}

/* ============= TEXT CONTENT ============= */
.text-content {
  position: absolute;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  cursor: move;
  padding: 20px;
  max-width: 400px;
  z-index: 5;
  pointer-events: auto;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  font-family: Arial, sans-serif;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}

/* Character-level styling */
.char {
  display: inline-block;
  position: relative;
  transition: all 0.1s ease;
}

.char.hovered {
  background: rgba(76, 175, 80, 0.1);
  outline: 1px solid rgba(76, 175, 80, 0.3);
  outline-offset: -1px;
}

/* Saw tool cut line indicator */
.char.cut-indicator::after {
  content: '';
  position: absolute;
  right: -2px;
  top: -5px;
  bottom: -5px;
  width: 3px;
  background: #FF5722;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 87, 34, 0.6);
  pointer-events: none;
  animation: cutLinePulse 0.8s ease-in-out infinite;
}

@keyframes cutLinePulse {
  0%, 100% {
    opacity: 0.8;
    transform: scaleY(1);
  }
  50% {
    opacity: 1;
    transform: scaleY(1.1);
  }
}

/* Position left text on left side initially */
#leftTextContent {
  left: 50px;
  top: 50px;
}

/* Position right text on right side initially */
#rightTextContent {
  left: calc(50% + 50px);
  top: 50px;
}

.text-content:hover {
  border-color: transparent;
}

.text-content.selected {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.text-content.dragging {
  opacity: 0.8;
  z-index: 100;
}

/* ============= ROTATION HANDLE ============= */
.rotation-handle {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: #FF9800;
  border: 2px solid white;
  border-radius: 50%;
  cursor: grab;
  display: none;
  z-index: 11;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.rotation-handle:active {
  cursor: grabbing;
}

.text-content.selected .rotation-handle {
  display: block;
}

/* ============= PAGE NUMBERS ============= */
.page-number {
  position: absolute;
  font-size: 24px;
  color: #000;
  cursor: move;
  z-index: 5;
  pointer-events: auto;
  padding: 5px 10px;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  font-family: Arial, sans-serif;
}

#leftPageNumber {
  left: 15mm;
  bottom: 15mm;
}

#rightPageNumber {
  right: 15mm;
  bottom: 15mm;
}

.page-number:hover {
  border-color: transparent;
}

.page-number.selected {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.page-number.dragging {
  opacity: 0.8;
  z-index: 100;
}

/* Page number rotation handle */
.page-number .rotation-handle {
  display: none;
}

.page-number.selected .rotation-handle {
  display: block;
}

/* ============= DRAGGABLE IMAGES ============= */
.draggable-image {
  position: absolute;
  cursor: move;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  z-index: 10;
  pointer-events: auto;
}

.draggable-image:hover {
  border-color: #4CAF50;
}

.draggable-image.selected {
  border-color: #4CAF50;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
  z-index: 50;
}

.draggable-image.dragging {
  z-index: 100;
}

.draggable-image img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #4CAF50;
  border: 2px solid white;
  border-radius: 50%;
  cursor: nwse-resize;
  z-index: 11;
  pointer-events: auto;
}

.image-rotation-handle {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #FF9800;
  border: 2px solid white;
  border-radius: 50%;
  cursor: grab;
  z-index: 11;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.image-rotation-handle:active {
  cursor: grabbing;
}

/* ============= CUSTOM CURSOR ============= */
.custom-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 36.96px;
  height: 36.96px;
  transform: translate(-18.48px, -18.48px);
  display: none;
  transition: transform 0.1s ease;
}

.custom-cursor.active {
  display: block;
}

.custom-cursor.animate {
  animation: cursorPulse 0.6s ease-out;
}

@keyframes cursorPulse {
  0%, 100% {
    transform: translate(-18.48px, -18.48px) rotate(0deg);
  }
  25% {
    transform: translate(-18.48px, -18.48px) rotate(-15deg);
  }
  75% {
    transform: translate(-18.48px, -18.48px) rotate(15deg);
  }
}

.custom-cursor img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Hide cursor only when over the spread with tool active */
.spread.tool-active {
  cursor: none;
}

.spread.tool-active * {
  cursor: none !important;
}

/* ============= TIMER STYLES ============= */
.design-timer {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #ffffff;
  color: #000000;
  padding: 12px 20px;
  border: 1px solid #000000;
  font-size: 16px;
  font-weight: 400;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

.timer-icon {
  font-size: 20px;
}

.timer-value {
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  min-width: 60px;
}

/* ============= NOTIFICATION ============= */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #000000;
  color: #ffffff;
  padding: 15px 25px;
  border: 1px solid #000000;
  opacity: 0;
  transition: all 0.2s;
  z-index: 10000;
}

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

/* ============= SCROLLBAR STYLES ============= */
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: #ffffff;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #cccccc;
}

.main-content::-webkit-scrollbar-track {
  background: #CCCCCC;
}

.main-content::-webkit-scrollbar-thumb {
  background: #999999;
}

/* ============= MODAL STYLES ============= */
.modal {
  display: none;
  position: fixed;
  z-index: 10001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: #ffffff;
  padding: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  min-width: 400px;
  animation: slideUp 0.3s ease;
  border: 1px solid #cccccc;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h2 {
  color: #000000;
  font-size: 22px;
  margin-bottom: 15px;
  text-align: center;
  font-weight: 400;
}

.modal-content p {
  color: #666666;
  font-size: 13px;
  margin-bottom: 20px;
  text-align: center;
}

.modal-content input[type="text"] {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  border: 1px solid #cccccc;
  background: #f5f5f5;
  color: #000;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.modal-content input[type="text"]:focus {
  outline: none;
  border-color: #000000;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 30px;
  font-size: 13px;
  font-weight: 400;
  border: 1px solid #000000;
  border-radius: 50px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
  color: #000000;
}

.modal-btn.save-btn {
  background: #000000;
  color: #ffffff;
}

.modal-btn.save-btn:hover {
  background: #333333;
}

.modal-btn.cancel-btn {
  background: #ffffff;
  color: #000000;
  border-color: #999999;
}

.modal-btn.cancel-btn:hover {
  background: #e0e0e0;
}

.modal-btn:active {
  transform: none;
}
