/* Chat Interface Styles */
.chat-container {
  display: flex;
  flex: 1;
  overflow-y: auto;
  flex-direction: column;
  background-color: #f5f5f5;
}

/* Hide header and footer when chat is active */
body:has(.chat-container) footer {
  display: none;
}

.chat-header {
  background: white;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.chat-header-left {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 1rem;
}

.chat-header-right {
  display: flex;
  align-items: center;
}

.character-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e0e0e0;
}

.character-info h2 {
  font-size: 1.2rem;
  margin: 0;
  color: #2c3e50;
}

.character-meta {
  font-size: 0.85rem;
  color: #666;
  margin: 0;
}

.chat-menu-container {
  position: relative;
}

.chat-menu-button {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s, color 0.2s;
}

.chat-menu-button:hover {
  background: #f5f5f5;
  color: #2c3e50;
}

.chat-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 180px;
  display: none;
  z-index: 1000;
  overflow: hidden;
}

.chat-menu-dropdown.show {
  display: block;
}

.menu-item {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: #2c3e50;
  transition: background-color 0.2s;
}

.menu-item:hover {
  background: #f5f5f5;
}

.menu-item svg {
  flex-shrink: 0;
}

.menu-item-danger {
  color: #e74c3c;
}

.menu-item-danger:hover {
  background: #fee;
}

.message-limit-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fff3cd;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid #ffc107;
}

.limit-text {
  font-size: 0.9rem;
  color: #856404;
  font-weight: 500;
}

.upgrade-link {
  background: #ffc107;
  color: #000;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background-color 0.3s;
}

.upgrade-link:hover {
  background: #ffb300;
}

.chat-messages {
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.scroll-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  color: #666;
  font-size: 0.9rem;
}

.loader-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #e0e0e0;
  border-top-color: #2c3e50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.message {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  animation: slideIn 0.3s ease-out;
}

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

.message-user {
  flex-direction: row-reverse;
  align-self: flex-end;
  max-width: 70%;
}

.message-opponent {
  flex-direction: row;
  align-self: flex-start;
  max-width: 95%;
}

.message-sender {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.message-bubble {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.message-user .message-bubble {
  background: #2c3e50;
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-opponent .message-bubble {
  background: white;
  color: #333;
  padding: 0.75rem 1rem;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.message-content {
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.message-time {
  font-size: 0.75rem;
  opacity: 0.7;
  text-align: left;
}

.message-user .message-time {
  text-align: right;
}

.typing-indicator {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  align-self: flex-start;
}

.typing-bubble {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.typing-bubble span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.chat-input-container {
  background: white;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 1200px;
  margin: 0 auto;
}

.chat-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-form textarea {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s;
  resize: none;
  min-height: 45px;
  max-height: 150px;
  line-height: 1.5;
  overflow-y: hidden;
}

.chat-form textarea:focus {
  border-color: #2c3e50;
}

.chat-form button {
  background: #2c3e50;
  color: white;
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.1s;
  flex-shrink: 0;
}

.chat-form button:hover:not(:disabled) {
  background: #34495e;
  transform: scale(1.05);
}

.chat-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.limit-reached-message {
  text-align: center;
  padding: 1rem;
  background: #fff3cd;
  border-radius: 12px;
  border: 1px solid #ffc107;
}

.limit-reached-message p {
  color: #856404;
  font-weight: 500;
}

.btn-register {
  display: inline-block;
  background: #2c3e50;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 25px;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.3s;
}

.btn-register:hover {
  background: #34495e;
}

.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-history-item {
  background: white;
  border-radius: 8px;
  padding: 1.0rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.chat-history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.chat-item-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.chat-item-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  background: #e0e0e0;
}

.chat-item-info {
  flex: 1;
}

.chat-item-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: #2c3e50;
  margin-bottom: 0.25rem;
}

.chat-item-type {
  font-size: 0.85rem;
  color: #7f8c8d;
}

.chat-item-last-message {
  color: #555;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #95a5a6;
}

.chat-item-time {
  font-style: italic;
}

.chat-item-count {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: #7f8c8d;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.chat-item-count svg {
  width: 18px;
  height: 18px;
  stroke: #7f8c8d;
}

.chat-item-count span {
  font-weight: 600;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #7f8c8d;
}

.no-chats {
  text-align: center;
  padding: 1rem;
  color: #7f8c8d;
}

.no-chats h2 {
  color: #95a5a6;
  margin-bottom: 1rem;
}

.no-chats a {
  color: #3498db;
  text-decoration: none;
}

.no-chats a:hover {
  text-decoration: underline;
}

.error-message {
  background: #fee;
  color: #c33;
  padding: 1rem;
  border-radius: 4px;
  text-align: center;
}

/* Responsive Chat Styles */
@media (max-width: 768px) {
  .chat-header {
    justify-content: start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .message-limit-badge {
    width: 100%;
  }

  .chat-messages {
    padding: 1rem 0;
  }

  .message-user {
    max-width: 85%;
  }
  .message-character {
    max-width: 95%;
  }

  .chat-input-container {
    padding: 0.75rem 1rem;
  }

  .chat-form button {
    width: 40px;
    height: 40px;
  }
}
/* Info Button Styles */
.info-button {
  background: linear-gradient(135deg, #7c8db5 0%, #8e7ba4 100%);
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  margin-left: 0.5rem;
  box-shadow: 0 2px 6px rgba(124, 141, 181, 0.25);
}

.info-button:hover {
  background: linear-gradient(135deg, #8e7ba4 0%, #7c8db5 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(124, 141, 181, 0.4);
}

.info-button svg {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.memory-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.memory-field {
  border-left: 3px solid #3498db;
  padding-left: 1rem;
}

.memory-field h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: #2c3e50;
  font-weight: 600;
}

.memory-field p {
  margin: 0;
  color: #555;
  line-height: 1.6;
  white-space: pre-wrap;
}

.memory-field .info-list {
  margin: 0;
  padding-left: 1.5rem;
  list-style-type: disc;
}

.memory-field .info-list li {
  color: #555;
  line-height: 1.8;
  margin-bottom: 0.5rem;
}

.memory-field .info-list li:last-child {
  margin-bottom: 0;
}

.memory-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
  text-align: center;
}

.memory-footer small {
  color: #999;
  font-size: 0.85rem;
}

.info-note {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.info-note p {
  margin: 0;
  line-height: 1.6;
}

.info-upgrade {
  text-align: center;
  padding: 2rem;
}

.info-upgrade p {
  margin: 0 0 1.5rem 0;
  color: #666;
  line-height: 1.6;
}

.btn-upgrade {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-upgrade:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

@media (max-width: 768px) {
  .info-button {
    padding: 0.4rem;
  }
}