/* Folder Modal Styles */
.folder-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100020;
  opacity: 0;
  visibility: hidden;
  transition: all 240ms cubic-bezier(0.2, 0, 0, 1);
}

.folder-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.folder-modal {
  background: white;
  border-radius: 20px;
  max-width: 40rem;
  max-height: 70vh;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 20px;
  animation: modalSlideUp 0.3s ease;
}

.folder-success-modal {
  background: white;
  border-radius: 20px;
  max-width: 40rem;
  padding: 32px 24px;
  text-align: center;
  animation: modalSlideUp 0.3s ease;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
}

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

.folder-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.folder-modal-header h2 {
  font-size: var(--gf-text-section);
  font-weight: var(--gf-weight-bold);
  color: #101828;
  margin: 0 auto;
}

.folder-modal-close {
  border: 0;
  background: transparent;
  color: #667085;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.folder-modal-header .highlight {
  color: #2966f4;
}

.folder-modal-description {
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-regular);
  color: #344054;
  line-height: var(--gf-leading-body);
  margin-bottom: 10px;
  text-align: center;
}

.folder-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-label-hint {
  color: #98a2b3;
  font-size: var(--gf-text-caption);
  font-weight: var(--gf-weight-medium);
}

.folder-instructions-input {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  border: 0;
  outline: 0;
  background: #f2f4f7;
  border-radius: 16px;
  padding: 12px 16px;
  color: #344054;
  font: inherit;
}

.folder-field-error {
  min-height: 16px;
  color: #b42318;
  font-size: var(--gf-text-caption);
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-label {
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-semibold);
  color: #344054;
}

.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 30px;
  background: #f2f4f7;
  cursor: pointer;
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-semibold);
  color: #1b1d22;
}

.category-btn.active {
  border: 1px solid var(--primary-color, var(--gf-blue));
  color: var(--primary-color, var(--gf-blue));
}

.interests-search,
.folder-name-input {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f2f4f7;
  border-radius: 30px;
  padding: 10px 16px;
}

.interests-search svg {
  flex-shrink: 0;
}

.interests-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: var(--gf-text-body);
  color: #344054;
}

.interests-search input::placeholder {
  color: #98a2b3;
}

.interests-suggestions {
  margin-top: 12px;
}

.suggestions-container {
  background: #f9fafb;
  border-radius: 12px;
  padding: 16px;
}

.suggestions-label {
  font-size: var(--gf-text-body);
  color: #667085;
  font-weight: var(--gf-weight-semibold);
  margin-bottom: 12px;
  display: block;
}

.suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: white;
  border: 1px solid #e4e7ec;
  border-radius: 20px;
  font-size: var(--gf-text-body);
  color: #344054;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.2, 0, 0, 1);
  font-weight: var(--gf-weight-medium);
}

.suggestion-tag:hover {
  background: #eef4ff;
  border-color: #2966f4;
  color: #2054cc;
}

.suggestion-tag svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.selected-interests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-interest {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  background: #101828;
  color: white;
  border-radius: 20px;
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-medium);
}

.remove-interest {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 160ms cubic-bezier(0.2, 0, 0, 1);
}

.remove-interest:hover {
  background: rgba(255, 255, 255, 0.2);
}

.folder-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

.cancel-folder-btn {
  padding: 6px 24px;
  border: 1px solid #d0d5dd;
  border-radius: 30px;
  background: white;
  color: #344054;
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-semibold);
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.2, 0, 0, 1);
}

.cancel-folder-btn:hover {
  background: #f9fafb;
  border-color: #98a2b3;
}

.create-folder-btn,
.start-new-chat {
  padding: 6px 24px;
  border: none;
  border-radius: 30px;
  background: #2966f4;
  color: white;
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-medium);
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.2, 0, 0, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.create-folder-btn:hover {
  background: #2054cc;
  transform: translateY(-1px);
}

.create-folder-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

