/* ==========================================================================
   AGENTOPS IDEATION STUDIO // VOICE PRD ENGINE
   Multi-File Document Attachment & 3-Phase Seeding Styles
   frontend/voice-discovery-attachments.css
   Binds strictly to :root tokens in frontend/voice-discovery.css
   ========================================================================== */

body {
  padding-bottom: max(240px, calc(var(--vd-hud-height, 220px) + 24px));
}

body.vd-auth-required {
  padding-bottom: 32px;
}

#vd-dropzone-overlay[hidden],
#vd-attachment-error-banner[hidden],
#vd-attachment-tray[hidden],
#vd-attach-count-badge[hidden] {
  display: none !important;
}

/* Composer Flex Shell & Textarea Anchor */
.hud-input-row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.hud-input-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: var(--vd-radius-md);
  transition: border-color var(--vd-transition-fast), box-shadow var(--vd-transition-fast);
}

#hud-reasoning-container {
  align-self: flex-start;
}

.hud-input-wrapper[data-drag-active="true"] {
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.28);
}

.vd-composer-textarea-wrap {
  position: relative;
  width: 100%;
}

.hud-hybrid-input,
#input-hybrid-note {
  padding: 10px 124px 10px 14px;
  min-height: 76px;
  box-sizing: border-box;
}

.hud-input-wrapper[data-has-attachments="true"] .hud-hybrid-input {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top-color: transparent;
}

/* Drag-and-Drop Overlay (pointer-events: none so drop bubbles & idle clicks never block) */
.vd-dropzone-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 2px dashed var(--vd-accent-cyan);
  border-radius: var(--vd-radius-md);
  background: rgba(11, 15, 23, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--vd-text-primary);
  font-family: var(--vd-font-sans);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

.vd-dropzone-overlay svg {
  color: var(--vd-accent-cyan);
  flex-shrink: 0;
}

/* Inline Validation & Recoverable Error Banner */
.vd-attachment-error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: var(--vd-radius-md);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--pg-border-error, rgba(248, 113, 113, 0.65));
  color: var(--pg-cancel-text, #FECACA);
  font-family: var(--vd-font-sans);
  font-size: 12px;
  line-height: 1.4;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.vd-attachment-error-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.vd-attachment-error-copy svg {
  color: var(--vd-accent-danger);
  flex-shrink: 0;
}

.vd-attachment-error-text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.vd-attachment-error-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 4px;
  border: none;
  border-radius: var(--vd-radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--vd-transition-fast), color var(--vd-transition-fast);
}

.vd-attachment-error-dismiss:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--vd-text-primary);
}

/* Staged Attachment Tray & Chips */
.vd-attachment-tray {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 6px;
  background: var(--vd-bg-surface);
  border: 1px solid var(--vd-border-default);
  border-bottom: 1px solid var(--vd-border-subtle);
  border-radius: var(--vd-radius-md) var(--vd-radius-md) 0 0;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  transition: border-color var(--vd-transition-fast);
}

.hud-input-wrapper[data-attachment-error="true"] .vd-attachment-tray {
  border-color: rgba(239, 68, 68, 0.45);
}

.vd-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 3px;
  max-height: 84px;
  overflow-y: auto;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.vd-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  background: var(--vd-surface-elevated);
  border: 1px solid var(--vd-border-subtle);
  border-radius: 6px;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  transition: border-color var(--vd-transition-fast);
}

.vd-attachment-chip:hover {
  border-color: var(--vd-border-hover);
}

.vd-chip-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--vd-radius-sm);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
  border: 1px solid var(--vd-border-subtle);
  background: rgba(15, 23, 42, 0.7);
  color: var(--pg-text-secondary, #CBD5E1);
}

.vd-attachment-chip[data-file-category="media"] .vd-chip-type-badge {
  background: rgba(6, 182, 212, 0.14);
  color: #38BDF8;
  border-color: rgba(6, 182, 212, 0.35);
}

.vd-attachment-chip[data-file-category="office"] .vd-chip-type-badge {
  background: rgba(59, 130, 246, 0.14);
  color: #93C5FD;
  border-color: rgba(59, 130, 246, 0.35);
}

.vd-attachment-chip[data-file-category="text"] .vd-chip-type-badge {
  background: rgba(16, 185, 129, 0.12);
  color: #6EE7B7;
  border-color: rgba(16, 185, 129, 0.3);
}

