/* Use the imported Inter font */
body {
  font-family: "Inter", sans-serif;
}

/* Styles for interact.js draggable/resizable/rotatable containers */
.canvas-item {
  position: absolute; /* Crucial for positioning on canvas */
  box-sizing: border-box;
  touch-action: none; /* Recommended by interact.js */
  border: 2px solid transparent;
  transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  padding: 0; /* Important for outpainting */
}

.canvas-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

.canvas-item .shape-container {
  width: 100%;
  height: 100%;
}
.canvas-item .text-svg-container {
  width: 100%;
  height: 100%;
  overflow: visible; /* Hide anything that still might peek out */
}
.canvas-item .text-content {
  /* ... other styles ... */

  /* Change this: */
  /* white-space: pre-wrap; */
  /* To this: */
  white-space: pre; /* Preserves whitespace/newlines, prevents auto-wrapping */

  /* Remove these as they are not needed with white-space: pre */
  /* word-wrap: break-word; */
  /* overflow-wrap: anywhere; */

  /* Keep the rest */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 2px;
  box-sizing: border-box;
  line-height: 1.2;
  text-align: center;
  user-select: none;
  word-break: normal; /* Ensure default behavior */
}
.canvas-item.selected .text-content[contenteditable="true"] {
  /* Allow text selection only when editing */
  user-select: text;
}
/* Highlight for selected items */
.canvas-item.selected {
  border-color: #6366f1; /* indigo-500 */
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.6);
}

.rotate-handle {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background-color: #6366f1;
  border-radius: 50%;
  cursor: grab;
  display: none; /* Hidden by default */
}

.canvas-item.selected .rotate-handle {
  display: block; /* Show on selection */
}

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

/* ✅ ADDED: Styles for the new corner resize handles */
.resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background-color: #6366f1; /* Match selection color */
  border: 2px solid white;
  border-radius: 50%;
  z-index: 50; /* Ensure handles are on top */
  display: none; /* Hidden by default */
}

.canvas-item.selected .resize-handle {
  display: block; /* Show handles only on selected items */
}

.resize-handle.top-left {
  top: -7px;
  left: -7px;
  cursor: nwse-resize;
}
.resize-handle.top-right {
  top: -7px;
  right: -7px;
  cursor: nesw-resize;
}
.resize-handle.bottom-left {
  bottom: -7px;
  left: -7px;
  cursor: nesw-resize;
}
.resize-handle.bottom-right {
  bottom: -7px;
  right: -7px;
  cursor: nwse-resize;
}

/* Styles for the tool overlay and editing state */
.tool-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: none;
  z-index: 10;
}

.canvas-item.is-editing .tool-overlay {
  display: block;
  pointer-events: auto;
}

/* Specific cursors and styles for each tool mode */
.canvas-item.is-editing.magic-fill-mode .tool-overlay {
  cursor: crosshair;
}

.canvas-item.is-editing.magic-select-mode .tool-overlay {
  cursor: crosshair;
}

/* NEW: Styles for outpainting mode */
.canvas-item.is-editing.outpaint-mode {
  /* The original border is hidden to avoid visual clutter with the outpaint-frame */
  border-color: transparent;
  box-shadow: none;
}

/* ✨ NEW: Styles for the outpainting frame itself */
.outpaint-frame {
  position: absolute;
  box-sizing: border-box;
  border: 3px dashed #a78bfa; /* violet-400 */
  z-index: 99; /* Make sure it's on top */
  touch-action: none;
}
.outpaint-frame .resize-handle {
  display: block; /* Handles are always visible for the frame */
}

/* NEW: Style for the selection box drawn by the user */
.selection-box {
  position: absolute;
  border: 2px dashed #f59e0b; /* amber-500 */
  background-color: rgba(245, 158, 11, 0.2);
  pointer-events: none;
}
#export-frame {
  position: absolute;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  box-sizing: border-box;
  pointer-events: none; /* The frame should not be interactive */
  z-index: 5; /* Sit below items but above the background */
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}
.is-exporting.selected {
   border-color: transparent !important;
   box-shadow: none !important;
  }
  
  .is-exporting .rotate-handle,
  .is-exporting .resize-handle {
   display: none !important;
  }
  #export-frame.hide-for-export {
      border: none !important;
      background-color: transparent !important;
      box-shadow: none !important; /* <-- ADD THIS LINE */
    }
