/**
 * Feature Menu Styles
 *
 * Styles for the "+" button menu and active feature badges
 */

/* Feature menu button */
.feature-menu-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.feature-menu-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

.feature-menu-btn svg {
  stroke: currentColor;
}

.feature-menu-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.feature-menu-btn.active svg {
  transform: rotate(45deg);
}

/* Feature menu popup */
.feature-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding: 8px;
  min-width: 220px;
  display: none;
  z-index: 100;
  animation: featureMenuSlideIn 0.2s ease-out;
}

.feature-menu.active {
  display: block;
}

@keyframes featureMenuSlideIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}

.feature-menu-item:hover {
  background: var(--bg-tertiary);
}

.feature-menu-item:active {
  transform: scale(0.98);
}

.feature-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.feature-label {
  flex: 1;
  font-weight: 500;
}

/* Feature badges container */
.feature-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  min-height: 0;
}

.feature-badges:empty {
  display: none;
}

/* Individual feature badge */
.feature-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-primary);
  animation: badgeFadeIn 0.3s ease-out;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.feature-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.feature-badge:active {
  transform: translateY(0);
}

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

.feature-badge-icon {
  font-size: 16px;
  line-height: 1;
}

.feature-badge-label {
  font-weight: 500;
}

.feature-badge-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  font-size: 16px;
  line-height: 1;
  margin-left: 4px;
}

.feature-badge-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Special badge colors */
.feature-badge[data-feature="search_web"] {
  background: rgba(64, 185, 197, 0.15);
  border-color: rgba(64, 185, 197, 0.3);
  color: var(--accent);
}

.feature-badge[data-feature="auto_speak"] {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
  color: #8b5cf6;
}

.feature-badge[data-feature="upload_file"] {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .feature-menu {
    min-width: 200px;
  }

  .feature-menu-item {
    padding: 10px;
    font-size: 13px;
  }

  .feature-badges {
    margin-top: 8px;
    gap: 6px;
  }

  .feature-badge {
    font-size: 12px;
    padding: 5px 10px;
  }
}

/* Position feature menu relative to input container */
.input-container {
  position: relative;
}

/* Model selector badge style (when Search The Web is active) */
#modelSelectorWrapper {
  display: none; /* Hidden by default */
}

#modelSelectorWrapper.active {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(64, 185, 197, 0.15);
  border: 1px solid rgba(64, 185, 197, 0.3);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  animation: badgeFadeIn 0.3s ease-out;
}

#modelSelectorWrapper.active .custom-select {
  background: transparent;
  border: none;
  min-width: 150px;
  position: relative;
}

#modelSelectorWrapper.active .custom-select-trigger {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

#modelSelectorWrapper.active .custom-select-trigger:hover {
  color: var(--text-primary);
}

#modelSelectorWrapper.active .select-arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

#modelSelectorWrapper.active .custom-select.open .select-arrow {
  transform: rotate(180deg);
}

/* Dropdown options for model selector badge */
#modelSelectorWrapper.active .custom-select-options {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding: 4px;
  display: none;
  z-index: 200;
  max-height: 300px;
  overflow-y: auto;
}

#modelSelectorWrapper.active .custom-select.open .custom-select-options {
  display: block;
}

/* Supporting mode - direct click on badge opens menu */
#modelSelectorWrapper.supporting-mode .custom-select-options {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding: 4px;
  z-index: 200;
  max-height: 300px;
  overflow-y: auto;
}

#modelSelectorWrapper.active .custom-select-option {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text-primary);
  border-radius: 6px;
  transition: all 0.2s;
  font-size: 14px;
}

#modelSelectorWrapper.active .custom-select-option:hover {
  background: var(--bg-tertiary);
}

#modelSelectorWrapper.active .custom-select-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Close button for model selector */
.model-selector-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  font-size: 16px;
  line-height: 1;
  margin-left: 4px;
}

.model-selector-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Model Onboarding Modal - New Nickname-First Structure */
.model-header {
  width: 100%;
}

.model-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.model-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.model-titles {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.model-nickname {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.model-canonical-name {
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--text-secondary, #9aa3af);
  line-height: 1.3;
}

.model-section {
  margin-top: 1rem;
}

.model-section:first-child {
  margin-top: 0;
}

.model-section > h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary, #9aa3af);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.model-instructions-text,
.model-tech-text {
  margin: 0;
  line-height: 1.55;
  color: var(--text-primary);
}

.hidden {
  display: none !important;
}

/* Upload Modal Styles */
:root {
  --upload-modal-z: 100000; /* Aggressive z-index - can be tuned later */
}

#upload-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: var(--upload-modal-z) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s ease-out;
  pointer-events: auto;
  visibility: visible !important;
  opacity: 1 !important;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#upload-modal .upload-modal-overlay {
  position: absolute !important;
  inset: 0;
  background: rgba(0, 0, 0, 0.75) !important;
  backdrop-filter: blur(3px);
  z-index: 1 !important;
  pointer-events: auto !important;
}

#upload-modal .upload-modal-content {
  position: relative !important;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex !important;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease-out;
  z-index: 2 !important;
  overflow: auto;
  pointer-events: auto !important;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.upload-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.upload-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.upload-modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.upload-modal-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.upload-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-secondary);
  transition: all 0.3s;
  cursor: pointer;
}

.upload-drop-zone:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.upload-drop-zone-active {
  border-color: var(--accent);
  background: rgba(64, 185, 197, 0.1);
  border-style: solid;
}

.upload-drop-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.upload-drop-text {
  font-size: 16px;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.upload-browse-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}

.upload-browse-link:hover {
  color: var(--text-primary);
}

.upload-drop-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.upload-file-list {
  margin-top: 16px;
  display: none;
}

.upload-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.upload-file-item:hover {
  background: var(--bg-secondary);
}

.upload-file-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.upload-file-info {
  flex: 1;
  min-width: 0;
}

.upload-file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-size {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.upload-file-remove {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  flex-shrink: 0;
}

.upload-file-remove:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.upload-inquiry-section {
  margin-top: 24px;
}

.upload-inquiry-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upload-inquiry-input {
  width: 100%;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  transition: all 0.2s;
}

.upload-inquiry-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-primary);
}

.upload-inquiry-input::placeholder {
  color: var(--text-secondary);
}

.upload-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
}

.upload-modal-button {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  min-width: 100px;
}

.upload-modal-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.upload-modal-button:not(:disabled):active {
  transform: scale(0.98);
}

.upload-modal-button-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.upload-modal-button-secondary:not(:disabled):hover {
  background: var(--bg-secondary);
}

.upload-modal-button-primary {
  background: var(--accent);
  color: white;
}

.upload-modal-button-primary:not(:disabled):hover {
  background: #4fa4ae;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(64, 185, 197, 0.3);
}

/* Mobile responsive */
@media (max-width: 640px) {
  .upload-modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .upload-modal-header,
  .upload-modal-body,
  .upload-modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .upload-drop-zone {
    padding: 32px 16px;
  }

  .upload-drop-icon {
    font-size: 36px;
  }

  .upload-modal-button {
    min-width: 80px;
    padding: 8px 16px;
  }
}

/* Extra small mobile (phones in portrait) */
@media (max-width: 480px) {
  .upload-modal-content {
    padding: 16px;
    border-radius: 12px;
    width: calc(100% - 16px);
  }

  .upload-modal-header {
    padding: 16px 16px 12px;
  }

  .upload-modal-body {
    padding: 16px;
  }
}