.success-content {
  position: relative;
  z-index: 1;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.success-icon {
  /* width: 80px;
  height: 80px; */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  animation: successBounce 0.6s ease;
}

@keyframes successBounce {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.success-content h2 {
  font-size: var(--gf-text-section);
  font-weight: var(--gf-weight-bold);
  color: #101828;
  margin: 0 0 16px;
}

.success-content p {
  font-size: var(--gf-text-body);
  color: #475467;
  line-height: var(--gf-leading-body);
  margin: 0 0 32px;
  text-align: center;
}

/* Folder List Styles */
.folder-list-container {
  margin: 5px 0;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.2, 0, 0, 1);
  margin-bottom: 4px;
}

.folder-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.folder-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-name {
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-medium);
  color: #344054;
}

.folder-category {
  font-size: var(--gf-text-caption);
  color: #667085;
}

.folder-expand {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 160ms cubic-bezier(0.2, 0, 0, 1);
}

.folder-item.expanded .folder-expand {
  transform: rotate(90deg);
}

.folder-contents {
  margin-left: 32px;
  padding: 8px 0;
  border-left: 2px solid #f3f4f6;
  padding-left: 16px;
  display: none;
}

.folder-item.expanded + .folder-contents {
  display: block;
}

.folder-content-item {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: var(--gf-text-caption);
  color: #667085;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.2, 0, 0, 1);
  margin-bottom: 4px;
}

.folder-content-item:hover {
  background: #f9fafb;
  color: #344054;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .folder-modal {
    width: 95%;
    padding: 20px;
    max-height: 95vh;
  }

  .folder-success-modal {
    width: 95%;
    padding: 24px 20px;
  }

  .category-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
  }

  .category-btn {
    padding: 12px 8px;
    font-size: var(--gf-text-caption);
  }

  .category-icon {
    font-size: 20px;
  }

  .folder-modal-actions {
    flex-direction: column;
  }

  .btn-secondary,
  .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

/* Success Confetti Canvas */
.success-confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  border-radius: 20px;
}

.success-content {
  position: relative;
  z-index: 2;
}

.start-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  background: #2966f4;
  color: white;
  font-size: var(--gf-text-body);
  font-weight: var(--gf-weight-medium);
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.2, 0, 0, 1);
}

.start-new-chat:hover {
  background: #2054cc;
  transform: translateY(-1px);
}