/* Checkerboard background for the canvas area */
#canvas-area {
  background-image: linear-gradient(45deg, #2d3748 25%, transparent 25%),
    linear-gradient(-45deg, #2d3748 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2d3748 75%),
    linear-gradient(-45deg, transparent 75%, #2d3748 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
  background-color: #1a202c; /* gray-900 */
}

.loading-image-wrapper {
  position: relative;
  display: inline-block; /* Or block, depending on layout */
  overflow: hidden; /* This is crucial for the sweep effect */
  border-radius: 0.5rem; /* Match image rounding */
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  mask-image: radial-gradient(white, black); /* Softens edges */
  -webkit-mask-image: -webkit-radial-gradient(
    white,
    black
  ); /* Softens edges on Safari */
}

.loading-image-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  left: -75%; /* Start off-screen */
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
  animation: light-sweep 1.8s ease-in-out infinite;
}

@keyframes light-sweep {
  0% {
    left: -75%;
  }
  100% {
    left: 125%;
  }
}
.ai-genesis-animation {
  width: 100%;
  height: 100%;
  border-radius: 0.5rem; /* rounded-lg */
  background: linear-gradient(-45deg, #4338ca, #6d28d9, #0891b2, #1e3a8a);
  background-size: 400% 400%;
  animation: gradient-flow 10s ease infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

@keyframes gradient-flow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.ai-genesis-animation .fa-wand-magic-sparkles {
    font-size: 2.25rem; /* text-4xl */
    margin-bottom: 1rem;
    opacity: 0.8;
    animation: pulse-and-fade 2s ease-in-out infinite;
}

@keyframes pulse-and-fade {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}
.feedback-actions {
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

.feedback-btn {
  background: transparent;
  border: 1px solid #4a5568; /* gray-600 */
  color: #a0aec0; /* gray-400 */
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: all 0.2s ease;
  cursor: pointer;
}
.feedback-btn:hover {
  background-color: #4a5568; /* gray-600 */
  color: white;
  transform: scale(1.1);
}
.feedback-btn:active {
  transform: scale(0.95);
}

/* --- Custom Model Selector --- */
.model-selector-wrapper {
  position: relative;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #4a5568; /* gray-700 */
}
.model-selector-label {
  display: block;
  font-size: 0.75rem; /* text-xs */
  font-weight: 500; /* font-medium */
  color: #9ca3af; /* text-gray-400 */
  margin-bottom: 0.25rem;
}
.model-selector-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background-color: #2d3748; /* gray-800 */
  border: 1px solid #4a5568; /* gray-600 */
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  text-align: left;
  transition: border-color 0.2s;
}
.model-selector-button:hover {
  border-color: #6366f1; /* indigo-500 */
}
.model-selector-button .model-selector-display {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-selector-button .fa-chevron-down {
  transition: transform 0.2s ease-in-out;
}
.model-selector-panel {
  display: none;
  position: absolute;
  bottom: 100%;
  margin-bottom: 0.25rem; /* A smaller gap so it doesn't touch */
  width: 100%;
  background-color: #1a202c; /* gray-900 */
  border: 1px solid #4a5568; /* gray-600 */
  border-radius: 0.5rem;
  z-index: 50;
  /* max-height and overflow-y are removed to prevent clipping the submenu */
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
.model-selector-panel.open {
  display: block;
}
.model-selector-panel.open + .model-selector-button .fa-chevron-down {
  transform: rotate(180deg);
}
.model-selector-panel ul {
  list-style: none;
  padding: 0.5rem;
  margin: 0;
}
.model-selector-panel li {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  font-size: 0.875rem;
  white-space: nowrap;
}
.model-selector-panel li:hover {
  background-color: #2d3748; /* gray-800 */
}
.model-selector-panel li.has-submenu {
  position: relative;
}
.model-selector-panel li.has-submenu::after {
  content: '';
  position: absolute;
  top: -0.5rem;  /* Align with the parent UL's padding */
  bottom: -0.5rem; /* Align with the parent UL's padding */
  right: 100%;    /* Position it to the left, in the gap */
  width: 0.75rem; /* Make it wide enough to cover the gap */
}
.model-selector-panel li.has-submenu .fa-chevron-right {
  color: #718096; /* gray-500 */
}
.model-selector-panel .submenu {
  display: none;
  position: absolute;
  right: 100%; /* This correctly positions it to the left */
  margin-right: 0.25rem; /* Adds a small visual gap */
  top: -0.5rem; /* Aligns with parent li padding */
  min-width: 200px;
  background-color: #111827; /* gray-950 */
  border: 1px solid #4a5568;
  border-radius: 0.5rem;
  padding: 0.5rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  z-index: 51; /* Ensures submenu appears above the main panel */
}
.model-selector-panel li.has-submenu:hover > .submenu {
    display: block;
  }
  
  /* --- Layout Image Picker --- */
  #layout-session-gallery .session-image {
    position: relative;
    cursor: pointer;
    border-radius: 0.375rem; /* rounded-md */
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s;
  }
  #layout-session-gallery .session-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 1 / 1;
  }
  #layout-session-gallery .session-image.selected {
    border-color: #6366f1; /* indigo-500 */
  }
  #layout-session-gallery .session-image .selected-check {
    display: none;
    position: absolute;
    top: 4px;
    right: 4px;
    width: 1.25rem; /* w-5 */
    height: 1.25rem; /* h-5 */
    background-color: #6366f1; /* bg-indigo-500 */
    color: white;
    border-radius: 50%;
    font-size: 0.75rem; /* text-xs */
    line-height: 1.25rem; /* for vertical center */
    text-align: center;
  }
  #layout-session-gallery .session-image.selected .selected-check {
    display: block;
  }
  #layout-session-gallery .no-images {
    color: #718096; /* gray-500 */
    font-size: 0.875rem; /* text-sm */
    text-align: center;
    grid-column: 1 / -1; /* Span all columns */
    padding: 1rem 0;
  }
  .selected-image-pill {
    display: flex;
    align-items: center;
    background-color: #2d3748; /* gray-800 */
    border-radius: 9999px; /* rounded-full */
    overflow: hidden;
    font-size: 0.75rem; /* text-xs */
  }
  .selected-image-pill img {
    width: 1.5rem; /* w-6 */
    height: 1.5rem; /* h-6 */
    object-fit: cover;
    margin-right: 0.5rem; /* mr-2 */
  }
  .selected-image-pill button {
    background: transparent;
    color: #9ca3af; /* gray-400 */
    padding: 0 0.5rem; /* px-2 */
  }
  .selected-image-pill button:hover {
    color: white;
  }


/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #2d3748;
}
::-webkit-scrollbar-thumb {
  background: #4a5568;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #718096;
}