/* Only lock scroll on the canvas page */
body.canvas-page {
  margin: 0;
  padding: 0;
  height: 100vh;
  background-color: #f0f0f0;
  overflow: hidden;
}


#canvas-container {
  display: flex;
  justify-content: center;
  align-items: start;
  height: 100vh; /* Fill full screen height */
  width: 100vw;  /* Fill full screen width */
  background-color: transparent; /* don't interfere with canvas */
  overflow: hidden;
}
#canvas-shadow-wrapper {
  box-shadow: 0px 10px 25px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  overflow: hidden;
  background-color: white;
}

/* Make touch gestures feed into Konva (no scroll/zoom/selection while drawing) */
#canvas-container,
#canvas-shadow-wrapper,
.konvajs-content {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}


.toolbar {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 8px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  z-index: 10;
  display: flex;
  gap: 0;
  flex-wrap: wrap; /* Allow wrapping on very small screens */
  max-width: 98vw;
  width: max-content;
  align-items: center;
  font-size: 0.85rem;
  justify-content: center;
}

.toolbar label {
  font-size: 0.75rem;
  margin-left: 4px;
  white-space: nowrap;
}

.toolbar select,
.toolbar input[type="color"],
.toolbar input[type="range"],
.toolbar input[type="number"] {
  margin-left: 4px;
}

.toolbar input[type="range"] {
  width: 60px;
  min-width: 40px;
}

.toolbar input[type="number"] {
  width: 45px;
  min-width: 35px;
}

.toolbar select {
  width: 70px;
  min-width: 50px;
  font-size: 0.75rem;
}

/* Toolbar sections */
.toolbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  margin-right: 8px;
  flex-shrink: 1;
  min-width: 0;
}

.toolbar-section:last-child {
  margin-right: 0;
}

.drawing-tools {
  background: #f0f8ff;
  border: 1px solid #b8d4f0;
}

.text-tools {
  background: #f5f8f0;
  border: 1px solid #c8d4b8;
}

.generate-section {
  background: #fff5f0;
  border: 1px solid #f0c8b8;
}

.toolbar button {
  font-size: 0.8rem;
  padding: 3px 6px;
  cursor: pointer;
  border: 1px solid #ccc;
  background: white;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.toolbar button:hover {
  background-color: #f5f5f5;
}

.button {
  background-color: #007bff !important;
  color: white !important;
  border: none !important;
  padding: 4px 8px !important;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.8rem !important;
}

.button:hover {
  background-color: #0056b3 !important;
}

.button:disabled {
  background-color: #6c757d !important;
  cursor: not-allowed;
}

button.active {
  background-color: #222;
  color: white;
}

.modal {
  position: fixed;
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 1.5rem;
  border-radius: 10px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  gap: 1rem;
  position: relative;
  overflow-y: auto;
}

.preview-container, 
.options-container {
  flex: 1;
}

.preview-container h3,
.options-container h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #333;
}

#final-sketch-preview {
  border: 1px solid #ddd;
  border-radius: 4px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9f9f9;
  margin-bottom: 1rem;
}

#final-sketch-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 4px;
}

/* AI Prompt Section Styling */
.prompt-section {
  margin-top: 1rem;
}

.prompt-section h4 {
  margin: 0 0 0.5rem 0;
  color: #333;
  font-size: 1rem;
}

#ai-prompt {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: vertical;
  background: #fafafa;
  box-sizing: border-box;
}

#ai-prompt:focus {
  outline: none;
  border-color: #007bff;
  background: white;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

#ai-prompt::placeholder {
  color: #666;
  font-style: italic;
}

.prompt-hint {
  margin: 0.5rem 0 0 0;
  font-size: 0.8rem;
  color: #666;
  font-style: italic;
}

.option-group {
  margin: 15px 0;
  padding: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #f9f9f9;
}

.option-group label {
  display: block;
  margin: 8px 0;
  cursor: pointer;
  font-size: 0.95rem;
}

.option-group label input[type="radio"],
.option-group label input[type="checkbox"] {
  margin-right: 8px;
}

.option-group:first-child {
  margin-top: 0;
}

#close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  font-weight: bold;
  line-height: 1;
}

#close-modal:hover {
  color: #333;
}

/* Enhanced responsive adjustments for full visibility */
@media (max-width: 1200px) {
  .toolbar {
    font-size: 0.8rem;
    padding: 6px;
    gap: 2px;
  }
  
  .toolbar-section {
    padding: 3px 6px;
    margin-right: 4px;
    gap: 3px;
  }
  
  .toolbar button {
    padding: 2px 4px;
    font-size: 0.75rem;
  }
  
  .button {
    padding: 3px 6px !important;
    font-size: 0.75rem !important;
  }
  
  .toolbar label {
    font-size: 0.7rem;
    margin-left: 3px;
  }
  
  .toolbar input[type="range"] {
    width: 50px;
    min-width: 35px;
  }
  
  .toolbar input[type="number"] {
    width: 40px;
    min-width: 30px;
  }
  
  .toolbar select {
    width: 60px;
    min-width: 45px;
    font-size: 0.7rem;
  }
}