.start-new-chat svg {
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   Create-folder modal — design pass
   Banner + folder badge, name-first form, 4-up category grid, inline interest
   chips and a footer action bar. Overrides the earlier block above; the success
   modal (.folder-success-modal) is untouched.
   --------------------------------------------------------------------------- */

.folder-modal-overlay .folder-modal-v2 {
  --fm-ink: #111827;
  --fm-body: #4b5563;
  --fm-muted: #6b7280;
  --fm-line: #e9edf5;
  --fm-field: #f3f4f7;
  --fm-accent: #3366e8;
  --fm-accent-light: color-mix(in srgb, var(--fm-accent) 68%, #ffffff);
  --fm-grad: linear-gradient(135deg, var(--fm-accent-light) 0%, var(--fm-accent) 100%);

  box-sizing: border-box;
  width: 720px;
  max-width: calc(100vw - 32px);
  max-height: min(92vh, 900px);
  padding: 0;
  overflow-y: auto;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(20, 35, 80, 0.28);
  font-family: var(--gf-font);
  color: var(--fm-ink);
}

.folder-modal-overlay .folder-modal-v2::-webkit-scrollbar {
  width: 0;
}

/* banner -------------------------------------------------------------- */

.folder-modal-overlay .folder-modal-banner {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  box-sizing: border-box;
  padding: 24px 28px 22px;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(135deg, #cfe0ff 0%, #e8effd 45%, #f6f8fe 100%);
}

/* The badge is the folder from the design reference: a tab peeking out behind a
   body, with the category emoji sitting on the body itself. */
.folder-modal-overlay .folder-badge {
  position: relative;
  flex: none;
  width: 84px;
  height: 72px;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.folder-modal-overlay .folder-badge::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 38px;
  height: 14px;
  border-radius: 8px 8px 0 0;
  background: #3e6bef;
}

.folder-modal-overlay .folder-badge::after {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 84px;
  height: 62px;
  border-radius: 6px 14px 14px 14px;
  background: linear-gradient(135deg, #5b8cff, #2f5bea);
  box-shadow: 0 14px 26px rgba(47, 91, 234, 0.38);
}

.folder-modal-overlay .folder-badge-icon {
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  bottom: 0;
  /* above the body pseudo-element, which is painted after the element's content */
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  background: none;
  font-size: 30px;
  line-height: 1;
}

.folder-modal-overlay .folder-banner-text {
  flex: 1;
  min-width: 0;
}

.folder-modal-overlay .folder-banner-text h2 {
  margin: 2px 0 6px;
  font-size: var(--gf-text-heading);
  line-height: 32px;
  font-weight: var(--gf-weight-bold);
  letter-spacing: -0.01em;
  color: var(--fm-ink);
}

.folder-modal-overlay .folder-banner-text h2 .highlight {
  color: var(--fm-accent);
}

.folder-modal-overlay .folder-banner-text p {
  margin: 0;
  max-width: 430px;
  font-size: var(--gf-text-body, 16px);
  line-height: 24px;
  color: var(--fm-body);
}

.folder-modal-overlay .folder-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(40, 60, 120, 0.14);
  cursor: pointer;
}

/* form ---------------------------------------------------------------- */

.folder-modal-overlay .folder-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-sizing: border-box;
  padding: 22px 28px 26px;
}

.folder-modal-overlay .form-section {
  gap: 10px;
}

.folder-modal-overlay .form-label {
  font-size: var(--gf-text-body, 16px);
  font-weight: var(--gf-weight-semibold);
  color: var(--fm-ink);
}

.folder-modal-overlay .form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.folder-modal-overlay .form-label-hint {
  margin-left: 4px;
  font-size: var(--gf-text-body, 16px);
  font-weight: var(--gf-weight-normal);
  color: var(--fm-muted);
}

.folder-modal-overlay .interests-count {
  font-size: var(--gf-text-body, 16px);
  color: var(--fm-muted);
}

.folder-modal-overlay .folder-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  height: 48px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--fm-field);
}

.folder-modal-overlay .folder-field:focus-within {
  border-color: var(--fm-accent);
  background: #ffffff;
}

.folder-modal-overlay .folder-field-icon {
  flex: none;
  font-size: var(--gf-text-header);
  line-height: 1;
}

.folder-modal-overlay .folder-field .folder-name-input,
.folder-modal-overlay .folder-name-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: var(--gf-text-body, 16px);
  color: var(--fm-ink);
}

.folder-modal-overlay .folder-name-input::placeholder {
  color: var(--fm-muted);
}

/* categories ---------------------------------------------------------- */

.folder-modal-overlay .category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.folder-modal-overlay .category-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  box-sizing: border-box;
  min-width: 0;
  height: 42px;
  padding: 0 6px 0 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--fm-field);
  font-family: inherit;
  font-size: var(--gf-text-body, 16px);
  font-weight: var(--gf-weight-medium);
  letter-spacing: -0.01em;
  color: var(--fm-ink);
  cursor: pointer;
}

.folder-modal-overlay .category-btn > span:last-child {
  min-width: 0;
  overflow: visible;
  white-space: nowrap;
}

.folder-modal-overlay .category-btn .category-icon {
  flex: none;
  width: 16px;
  font-size: var(--gf-text-body);
  line-height: 1;
  text-align: center;
}

.folder-modal-overlay .category-btn:hover {
  background: #eaecf2;
}

.folder-modal-overlay .category-btn.active {
  border-color: var(--fm-accent);
  background: #ffffff;
  color: var(--fm-accent);
  font-weight: var(--gf-weight-semibold);
}

