#floatingWidget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  height: 600px;
}

/* CRITICAL: Hidden attribute styling */
#floatingWidget[hidden] {
  display: none !important;
}

/* Chat Interface */
#chatInterface {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#chatHeader {
  background: #007ac2;
  /* Brand Blue */
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#chatHeader h3 {
  margin: 0;
  font-size: 18px;
  flex: 1;
}

.header-buttons {
  display: flex;
  gap: 10px;
}

.header-button {
  background: transparent;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background 0.2s;
}

.header-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* CRITICAL: Close and Minimize buttons ALWAYS enabled */
.header-button:disabled {
  opacity: 1 !important;
  cursor: pointer !important;
  background: transparent;
}

/* Participants */
#participants {
  background: #f8f9fa;
  padding: 10px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  gap: 15px;
  min-height: 44px;
}

#participants .user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
}

#participants .user img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

#participants .hidden {
  display: none;
}

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#messages p {
  /* DEPRECATED: Old style - kept as fallback or removed if full switch */
  display: none;
}

/* NEW Message Styles */
.message-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  width: 100%;
}

/* System Messages (Connecting, Joined, etc.) */
.system-message {
  align-self: center;
  background: rgba(0, 0, 0, 0.05);
  color: #666;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  text-align: center;
  margin: 8px 0;
  max-width: 90%;
}

/* Chat Bubbles */
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  position: relative;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

/* User Messages (Sent) */
.message-row.sent {
  align-items: flex-end;
}

.message-row.sent .chat-bubble {
  background: #007ac2;
  /* Brand Blue */
  color: white;
  border-bottom-right-radius: 4px;
}

/* Agent Messages (Response) */
.message-row.response {
  align-items: flex-start;
}

.message-row.response .chat-bubble {
  background: #e9ecef;
  color: #333;
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.7;
  text-align: right;
  display: block;
}

.message-row.sent .message-time {
  color: #e0e0e0;
}

.message-row.response .message-time {
  color: #888;
}

#messages a {
  color: inherit;
  text-decoration: underline;
}

/* Input Area - STARTS DISABLED */
#inputArea {
  padding: 15px 20px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
}

#outmessage {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  min-height: 44px;
  max-height: 100px;
}

/* CRITICAL: Disabled state styling */
#outmessage:disabled {
  background: #e9ecef;
  cursor: not-allowed;
  opacity: 0.6;
  color: #6c757d;
}

#sendbutton-chat {
  padding: 10px 20px;
  background: #007ac2;
  /* Brand Blue */
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s;
}

#sendbutton-chat:hover:not(:disabled) {
  background: #00629c;
  /* Darker Brand Blue */
}

/* CRITICAL: Disabled send button styling */
#sendbutton-chat:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Page Push */
#pagePushDiv {
  padding: 10px 20px;
  background: #fff3cd;
  border-top: 1px solid #ffc107;
  display: flex;
  gap: 10px;
}

#urlInput {
  flex: 1;
  padding: 8px;
  border: 1px solid #ffc107;
  border-radius: 4px;
  font-size: 13px;
}

#pagePushDiv button {
  padding: 8px 15px;
  background: #ffc107;
  color: #333;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

#pagePushDiv button:hover {
  background: #e0a800;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Scrollbar */
#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

#messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Confirmation Modal Styles */
#confirmationModal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  /* Semi-transparent overlay */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  /* On top of everything inside widget */
}

#confirmationModal.hidden {
  display: none !important;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  width: 800px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  height: 300px;
}

.modal-content-chat {
  background: white;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  width: 80%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-content-chat p {
  margin-bottom: 20px;
  color: #333;
  font-size: 16px;
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.modal-buttons button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}
.custom-modal {
  max-width: 525px !important;
}
.custom-modal .modal-header {
  justify-content: flex-start;
  text-align: left;
}

.custom-modal .modal-header {
  text-align: left;
  width: 100%;
}

.custom-modal .modal-body {
  text-align: left;
  padding-bottom: 0.25rem;
}

.confirm-btn {
  background: #dc3545;
  /* Red for danger/end */
  color: white;
}

.confirm-btn:hover {
  background: #bd2130;
}

.cancel-btn {
  background: #6c757d;
  /* Grey for cancel */
  color: white;
}

.cancel-btn:hover {
  background: #5a6268;
}