@media (max-width: 900px) {
  .toolbar {
    font-size: 0.75rem;
    padding: 5px;
    gap: 1px;
    max-width: 99vw;
  }
  
  .toolbar-section {
    padding: 2px 4px;
    margin-right: 3px;
    gap: 2px;
  }
  
  .toolbar button {
    padding: 2px 3px;
    font-size: 0.7rem;
  }
  
  .button {
    padding: 2px 4px !important;
    font-size: 0.7rem !important;
  }
  
  .toolbar label {
    font-size: 0.65rem;
    margin-left: 2px;
  }
  
  .toolbar input[type="range"] {
    width: 40px;
    min-width: 30px;
  }
  
  .toolbar input[type="number"] {
    width: 35px;
    min-width: 25px;
  }
  
  .toolbar select {
    width: 50px;
    min-width: 40px;
    font-size: 0.65rem;
  }
}

@media (max-width: 768px) {
  .modal-content {
    flex-direction: column;
    width: 95%;
    max-height: 95vh;
    max-width: 800px;
  }
  
  .toolbar {
    font-size: 0.7rem;
    padding: 4px;
    max-width: 99.5vw;
    gap: 1px;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .toolbar-section {
    padding: 2px 3px;
    margin-right: 2px;
    margin-bottom: 2px;
    gap: 1px;
  }
  
  .toolbar button {
    padding: 1px 2px;
    font-size: 0.65rem;
  }
  
  .button {
    padding: 2px 3px !important;
    font-size: 0.65rem !important;
  }
  
  .toolbar label {
    font-size: 0.6rem;
    margin-left: 1px;
  }
  
  .toolbar input[type="range"] {
    width: 35px;
    min-width: 25px;
  }
  
  .toolbar input[type="number"] {
    width: 30px;
    min-width: 25px;
  }
  
  .toolbar select {
    width: 45px;
    min-width: 35px;
    font-size: 0.6rem;
  }
  
  /* Mobile responsive adjustments for prompt section */
  #ai-prompt {
    font-size: 0.85rem;
    min-height: 70px;
    padding: 10px;
  }
  
  .prompt-hint {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .toolbar {
    top: 5px;
    font-size: 0.65rem;
    padding: 3px;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .toolbar-section {
    padding: 1px 2px;
    margin-right: 1px;
    margin-bottom: 2px;
    gap: 1px;
  }
  
  .toolbar button {
    padding: 1px 2px;
    font-size: 0.6rem;
  }
  
  .button {
    padding: 1px 2px !important;
    font-size: 0.6rem !important;
  }
  
  .toolbar label {
    font-size: 0.55rem;
    margin-left: 1px;
  }
  
  .toolbar input[type="range"] {
    width: 30px;
    min-width: 20px;
  }
  
  .toolbar input[type="number"] {
    width: 25px;
    min-width: 20px;
  }
  
  .toolbar select {
    width: 40px;
    min-width: 30px;
    font-size: 0.55rem;
  }
  
  /* Small screen adjustments for prompt section */
  #ai-prompt {
    font-size: 0.8rem;
    min-height: 60px;
    padding: 8px;
  }
  
  .prompt-hint {
    font-size: 0.7rem;
  }
  
  .modal-content {
    padding: 1rem;
  }
}
.modal-image-container {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.image-box {
  flex: 1;
}

.preview-box {
  width: 100%;
  height: 300px;
  background: #f0f0f0;
  border: 2px dashed #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.loading-placeholder::after {
  content: "";
  width: 80%;
  height: 80%;
  border-radius: 15px;
  border: 5px solid #ddd;
  border-top: 5px solid #aaa;
  animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse {
  0% { box-shadow: 0 0 10px rgba(255, 0, 200, 0.2); }
  50% { box-shadow: 0 0 30px rgba(0, 200, 255, 0.6); }
  100% { box-shadow: 0 0 10px rgba(255, 0, 200, 0.2); }
}

.modal-options, .prompt-section {
  margin-top: 15px;
}

.option-group {
  margin-bottom: 10px;
}

.full-width {
  width: 100%;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}
/* Initially no aura */
#ai-image-preview {
  border: 2px dashed #ccc;
  transition: box-shadow 0.3s ease, border 0.3s ease;
}

/* Active pulsating aura during loading */
.pulsing {
  animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse {
  0% { box-shadow: 0 0 5px rgba(0, 200, 255, 0.2); }
  50% { box-shadow: 0 0 20px rgba(0, 200, 255, 0.7); }
  100% { box-shadow: 0 0 5px rgba(0, 200, 255, 0.2); }
}

/* Success and error glow */
.success {
  border: 3px solid limegreen;
  box-shadow: 0 0 10px limegreen;
}

.error {
  border: 3px solid crimson;
  box-shadow: 0 0 10px crimson;
}

.nav-tools {
  display: flex;
  gap: 0.5em;
  margin-bottom: 0.5em;
}