/* interests ----------------------------------------------------------- */

.folder-modal-overlay .interests-search {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  box-sizing: border-box;
  min-height: 48px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--fm-field);
}

.folder-modal-overlay .interests-search:focus-within {
  border-color: var(--fm-accent);
  background: #ffffff;
}

.folder-modal-overlay .interests-search > svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.folder-modal-overlay .interests-search input {
  flex: 1;
  min-width: 140px;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: var(--gf-text-body, 16px);
  color: var(--fm-ink);
}

.folder-modal-overlay .interests-search input::placeholder {
  color: var(--fm-muted);
}

.folder-modal-overlay .selected-interests {
  display: contents;
}

.folder-modal-overlay .selected-interest {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 12px;
  border-radius: 16px;
  background: #e8eeff;
  color: #2f4fb8;
  font-size: var(--gf-text-body, 16px);
  font-weight: var(--gf-weight-medium);
}

.folder-modal-overlay .remove-interest {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: currentColor;
  cursor: pointer;
}

.folder-modal-overlay .remove-interest:hover {
  background: rgba(47, 79, 184, 0.14);
}

.folder-modal-overlay .interests-suggestions {
  margin: 0;
}

.folder-modal-overlay .popular-interests {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.folder-modal-overlay .popular-label {
  flex: none;
  font-size: var(--gf-text-body, 16px);
  color: var(--fm-muted);
}

.folder-modal-overlay .popular-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.folder-modal-overlay .popular-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid #dfe3ea;
  border-radius: 16px;
  background: #ffffff;
  color: var(--fm-ink);
  font-family: inherit;
  font-size: var(--gf-text-body, 16px);
  font-weight: var(--gf-weight-medium);
  cursor: pointer;
}

.folder-modal-overlay .popular-chip:hover {
  border-color: var(--fm-accent);
  background: #eef3ff;
}

.folder-modal-overlay .popular-chip > span:first-child {
  color: var(--fm-accent);
  font-weight: var(--gf-weight-semibold);
}

/* footer -------------------------------------------------------------- */

.folder-modal-overlay .folder-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 18px 28px;
  border-top: 1px solid var(--fm-line);
  border-radius: 0 0 24px 24px;
  background: #f7f9fc;
}

.folder-modal-overlay .folder-modal-hint {
  margin: 0;
  font-size: var(--gf-text-body, 16px);
  color: var(--fm-muted);
}

.folder-modal-overlay .folder-modal-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.folder-modal-overlay .cancel-folder-btn {
  height: 46px;
  padding: 0 26px;
  border: 1px solid #dfe3ea;
  border-radius: 23px;
  background: #ffffff;
  color: var(--fm-ink);
  font-family: inherit;
  font-size: var(--gf-text-body, 16px);
  font-weight: var(--gf-weight-semibold);
  cursor: pointer;
}

.folder-modal-overlay .cancel-folder-btn:hover {
  background: #f4f6fb;
}

.folder-modal-overlay .create-folder-btn {
  height: 46px;
  padding: 0 26px;
  border: 0;
  border-radius: 23px;
  background: var(--fm-grad);
  color: #ffffff;
  font-family: inherit;
  font-size: var(--gf-text-body, 16px);
  font-weight: var(--gf-weight-semibold);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(51, 102, 232, 0.3);
}

.folder-modal-overlay .create-folder-btn:hover {
  transform: none;
  filter: brightness(1.03);
}

.folder-modal-overlay .create-folder-btn:disabled {
  background: #dfe4f5;
  color: #ffffff;
  box-shadow: none;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  .folder-modal-overlay .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .folder-modal-overlay .folder-form {
    padding: 20px 20px 24px;
  }

  .folder-modal-overlay .folder-modal-banner {
    padding: 20px 20px 18px;
  }

  .folder-modal-overlay .folder-modal-actions {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 20px;
  }

  .folder-modal-overlay .folder-modal-buttons {
    justify-content: flex-end;
  }
}
