/* ═══════════════════════════════════════════
   Meshy AI — 3D Generation Panel
   ═══════════════════════════════════════════ */

/* Floating toggle button */
.meshy-toggle {
  position: fixed;
  bottom: 2.5rem;
  right: 1.2rem;
  z-index: 800;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border, #2a2d35);
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.meshy-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.5);
}
.meshy-toggle.active {
  background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%);
  border-color: #a78bfa;
}

/* Side panel */
.meshy-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  max-width: 92vw;
  height: 100vh;
  z-index: 900;
  background: var(--bg1, #111318);
  border-left: 1px solid var(--border, #2a2d35);
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
}
.meshy-panel.open {
  right: 0;
}

.meshy-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border, #2a2d35);
  background: var(--bg2, #181b22);
  flex-shrink: 0;
}
.meshy-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #e0e0e0);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.meshy-panel-header h3 .meshy-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.meshy-close-btn {
  background: none;
  border: none;
  color: var(--text3, #666);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.meshy-close-btn:hover {
  background: var(--bg3, #252830);
  color: var(--text, #e0e0e0);
}

/* Tabs */
.meshy-tabs {
  display: flex;
  border-bottom: 1px solid var(--border, #2a2d35);
  background: var(--bg2, #181b22);
  flex-shrink: 0;
}
.meshy-tab {
  flex: 1;
  padding: 0.6rem 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text3, #666);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.meshy-tab:hover {
  color: var(--text2, #aaa);
}
.meshy-tab.active {
  color: #a78bfa;
  border-bottom-color: #a78bfa;
}

/* Panel body */
.meshy-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.meshy-body::-webkit-scrollbar {
  width: 6px;
}
.meshy-body::-webkit-scrollbar-track {
  background: transparent;
}
.meshy-body::-webkit-scrollbar-thumb {
  background: var(--border, #2a2d35);
  border-radius: 3px;
}

/* Tab content */
.meshy-tab-content {
  display: none;
}
.meshy-tab-content.active {
  display: block;
}

/* Form elements */
.meshy-form-group {
  margin-bottom: 1rem;
}
.meshy-form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text2, #aaa);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.meshy-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg3, #252830);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.meshy-input:focus {
  border-color: #7c3aed;
}
textarea.meshy-input {
  resize: vertical;
  min-height: 70px;
}

.meshy-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg3, #252830);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
}

/* Slider */
.meshy-slider-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.meshy-slider-group input[type="range"] {
  flex: 1;
  accent-color: #7c3aed;
}
.meshy-slider-group .meshy-slider-value {
  font-size: 0.75rem;
  color: #a78bfa;
  min-width: 40px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

/* Checkbox */
.meshy-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text2, #aaa);
  cursor: pointer;
}
.meshy-checkbox input[type="checkbox"] {
  accent-color: #7c3aed;
  cursor: pointer;
}

/* Generate button */
.meshy-generate-btn {
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 0.5rem;
}
.meshy-generate-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}
.meshy-generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Task status card */
.meshy-task-card {
  background: var(--bg2, #181b22);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
}
.meshy-task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.meshy-task-prompt {
  font-size: 0.82rem;
  color: var(--text, #e0e0e0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.meshy-task-status {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.meshy-task-status.pending { background: #44403c; color: #fbbf24; }
.meshy-task-status.in-progress { background: #1e3a5f; color: #60a5fa; }
.meshy-task-status.succeeded { background: #14532d; color: #4ade80; }
.meshy-task-status.failed { background: #450a0a; color: #f87171; }

/* Progress bar */
.meshy-progress {
  height: 4px;
  background: var(--bg3, #252830);
  border-radius: 2px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.meshy-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Thumbnail */
.meshy-task-thumbnail {
  width: 100%;
  height: 120px;
  background: var(--bg3, #252830);
  border-radius: 6px;
  margin: 0.5rem 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.meshy-task-thumbnail img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.meshy-task-thumbnail .placeholder {
  color: var(--text3, #666);
  font-size: 2rem;
}

/* Action buttons row */
.meshy-task-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.meshy-action-btn {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border, #2a2d35);
  border-radius: 6px;
  background: var(--bg3, #252830);
  color: var(--text2, #aaa);
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  text-align: center;
}
.meshy-action-btn:hover {
  background: var(--bg2, #181b22);
  color: var(--text, #e0e0e0);
  border-color: #7c3aed;
}
.meshy-action-btn.primary {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  border-color: transparent;
}
.meshy-action-btn.primary:hover {
  opacity: 0.85;
}

/* Image upload area */
.meshy-upload-area {
  border: 2px dashed var(--border, #2a2d35);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 1rem;
}
.meshy-upload-area:hover,
.meshy-upload-area.dragover {
  border-color: #7c3aed;
  background: rgba(124, 58, 237, 0.05);
}
.meshy-upload-area .upload-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.meshy-upload-area .upload-text {
  font-size: 0.82rem;
  color: var(--text2, #aaa);
}
.meshy-upload-area .upload-hint {
  font-size: 0.7rem;
  color: var(--text3, #666);
  margin-top: 0.3rem;
}

/* Preview of uploaded image */
.meshy-image-preview {
  position: relative;
  margin-bottom: 1rem;
}
.meshy-image-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border, #2a2d35);
}
.meshy-image-preview .remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Gallery grid */
.meshy-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.meshy-gallery-item {
  background: var(--bg2, #181b22);
  border: 1px solid var(--border, #2a2d35);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}
.meshy-gallery-item:hover {
  border-color: #7c3aed;
}
.meshy-gallery-item .thumb {
  width: 100%;
  height: 80px;
  background: var(--bg3, #252830);
  display: flex;
  align-items: center;
  justify-content: center;
}
.meshy-gallery-item .thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.meshy-gallery-item .info {
  padding: 0.35rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text2, #aaa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty state */
.meshy-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text3, #666);
}
.meshy-empty .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.meshy-empty .empty-text {
  font-size: 0.85rem;
}

/* Spinner */
.meshy-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: meshy-spin 0.6s linear infinite;
  margin-right: 0.4rem;
  vertical-align: middle;
}
@keyframes meshy-spin {
  to { transform: rotate(360deg); }
}

/* Not configured banner */
.meshy-not-configured {
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}
.meshy-not-configured .config-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.meshy-not-configured .config-text {
  font-size: 0.82rem;
  color: var(--text2, #aaa);
  line-height: 1.5;
}
.meshy-not-configured code {
  background: var(--bg3, #252830);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  color: #a78bfa;
}

/* Task time info */
.meshy-task-meta {
  font-size: 0.7rem;
  color: var(--text3, #666);
  margin-top: 0.3rem;
}

/* Options accordion */
.meshy-options-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text3, #666);
  cursor: pointer;
  margin-bottom: 0.5rem;
  user-select: none;
}
.meshy-options-toggle:hover {
  color: var(--text2, #aaa);
}
.meshy-options-toggle .arrow {
  transition: transform 0.2s;
  font-size: 0.6rem;
}
.meshy-options-toggle .arrow.open {
  transform: rotate(90deg);
}
.meshy-options-body {
  display: none;
  padding-left: 0.5rem;
  border-left: 2px solid var(--border, #2a2d35);
  margin-bottom: 0.8rem;
}
.meshy-options-body.open {
  display: block;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .meshy-panel {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
  }
  .meshy-toggle {
    bottom: 1.5rem;
    right: 0.8rem;
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }
}
