/* threads.css */
.conversations-module {
  width: 100%;
  padding: 32px 20px 48px;
  justify-content: center;
  align-items: stretch;
  box-sizing: border-box;
}

.tab-content.active.conversations-module {
  display: flex;
}

.tab-content.conversations-module[hidden] {
  display: none !important;
}

.conversations-module--empty::after {
  content: '';
}

@media (max-width: 768px) {
  .conversations-module {
    padding: 24px 14px 32px;
  }
}

@media (max-width: 480px) {
  .conversations-module {
    padding: 18px 12px 28px;
  }
}

.threads-panel {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 32px;
  border-radius: 28px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(11, 18, 32, 0.78);
  box-shadow: 0 24px 64px rgba(8, 15, 35, 0.35);
  backdrop-filter: blur(18px);
}

.threads-panel__inner {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.threads-panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.threads-panel__titles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(100%, 520px);
}

.threads-panel__title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.threads-panel__subtitle {
  margin: 0;
  font-size: 15px;
  color: rgba(226, 232, 240, 0.72);
  line-height: 1.5;
}

.threads-panel__new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.08));
  color: #e0f2fe;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

.threads-panel__new:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(56, 189, 248, 0.12));
  border-color: rgba(56, 189, 248, 0.75);
  transform: translateY(-1px);
}

/* Rename functionality */
.threads-panel__rename {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.5);
  color: rgba(226, 232, 240, 0.85);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.threads-panel__rename:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
}

.threads-panel__rename:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.threads-panel__rename-form {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  margin-top: 8px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.threads-panel__rename-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.8);
  color: rgba(226, 232, 240, 0.95);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.threads-panel__rename-input:focus {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(15, 23, 42, 0.95);
}

.threads-panel__rename-input::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

.threads-panel__rename-actions {
  display: flex;
  gap: 6px;
}

.threads-panel__rename-save,
.threads-panel__rename-cancel {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.threads-panel__rename-save {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.threads-panel__rename-save:hover {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.5);
}

.threads-panel__rename-cancel {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.threads-panel__rename-cancel:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

/* Sort and controls */
.threads-panel__controls {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.threads-panel__search {
  flex: 1;
  min-width: 240px;
}

.threads-panel__sort {
  display: flex;
  gap: 10px;
  align-items: center;
}

.threads-panel__sort-label {
  font-size: 14px;
  color: rgba(226, 232, 240, 0.75);
  white-space: nowrap;
}

.threads-panel__sort-select {
  padding: 8px 32px 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.8);
  color: rgba(226, 232, 240, 0.95);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(226, 232, 240, 0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}

.threads-panel__sort-select:hover {
  border-color: rgba(148, 163, 184, 0.4);
  background-color: rgba(15, 23, 42, 0.95);
}

.threads-panel__sort-select:focus {
  border-color: rgba(56, 189, 248, 0.5);
  background-color: rgba(15, 23, 42, 0.95);
}

/* Context Menu */
.threads-context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 180px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  animation: contextMenuFadeIn 0.15s ease-out;
}

@keyframes contextMenuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.threads-context-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(226, 232, 240, 0.9);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.threads-context-menu__item:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #e0f2fe;
}

.threads-context-menu__item--danger {
  color: rgba(252, 165, 165, 0.9);
}

.threads-context-menu__item--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.threads-panel__new:disabled {
  opacity: 0.55;
  cursor: default;
}

.threads-panel__search-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.65);
  color: rgba(226, 232, 240, 0.95);
  font-size: 14px;
  font-family: inherit;
  transition: border 0.2s ease, background 0.2s ease;
}

.threads-panel__search-input::placeholder {
  color: rgba(148, 163, 184, 0.58);
}

.threads-panel__search-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(15, 23, 42, 0.85);
}

.threads-panel__body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.threads-panel__error {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #fda4af;
}

.threads-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.threads-panel__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.58);
  transition: border 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.threads-panel__item:hover {
  border-color: rgba(148, 163, 184, 0.35);
  transform: translateY(-1px);
}

.threads-panel__item.is-active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.threads-panel__select {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.threads-panel__select.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

.threads-panel__select.is-disabled {
  opacity: 0.5;
  cursor: default;
}

.threads-panel__item-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.threads-panel__item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(226, 232, 240, 0.75);
}

.threads-panel__item-agent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.18);
  color: rgba(191, 219, 254, 0.92);
  font-weight: 500;
}

.threads-panel__item-status {
  padding: 2px 12px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}

.threads-panel__item-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(226, 232, 240, 0.68);
  font-weight: 500;
}

.threads-panel__item-count::before {
  content: "\2022";
  color: rgba(148, 163, 184, 0.7);
  font-weight: 600;
  margin-right: 6px;
}

.threads-panel__item-timestamp {
  font-size: 13px;
  color: rgba(148, 163, 184, 0.68);
}

.threads-panel__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.threads-panel__archive,
.threads-panel__delete {
  min-width: 140px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.45);
  color: rgba(226, 232, 240, 0.88);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

.threads-panel__archive:hover:not(:disabled) {
  border-color: rgba(147, 197, 253, 0.6);
  background: rgba(37, 99, 235, 0.16);
}

.threads-panel__delete {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
}

.threads-panel__delete:hover:not(:disabled) {
  border-color: rgba(252, 165, 165, 0.75);
  background: rgba(252, 165, 165, 0.18);
}

.threads-panel__archive.is-busy,
.threads-panel__archive.is-disabled,
.threads-panel__delete.is-busy,
.threads-panel__delete.is-disabled,
.threads-panel__archive:disabled,
.threads-panel__delete:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.threads-panel__confirm {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.28);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.threads-panel__confirm-text {
  margin: 0;
  font-size: 14px;
  color: rgba(254, 226, 226, 0.92);
}

.threads-panel__confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.threads-panel__confirm-delete,
.threads-panel__confirm-cancel {
  min-width: 120px;
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease;
}

.threads-panel__confirm-delete {
  border: 1px solid rgba(239, 68, 68, 0.65);
  background: rgba(239, 68, 68, 0.22);
  color: #fee2e2;
}

.threads-panel__confirm-delete:hover:not(:disabled) {
  border-color: rgba(239, 68, 68, 0.85);
  background: rgba(239, 68, 68, 0.32);
}

.threads-panel__confirm-cancel {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(30, 41, 59, 0.85);
  color: rgba(226, 232, 240, 0.9);
}

.threads-panel__confirm-cancel:hover:not(:disabled) {
  border-color: rgba(148, 163, 184, 0.5);
}

.threads-panel__confirm-delete:disabled,
.threads-panel__confirm-cancel:disabled {
  opacity: 0.55;
  cursor: default;
}

.threads-panel__placeholder {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.52);
  font-size: 14px;
  color: rgba(226, 232, 240, 0.75);
  text-align: center;
}

.conversations-module--empty .threads-panel {
  border-style: dashed;
}

@media (max-width: 960px) {
  .threads-panel {
    padding: 24px;
    border-radius: 24px;
  }

  .threads-panel__header {
    flex-direction: column;
    align-items: stretch;
  }

  .threads-panel__new {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .threads-panel {
    padding: 20px;
    margin: 0;
  }

  .threads-panel__item {
    padding: 16px;
  }

  .threads-panel__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .threads-panel__archive,
  .threads-panel__delete {
    width: 100%;
  }

  .threads-panel__confirm-actions {
    flex-direction: column;
  }

  .threads-panel__confirm-delete,
  .threads-panel__confirm-cancel {
    width: 100%;
  }
}



