/* FruitMood - Main Styles */

body {
  margin: 0;
  font-family: sans-serif;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 150px 1fr 180px;
  grid-template-rows: auto 1fr 100px;
  grid-template-areas:
    "header header header"
    "fruits canvas parts"
    "garbage garbage garbage";
}

h1 {
  grid-area: header;
  text-align: center;
  margin: 10px;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

h1 .brand-name {
  color: #900406;
}

h1 .brand-name sup {
  font-size: 0.6em;
  color: #900406;
  opacity: 0.8;
}

h1 img {
  height: 1.5em;
  width: auto;
}

#fruits, #parts {
  background: #f8f8f8;
  padding: 10px;
  overflow-y: auto;
}

#fruits {
  grid-area: fruits;
}

#parts {
  grid-area: parts;
}

#canvas {
  grid-area: canvas;
  position: relative;
  background: #fff;
  border: 2px dashed #ccc;
  overflow: hidden;
}

#welcome-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  text-align: center;
  transition: opacity 0.5s ease-out;
}

#welcome-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.logo {
  font-size: 3rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.logo .brand-name {
  color: #900406;
}

.logo .brand-name sup {
  font-size: 0.6em;
  color: #900406;
  opacity: 0.8;
}

.logo img {
  height: 1.2em;
  width: auto;
  position: static !important;
}

.tagline {
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 30px;
  font-style: italic;
}

.instruction {
  display: flex;
  align-items: center;
  margin: 15px 0;
  font-size: 1.1rem;
  color: #333;
  max-width: 500px;
}

.instruction svg {
  margin-right: 15px;
  flex-shrink: 0;
}

.instruction.delete {
  color: #e74c3c;
}

#canvas img {
  position: absolute;
  touch-action: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
}

#garbage {
  grid-area: garbage;
  background: #ffdddd;
  text-align: center;
  line-height: 100px;
  font-weight: bold;
  border-top: 2px solid #ccc;
  transition: background-color 0.2s ease;
}

#garbage.drag-over {
  background: #cc4444;
  color: white;
}

.draggable-item {
  width: 50px;
  cursor: grab;
  margin: 5px;
}

.draggable {
  border: 2px solid transparent;
} 

.draggable:hover {
  border: 2px dashed grey;
}

.draggable.resizing {
  pointer-events: none;
  transition: none !important;
  will-change: transform, width, height;
}

.draggable.resizing:hover {
  border: 2px solid transparent;
}

/* Selection overlay for selected items */
.selection-overlay {
  position: absolute;
  border: 2px dashed #4a90e2;
  background: rgba(74, 144, 226, 0.1);
  pointer-events: none;
  z-index: 10000;
  display: none;
  box-sizing: border-box;
}

.selection-overlay.active {
  display: block;
}

/* Resize handles for selected items */
.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #4a90e2;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10001;
  display: none;
  pointer-events: auto;
}

.resize-handle.active {
  display: block;
}

.resize-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.resize-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.resize-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.resize-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.resize-handle.n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle.w { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }
.resize-handle.e { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }

/* Hide resize handles on mobile devices */
@media (max-width: 768px) {
  .resize-handle {
    display: none !important;
  }
}

#copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #4a90e2;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  z-index: 100;
  transition: background-color 0.2s ease;
}

#copy-button:hover {
  background: #357abd;
}

#copy-button:active {
  background: #2969a3;
}

#copy-button.copied {
  background: #27ae60;
}

#copy-sticker-button {
  position: absolute;
  top: 10px;
  right: 110px;
  background: #e74c3c;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  z-index: 100;
  transition: background-color 0.2s ease;
}

#copy-sticker-button:hover {
  background: #c0392b;
}

#copy-sticker-button:active {
  background: #a93226;
}

#copy-sticker-button.copied {
  background: #27ae60;
}

#restart-button {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #95a5a6;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  z-index: 100;
  transition: background-color 0.2s ease;
}

#restart-button:hover {
  background: #7f8c8d;
}

#restart-button:active {
  background: #34495e;
}

/* Hide copy buttons on iOS devices */
@supports (-webkit-touch-callout: none) {
  #copy-button,
  #copy-sticker-button,
  #share-button {
    display: none !important;
  }
}

/* Responsive styles */
@media (max-width: 768px) {
  .logo {
    font-size: 2rem;
    gap: 12px;
  }
  
  .logo img {
    height: 1.1em;
    position: static;
  }
  
  .tagline {
    font-size: 1rem;
  }
  
  .instruction {
    font-size: 1rem;
    margin: 10px 0;
  }
  
  .instruction svg {
    margin-right: 10px;
  }
  
  #restart-button {
    top: 5px;
    left: 5px;
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  
  #copy-button {
    top: 5px;
    right: 5px;
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  #copy-sticker-button {
    top: 5px;
    right: 80px;
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas:
      "header"
      "fruits"
      "canvas"
      "parts"
      "garbage";
  }
  
  h1 {
    font-size: 1.2rem;
    margin: 5px;
    gap: 8px;
  }
  
  h1 img {
    height: 1.3em;
  }
  
  #fruits, #parts {
    max-height: 120px;
    padding: 5px;
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
  }
  
  #fruits::-webkit-scrollbar, #parts::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
  }
  
  .draggable-item {
    height: 60px;
    width: auto;
    margin: 2px;
    flex-shrink: 0;
    object-fit: contain;
  }
  
  #garbage {
    line-height: 60px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1rem;
    gap: 6px;
  }
  
  h1 img {
    height: 1.2em;
  }
  
  #fruits, #parts {
    max-height: 100px;
    padding: 3px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  
  .draggable-item {
    height: 50px;
    width: auto;
    margin: 1px;
    flex-shrink: 0;
    object-fit: contain;
  }
  
  #garbage {
    line-height: 50px;
    font-size: 0.8rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  body {
    grid-template-columns: 120px 1fr 150px;
  }
  
  .draggable-item {
    width: 45px;
  }
}
