/**
 * Chat Groups Styles
 * @package virtuaria/ai
 */

:root {
  --chat-group-bg: rgba(255, 255, 255, 0.03);
  --chat-group-border: rgba(255, 255, 255, 0.1);
  --chat-group-hover: rgba(255, 255, 255, 0.05);
  --chat-group-hover-border: rgba(255, 255, 255, 0.15);
  --chat-item-hover: rgba(255, 255, 255, 0.08);
  --chat-item-active: rgb(208 208 232 / 17%);
  --danger-color: #ff6b6b;
  --primary-color: #0ea5ff;
}

/* Chat Groups Container */
#chat-groups-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

/* Groups List */
.groups-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Individual Group */
.chat-group {
  border-radius: 8px;
  overflow: hidden;
  background: var(--chat-group-bg);
  border: 1px solid var(--chat-group-border);
  transition: all 0.3s ease;
  position: relative;
}

.chat-group:hover {
  background: var(--chat-group-hover);
  border-color: var(--chat-group-hover-border);
}

/* Group Header (Toggle) */
.chat-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 10px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
}

.chat-group-header:hover {
  background: var(--chat-item-hover);
}

.chat-group-header:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

.group-title-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.group-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
  font-size: 12px;
  flex-shrink: 0;
}

.chat-group[aria-expanded="true"] .group-toggle-icon .fa:before {
  content: "\f07c";
}

.group-folder-icon {
  opacity: 0.7;
  flex-shrink: 0;
}

.group-folder-icon .fa {
  font-size: 16px;
}

.group-name {
  font-size: 16px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  font-size: 12px;
  opacity: 0.6;
  margin-left: 8px;
  flex-shrink: 0;
}

/* Group Actions */
.group-actions {
  display: flex;
  gap: 4px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.chat-group-header:hover .group-actions {
  opacity: 1;
}

.group-action-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
}

.group-action-btn:focus {
  outline: 1px solid var(--primary-color);
  outline-offset: -1px;
}

.group-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.group-options-dots {
  font-weight: 700;
  letter-spacing: 1px;
}

/* Group Chats Container */
.group-chats {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-group[aria-expanded="true"] .group-chats {
  max-height: 1500px;
  overflow-y: auto;
}

.chat-group.selected .chat-group-header {
  background: rgba(255, 255, 255, 0.06);
}


/* Chat Items */
.chat-item {
  display: flex;
  flex-direction: r;
  padding: 10px 1px 10px 20px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.2s ease;
  font-size: 13px;
  overflow: hidden;
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  justify-content: space-between;
  width: 100%;
  position: relative;
  padding-right: 10px;
  align-items: center;
}


.chat-item:hover {
  background: var(--chat-item-hover);
  border-left-color: rgba(255, 255, 255, 0.4);
}

.chat-item:hover {
  background: var(--chat-item-hover);
  border-left-color: rgba(255, 255, 255, 0.4);
}

.chat-item:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

.chat-item.active {
  background: var(--chat-item-active);
  border-left-color: var(--primary-color);
}

.chat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.chat-type {
  font-size: 15px;
  opacity: 0.6;
  margin-right: 5px;
}

.chat-item-options {
  font-size: 12px;
  opacity: 0.6;
  cursor: pointer;
  padding: 3px 10px;
}


.chat-item-options:hover {
  opacity: 1;
}

.no-chats {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  opacity: 0.6;
  color: #9aa7b2;
}

/* Create Group Button */
.create-group-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: inherit;
  justify-content: flex-start;
  font-size: 1rem;
}

.create-group-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

.create-group-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

.create-group-btn:active {
  transform: scale(0.98);
}

.create-group-btn i {
  font-size: 14px;
}
.light-theme .create-group-btn {
  border-color: transparent;
  background-color: #e0e0e1;
  color: var(--text);
}
.light-theme .create-group-btn:hover {
  background-color: #e0e0e1;
  filter: brightness(1.2);
}
.light-theme .chat-item {
    border-bottom: 1px solid #e1e1e1;
}

.chat-type img {
  max-width: 13px;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-in-out;
}

.modal-overlay.show {
  display: flex;
}

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

.modal-content {
  background: linear-gradient(110deg, #0d2229 0%, #42616b 100%);;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.light-theme .show .modal-header,
.light-theme .modal-content {
  color: var(--text-button);
}

.light-theme .modal-input option {
    background-color: #020611;
}

.modal-header {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 16px;
  transition: all 0.2s ease;
}

.modal-input:focus {
  outline: none;
  border-color: #0ea5ff;
  background: rgba(255, 255, 255, 0.08);
}

.modal-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: inherit;
}

.modal-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.modal-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-btn.cancel {
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
}

.modal-btn.cancel:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

.modal-btn.create {
  background: var(--primary-color);
  color: #071029;
}

.modal-btn.create:hover:not(:disabled) {
  background: #06d6ff;
  box-shadow: 0 4px 12px rgba(14, 165, 255, 0.3);
}

/* Group Selection Modal */
.modal-select {
  width: 100%;
  padding: 10px 12px;
  margin: 12px 0;
  border: 1px solid var(--chat-group-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-select:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-color);
}

.modal-select:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(14, 165, 255, 0.2);
}

.modal-select option {
  background: #1a1f35;
  color: inherit;
  padding: 8px;
}

.light-theme .chat-group {
    background-color: #ffffff;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-item {
    padding: 8px 12px 8px 28px;
    font-size: 12px;
  }

  .group-name {
    font-size: 13px;
  }

  .chat-group-header {
    padding: 10px 12px;
  }

  .group-actions {
    gap: 2px;
  }

  .group-action-btn {
    padding: 2px 4px;
    font-size: 11px;
  }
}
