/* css/chat.css - Visually Stunning Chat System Styling */

/* --- Chat Slideout Base Layout --- */
.chat-slideout {
  position: fixed;
  top: 0;
  right: -400px; /* Start hidden off-screen */
  width: 380px;  /* Premium desktop width */
  height: 100vh;
  height: 100dvh;
  background-color: #0b0c10; /* Very dark background */
  z-index: 9999; /* Super high to overlay nav bar and wait times */
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 25px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  border-left: 1px solid #1f2833;
}

.chat-slideout.open {
  right: 0; /* Fully reveal slideout */
}

/* Reserve space for right navigation bar on Desktop */
@media (min-width: 933px) {
  .chat-slideout.open {
    right: var(--right-panel-width, 55px);
  }
  
  /* If the wait times slideout is also open, shift the chat further left */
  body:has(.park-companion-slideout.open) .chat-slideout.open {
    right: calc(var(--right-panel-width, 55px) + 25vw);
  }
}

/* Responsive fullscreen on mobile */
@media (max-width: 932px) {
  .chat-slideout {
    right: -100vw;
    width: 100vw;
    z-index: 9999; /* Overlay everything on mobile */
    border-left: none;
  }
  .chat-slideout.open {
    right: 0;
  }
}

/* Reserve bottom space if the horizontal Wait Times scrolling bar is active */
body.wait-times-active .chat-slideout {
  height: calc(100vh - var(--wait-times-bar-height, 30px));
}

/* --- Header --- */
.chat-header {
  background-color: #1f2833;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #66fcf1; /* Teal accent border */
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-icon {
  font-size: 1.3em;
}

.chat-header-title h3 {
  color: #ffffff;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#chat-settings-toggle-btn {
  background: none;
  border: none;
  color: #c5c6c7;
  font-size: 1.15em;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s, background-color 0.2s;
}

#chat-settings-toggle-btn:hover {
  color: #66fcf1;
  background-color: rgba(102, 252, 241, 0.08);
}

.close-chat-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  transition: transform 0.2s, color 0.2s;
}

.close-chat-btn:hover {
  color: #ff4d4d;
  transform: scale(1.1);
}

/* --- Settings Overlay Panel --- */
.chat-settings-panel {
  position: absolute;
  top: 58px; /* Below Header */
  left: 0;
  width: 100%;
  height: calc(100% - 58px);
  background-color: #0b0c10;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
  animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
  from { transform: translateY(-15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.chat-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1f2833;
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.chat-settings-header h4 {
  margin: 0;
  color: #66fcf1;
  font-size: 1.1rem;
}

#chat-settings-back-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  transition: background-color 0.2s;
}

#chat-settings-back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-settings-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chat-setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #c5c6c7;
  font-size: 0.95rem;
  padding: 10px 0;
  border-bottom: 1px dashed #1f2833;
  cursor: pointer;
}

.chat-setting-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #66fcf1;
  cursor: pointer;
}

.chat-setting-item.sub-setting {
  font-size: 0.85rem;
  padding: 6px 0;
  color: #8f9499;
}

#chat-settings-save-btn {
  margin-top: 20px;
  background-color: #45a29e;
  color: #0b0c10;
  border: none;
  padding: 12px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

#chat-settings-save-btn:hover {
  background-color: #66fcf1;
  box-shadow: 0 0 10px rgba(102, 252, 241, 0.4);
}

/* --- Workspace Split --- */
.chat-main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* --- Rooms/Users Sidebar --- */
.chat-rooms-list {
  width: 140px; /* Fixed width to prevent distracting hover expansion */
  background-color: #151b24;
  border-right: 1px solid #1f2833;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Scrollbar styling for sidebar */
.chat-rooms-list::-webkit-scrollbar {
  width: 3px;
}
.chat-rooms-list::-webkit-scrollbar-thumb {
  background: #1f2833;
}

.chat-room-item {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border-bottom: 1px solid #1f2833;
  cursor: pointer;
  position: relative;
  text-align: center;
  transition: background-color 0.2s;
}

.chat-room-item:hover {
  background-color: rgba(102, 252, 241, 0.05);
}

.chat-room-item.active {
  background-color: rgba(102, 252, 241, 0.1);
  border-left: 3px solid #66fcf1;
}

.chat-room-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #1f2833;
  font-size: 1.1rem;
  border: 1px solid #45a29e;
  object-fit: cover;
}

