/* Modern Grid Interface */
.im-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  font-family: 'Inter', sans-serif;
}

/* Control Panel */
.im-toolbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  align-items: end;
  position: relative;
  overflow: hidden;
}

.im-toolbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2, #ff6b6b, #ffd93d);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
}

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

.im-toolbar label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  color: #2d3748;
  font-size: 0.9rem;
  gap: 0.5rem;
}

.im-toolbar input,
.im-toolbar select {
  padding: 0.875rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: white;
}

.im-toolbar input:focus,
.im-toolbar select:focus {
  outline: none;
  border-color: #667eea;
  transform: translateY(-2px);
}

.im-toolbar button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 16px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.im-toolbar button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.im-toolbar button:hover::before {
  left: 100%;
}

.im-toolbar button:hover {
  transform: translateY(-4px);
}

.im-toolbar button:active {
  transform: translateY(-2px);
}

#im-buy {
  background: linear-gradient(135deg, #ff6b6b 0%, #ffd93d 100%);
}

#im-buy:hover {
}

/* Price Display */
.im-toolbar strong {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 800;
  white-space: nowrap;
}

/* Canvas Container */
.im-canvas-wrap {
  position: relative;
  border: 3px solid rgba(255, 255, 255, 0.3);

  overflow: hidden;
  background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);

  aspect-ratio: 1/1;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.im-canvas {
  width: 100%;
  height: 100%;
  touch-action: pan-x pan-y pinch-zoom;
  cursor: grab;
  transition: cursor 0.2s;
}

.im-canvas:active {
  cursor: grabbing;
}

/* Overlays for blocks */
#im-overlays {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

/* Individual blocks */
.im-block {
  position: absolute;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.im-block img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.im-block:hover {
  transform: scale(1.08) translateZ(0);
  z-index: 10;
  border-color: rgba(255, 255, 255, 0.8);
}

.im-block:hover img {
  transform: scale(1.05);
}

/* Tooltip styling */
.im-block[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 1000;
  animation: tooltipFadeIn 0.2s ease-out;
}

.im-block[title]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  animation: tooltipFadeIn 0.2s ease-out;
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(5px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Legend */
.im-legend {
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Status indicators */
.im-block.status-paid {
  border-color: rgba(34, 197, 94, 0.6);
}

.im-block.status-pending {
  border-color: rgba(251, 191, 36, 0.6);
  animation: pendingPulse 2s ease-in-out infinite;
}

@keyframes pendingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Mobile Responsive Design */
@media (max-width: 1024px) {
  .im-wrap {
    padding: 1.5rem;
  }
  
  .im-toolbar {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    padding: 1.5rem;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .im-wrap {
    padding: 1rem;
  }
  
  .im-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-radius: 20px 20px 0 0;
    padding: 1rem;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    z-index: 100;
    max-height: 60vh;
    overflow-y: auto;
  }
  
  .im-canvas-wrap {
    margin-bottom: 25rem;
    border-radius: 16px;
  }
  
  .im-legend {
    margin-bottom: 1rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .im-toolbar {
    padding: 0.75rem;
  }
  
  .im-toolbar input,
  .im-toolbar select,
  .im-toolbar button {
    font-size: 0.9rem;
  }
  
  .im-toolbar button {
    padding: 0.875rem 1.5rem;
  }
}

/* Loading states */
.im-loading {
  position: relative;
  overflow: hidden;
}

.im-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: loading 2s infinite;
}

@keyframes loading {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus indicators for keyboard navigation */
.im-toolbar input:focus,
.im-toolbar select:focus,
.im-toolbar button:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .im-toolbar {
    background: white;
    border: 2px solid black;
  }
  
  .im-block {
    border-color: black;
  }
}