.vd-chip-name {
  font-family: var(--vd-font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--vd-text-primary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vd-chip-size {
  font-size: 11px;
  color: var(--pg-text-secondary, #CBD5E1);
  white-space: nowrap;
  flex-shrink: 0;
}

.vd-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 2px;
  border: none;
  border-radius: var(--vd-radius-sm);
  background: transparent;
  color: var(--vd-text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--vd-transition-fast), color var(--vd-transition-fast);
}

.vd-chip-remove:hover:not(:disabled) {
  color: var(--vd-accent-danger);
  background: rgba(239, 68, 68, 0.14);
}

.vd-chip-remove:disabled,
.vd-chip-remove[aria-disabled="true"],
.vd-chip-remove[data-processing-locked="true"] {
  opacity: var(--pg-lock-opacity, 0.48);
  cursor: not-allowed;
  pointer-events: none;
}

.vd-attachment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(31, 41, 55, 0.7);
  flex-wrap: wrap;
}

.vd-attachment-summary {
  font-size: 11px;
  color: var(--pg-text-secondary, #CBD5E1);
}

.vd-btn-clear-attachments {
  background: transparent;
  border: 1px solid var(--vd-border-subtle);
  color: var(--pg-text-secondary, #CBD5E1);
  border-radius: var(--vd-radius-sm);
  font-family: var(--vd-font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  min-width: 24px;
  min-height: 24px;
  cursor: pointer;
  transition: border-color var(--vd-transition-fast), color var(--vd-transition-fast), background-color var(--vd-transition-fast);
}

.vd-btn-clear-attachments:hover:not(:disabled) {
  color: var(--vd-accent-danger);
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.1);
}

.vd-btn-clear-attachments:disabled,
.vd-btn-clear-attachments[aria-disabled="true"] {
  opacity: var(--pg-lock-opacity, 0.48);
  cursor: not-allowed;
}

/* Attach Button & Count Pill */
.btn-hud-attach {
  position: relative;
  min-width: 32px;
  min-height: 32px;
}

.btn-hud-attach:hover:not(:disabled) {
  color: var(--vd-accent-primary);
  background-color: rgba(59, 130, 246, 0.12);
}

.btn-hud-attach:disabled,
.btn-hud-attach[aria-disabled="true"],
.btn-hud-submit:disabled,
.btn-hud-submit[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.vd-attach-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9999px;
  background-color: var(--vd-accent-primary);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.btn-hud-submit[data-has-attachments="true"]:not(:disabled) {
  box-shadow: var(--shadow-glow-blue);
}

/* Parallel 3-Phase Seeding Shimmer Feedback */
.vd-column-seeding {
  position: relative;
  overflow: hidden;
  border-color: var(--pg-border-active, rgba(6, 182, 212, 0.55)) !important;
  box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.35);
}

.vd-column-seeding .vd-column-header {
  border-bottom-color: var(--pg-border-active, rgba(6, 182, 212, 0.55));
}

.vd-column-seeding::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--vd-accent-cyan), transparent);
  animation: pg-shimmer 1.35s ease-in-out infinite;
  pointer-events: none;
  z-index: 6;
}

@media (prefers-reduced-motion: reduce) {
  .vd-column-seeding::before {
    animation: none !important;
    width: 100%;
    opacity: 0.72;
  }
}

/* Desktop & Tablet HUD Column Sizing */
@media (min-width: 1280px) {
  .hud-section-visualizer {
    flex: 0 1 300px;
    min-width: 220px;
    max-width: 300px;
  }

  .hud-voice-info {
    min-width: 0;
  }

  .hud-section-interaction {
    flex: 1 1 0%;
    min-width: 0;
    max-width: 1120px;
  }
}

@media (max-width: 1279px) {
  .hud-section-interaction {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* Mobile & Touch Targets (<= 768px / coarse pointer) */
@media (max-width: 768px), (pointer: coarse) {
  .hud-input-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .hud-input-wrapper {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .vd-attachment-tray,
  .vd-attachment-list,
  .vd-attachment-chip,
  .vd-attachment-error-banner {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .vd-attachment-list {
    max-height: 140px;
  }

  .vd-chip-name {
    max-width: 140px;
  }

  #btn-attach-files,
  #btn-mic-vad,
  #btn-submit-note,
  .vd-chip-remove,
  #btn-clear-attachments,
  #btn-dismiss-attachment-error {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
  }

  .hud-hybrid-input,
  #input-hybrid-note {
    padding-right: 154px;
    min-height: 112px;
  }
}

/* Mobile Layout Flow (<= 768px): Un-fix tall stacked HUD so it never overlaps header/cards */
@media (max-width: 768px) {
  body {
    padding-bottom: 24px;
  }

  .vd-main-container {
    padding-bottom: 24px;
  }

  .vd-voice-hud {
    position: static;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    box-sizing: border-box;
  }

  .hud-section-visualizer {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .hud-voice-info {
    min-width: 0;
  }

  #hud-reasoning-container {
    width: 100%;
    justify-content: flex-start;
  }
}