.chat-room-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
}

.chat-room-name {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 120px;
  width: 100%;
}

.chat-hide-convo-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: #8f9499;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.chat-room-item:hover .chat-hide-convo-btn {
  opacity: 1;
}

.chat-hide-convo-btn:hover {
  color: #ff4d4d;
}

.chat-room-status {
  color: #8f9499;
  font-size: 0.65rem;
  white-space: nowrap;
}

.chat-sidebar-section-title {
  color: #45a29e;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 12px 4px 6px;
  border-top: 1px solid #1f2833;
  text-align: center;
  letter-spacing: 0.5px;
  white-space: normal;
  word-wrap: break-word;
}

.chat-room-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background-color: #ff4d4d;
  color: white;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.chat-no-users {
  color: #8f9499;
  font-size: 0.7rem;
  padding: 15px 5px;
  text-align: center;
}

/* --- Chat Room Conversation Window --- */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #0b0c10;
}

/* Messages List */
.chat-messages-container {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages-container::-webkit-scrollbar {
  width: 5px;
}
.chat-messages-container::-webkit-scrollbar-track {
  background: #0b0c10;
}
.chat-messages-container::-webkit-scrollbar-thumb {
  background: #1f2833;
  border-radius: 4px;
}

.chat-loading-msgs {
  color: #8f9499;
  font-size: 0.9em;
  text-align: center;
  margin-top: 40px;
}

/* Chat bubble structures */
.chat-msg-row {
  display: flex;
  gap: 8px;
  max-width: 85%;
}

.chat-msg-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-row.theirs {
  align-self: flex-start;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #1f2833;
  object-fit: cover;
}

.chat-msg-bubble-wrap {
  display: flex;
  flex-direction: column;
}

.chat-msg-sender {
  font-size: 0.7rem;
  color: #8f9499;
  margin-bottom: 2px;
}

.chat-msg-row.mine .chat-msg-sender {
  text-align: right;
}

.chat-msg-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.chat-msg-row.mine .chat-msg-bubble {
  background-color: #45a29e;
  color: #0b0c10;
  border-top-right-radius: 2px;
}

.chat-msg-row.theirs .chat-msg-bubble {
  background-color: #1f2833;
  color: #c5c6c7;
  border-top-left-radius: 2px;
}

.chat-msg-time {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  align-self: flex-end;
  margin-top: 4px;
  white-space: nowrap;
}

.chat-msg-row.mine .chat-msg-time {
  color: rgba(11, 12, 16, 0.6);
}

/* Direct Message Avatar Green Status Dot */
.chat-room-item-avatar-wrapper {
  position: relative;
  display: inline-block;
}

.chat-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background-color: #66fcf1; /* Cyber green/cyan status dot */
  border-radius: 50%;
  border: 1.5px solid #151b24;
}

/* --- Message Deep-Link Highlighting Animation --- */
.highlight-pulse {
  animation: messagePulse 2s ease-in-out;
}

@keyframes messagePulse {
  0% { box-shadow: 0 0 0 0 rgba(102, 252, 241, 0.8); border: 1.5px solid #66fcf1; }
  50% { box-shadow: 0 0 15px 4px rgba(102, 252, 241, 0.6); border: 1.5px solid #66fcf1; }
  100% { box-shadow: 0 2px 5px rgba(0,0,0,0.2); border: none; }
}

/* --- Chat Input Area --- */
.chat-input-container {
  padding: 12px;
  background-color: #151b24;
  border-top: 1px solid #1f2833;
  display: flex;
  gap: 8px;
}

#chat-message-input {
  flex: 1;
  background-color: #0b0c10;
  border: 1px solid #1f2833;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

#chat-message-input:focus {
  border-color: #66fcf1;
}

#chat-send-btn {
  background-color: #45a29e;
  border: none;
  color: #0b0c10;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

#chat-send-btn:hover {
  background-color: #66fcf1;
}
