/* Character Studio Grid Layout */

/* Container for the list of character cards */
.character-sets-grid {
  display: grid;
  grid-template-columns: 1fr; /* Stack vertically on mobile */
  gap: 20px;
  width: 100%; /* Ensure full width */
  grid-column: 1 / -1; /* Span all columns of parent grid */
}

/* Override parent .asset-grid when it contains character-sets-grid */
#avatarGallery.asset-grid {
  display: block; /* Disable grid, let child control layout */
}

@media (max-width: 430px) {
  .character-sets-grid {
    gap: 12px;
  }
  .character-card {
    padding: 8px;
    border-radius: 10px;
  }
  .character-header {
    margin-bottom: 6px;
    font-size: 0.82rem;
  }
  .character-moods-grid {
    gap: 4px;
  }
  .mini-mood-item img {
    border-radius: 5px;
  }
}

/* Community layout */
#communityEmojiGallery.asset-grid {
  display: block;
}

.community-active-sets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.community-active-tile.asset-item {
  position: relative;
  margin: 0;
  overflow: visible !important; /* allow balloon preview to escape tile bounds */
}

.community-active-tile .asset-footer {
  font-size: 11px;
  text-align: center;
  padding: 4px 3px;
}

.community-set-preview { display: none !important; }

#communityGlobalPreview {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1600;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
}
#communityGlobalPreview.show { display: flex; }
#communityGlobalPreview .community-global-preview-inner {
  width: min(92vw, 560px);
  max-height: 82vh;
  overflow: auto;
  background: rgba(12, 16, 28, 0.97);
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.55);
}
#communityGlobalPreview img, #communityGlobalPreview .preview-empty {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  object-fit: cover;
  background: rgba(255,255,255,0.10);
}

.community-emoji-section {
  margin-top: 8px;
}

.community-emoji-title {
  font-size: 12px;
  opacity: 0.85;
  margin: 0 0 8px 2px;
}

.community-emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* Keep Emojis tab and Community emoji sizes consistent */
#emojiSetGallery.asset-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
#emojiSetGallery.asset-grid .asset-footer,
.community-emoji-grid .asset-footer {
  font-size: 11px;
  padding: 6px 4px;
}

@media (min-width: 600px) {
  .character-sets-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Grid on desktop */
  }
}

/* Individual Character Card */
.character-card {
  background: var(--bg-container);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px;
  cursor: default; /* No pointer on container, only on items */
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px var(--shadow);
  width: 100%; /* Fill grid column on mobile */
  box-sizing: border-box;
  position: relative;
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

/* Active State Highlighting */
.character-card.active-character-card {
  border: 2px solid var(--border-primary);
  background-color: var(--bg-nav);
  box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.1);
}

/* Header inside card */
.character-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.active-badge {
  background: var(--border-primary);
  color: white;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

/* 8-Mood Mini Grid inside card */
.character-moods-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 columns x 2 rows */
  gap: 6px;
  width: 100%;
}

/* Mood cell backgrounds - vibrant colors for transparent PNGs */
.mini-mood-item {
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
}

/* Color each mood cell based on position */
.mini-mood-item:nth-child(1) { background: linear-gradient(135deg, #FFD93D, #FF6B6B); } /* Happy - warm yellow/orange */
.mini-mood-item:nth-child(2) { background: linear-gradient(135deg, #6BCB77, #4D96FF); } /* Sad - blue/teal */
.mini-mood-item:nth-child(3) { background: linear-gradient(135deg, #FF6B6B, #C34A36); } /* Angry - red */
.mini-mood-item:nth-child(4) { background: linear-gradient(135deg, #A66CFF, #9C89B8); } /* Thinking - purple */
.mini-mood-item:nth-child(5) { background: linear-gradient(135deg, #6BCB77, #54B435); } /* Tired - green */
.mini-mood-item:nth-child(6) { background: linear-gradient(135deg, #FFB830, #FF6B6B); } /* Excited - orange */
.mini-mood-item:nth-child(7) { background: linear-gradient(135deg, #FF9A9E, #FECFEF); } /* Surprised - pink */
.mini-mood-item:nth-child(8) { background: linear-gradient(135deg, #A8E6CF, #DCE2F1); } /* Cool - mint */

.mini-mood-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Wiggle Animation */
@keyframes wiggle {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-1deg); }
  75% { transform: rotate(1deg); }
  100% { transform: rotate(0deg); }
}

/* Edit Mode Styles */
.edit-mode .character-card,
.edit-mode .asset-item {
  animation: wiggle 0.3s infinite;
  cursor: pointer;
  position: relative;
}

/* Disable inner interaction in edit mode */
.edit-mode .character-card *,
.edit-mode .asset-item * {
  pointer-events: none;
}

/* Selection Indicator (Overlay) */
.selection-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.5);
  border: 3px solid #ff4444;
  border-radius: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.selection-overlay::after {
  content: '✓';
  color: white;
  background: #ff4444;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.character-card.selected .selection-overlay,
.asset-item.selected .selection-overlay {
  display: flex;
}

/* Delete FAB */
.delete-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 30px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  display: none; /* hidden by default */
  align-items: center;
  gap: 8px;
  transition: transform 0.2s;
  cursor: pointer;
}

.delete-fab:active {
  transform: scale(0.95);
}

.delete-fab.visible {
  display: flex;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.mini-mood-item {
  position: relative;
  cursor: pointer;
  transition: transform 0.15s;
}

.mini-mood-item:hover {
  transform: scale(1.05);
}

.mini-mood-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-card);
  border: 2px solid transparent;
}

/* Active Mood Highlight - Aggressive Style */
.mini-mood-item.active-mood-item {
  transform: scale(1.05);
  z-index: 5; /* Bring to front */
}

.mini-mood-item.active-mood-item img {
  border: 4px solid #4CAF50 !important; /* Thick green border */
  box-shadow: 0 0 12px rgba(76, 175, 80, 0.6) !important; /* Green glow */
}

/* Remove the old subtle checkmark if it was interfering */
.mood-check {
  display: flex; /* Keep it, but make sure it's on top */
  width: 24px;
  height: 24px;
  font-size: 14px;
  top: -8px; /* Pop out of the corner */
  right: -8px;
  border: 2px solid white; /* Contrast outline */
  z-index: 10;
}

/* Avatar mood quick-picker: keep full set on one row on mobile */
.avatar-mood-menu {
  display: none;
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 20;
  padding: 6px;
  border-radius: 10px;
  background: rgba(16, 18, 27, 0.95);
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.avatar-mood-menu.show { display: grid; }

.avatar-mood-btn {
  border: 0;
  padding: 0;
  background: transparent;
}

.avatar-mood-btn img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
}
