/* ══════════════════════════════════════════════════════
   Consultation Room & Chatbot Widget Styles
   ══════════════════════════════════════════════════════ */

/* ── Chatbot Widget ── */
#chatbot-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9990;
  font-family: 'DM Sans', sans-serif;
}

#chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-600), var(--green-700));
  color: #fff;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
#chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}

.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s ease;
}
.chatbot-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chatbot-header {
  background: linear-gradient(135deg, var(--green-700), var(--green-800, #2d5a3d));
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.chatbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.chatbot-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.chatbot-status {
  font-size: 0.72rem;
  opacity: 0.85;
}
.chatbot-status i {
  font-size: 0.5rem;
  color: #4ade80;
  margin-right: 3px;
}
.chatbot-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.chatbot-close:hover { opacity: 1; }

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 260px;
  max-height: 320px;
  background: #f8f9fa;
}

.chatbot-msg {
  max-width: 85%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-line;
  animation: msgFadeIn 0.25s ease;
}
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chatbot-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--text-primary);
  border: 1px solid #e8e8e8;
  border-bottom-left-radius: 4px;
}
.chatbot-msg-user {
  align-self: flex-end;
  background: var(--green-600);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chatbot-input-area {
  border-top: 1px solid #eee;
  background: #fff;
}
.chatbot-options {
  display: none;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 0.8rem 0;
}
.chatbot-option-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--green-300);
  border-radius: 20px;
  background: var(--green-50);
  color: var(--green-700);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}
.chatbot-option-btn:hover {
  background: var(--green-600);
  color: #fff;
  border-color: var(--green-600);
}

.chatbot-input-row {
  display: flex;
  padding: 0.6rem;
  gap: 0.4rem;
}
.chatbot-input-row input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 24px;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.chatbot-input-row input:focus {
  border-color: var(--green-400);
}
.chatbot-input-row input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}
.chatbot-input-row button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--green-600);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.chatbot-input-row button:hover {
  background: var(--green-700);
}

/* Mobile chatbot */
@media (max-width: 480px) {
  .chatbot-panel {
    width: calc(100vw - 2rem);
    right: -0.5rem;
    max-height: 70vh;
  }
}

/* ── Consultation Room ── */
.consultation-body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f4f5f7;
  font-family: 'DM Sans', sans-serif;
}

.consult-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  height: 52px;
  flex-shrink: 0;
}
.consult-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.consult-brand {
  text-decoration: none;
  color: var(--green-700);
  font-weight: 700;
  font-size: 1rem;
}
.consult-brand i { margin-right: 0.3rem; }
.consult-separator { color: #ccc; }
.consult-title { color: var(--text-secondary); font-size: 0.88rem; }

.consult-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.consult-status-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  background: #fff3cd;
  color: #856404;
}
.consult-status-badge i { font-size: 0.5rem; }
.consult-status-badge.status-connected { background: #d4edda; color: #155724; }
.consult-status-badge.status-ended { background: #e2e3e5; color: #383d41; }

.btn-consult-end {
  background: #dc3545;
  color: #fff;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.2s;
}
.btn-consult-end:hover { background: #c82333; }

/* Main area */
.consult-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Video Area */
.consult-video-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  position: relative;
  min-width: 0;
}
.consult-video-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.consult-video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.consult-video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}
.consult-video-placeholder {
  text-align: center;
  color: rgba(255,255,255,0.5);
}
.consult-video-placeholder i { font-size: 3rem; margin-bottom: 0.5rem; }
.consult-video-placeholder p { font-size: 0.9rem; }

.consult-local-video {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 160px;
  height: 120px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.3);
  object-fit: cover;
  z-index: 2;
}

.consult-call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(0,0,0,0.4);
}
.call-ctrl {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-ctrl:hover { background: rgba(255,255,255,0.25); }
.call-ctrl.active { background: #dc3545; }
.call-ctrl-end {
  background: #dc3545;
  width: 56px;
  height: 56px;
}
.call-ctrl-end:hover { background: #c82333; }

/* Incoming call modal */
.consult-call-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.call-modal-content {
  background: #fff;
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: callPulse 0.5s ease;
}
@keyframes callPulse {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.call-modal-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: #fff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  animation: ringPulse 1.5s infinite;
}
@keyframes ringPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76,175,80,0.4); }
  50% { box-shadow: 0 0 0 16px rgba(76,175,80,0); }
}
.call-modal-content h3 { margin: 0 0 0.25rem; }
.call-modal-content p { color: #666; margin: 0 0 1.5rem; font-size: 0.9rem; }
.call-modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.call-modal-accept, .call-modal-decline {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 30px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}
.call-modal-accept { background: #28a745; color: #fff; }
.call-modal-accept:hover { background: #218838; }
.call-modal-decline { background: #dc3545; color: #fff; }
.call-modal-decline:hover { background: #c82333; }

/* Chat Area */
.consult-chat-area {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  transition: max-width 0.3s ease;
}
.consult-chat-area.with-video {
  max-width: 380px;
  min-width: 320px;
}

.consult-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.consult-chat-header-info h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.consult-chat-header-info h4 i { color: var(--green-600); margin-right: 0.3rem; }
.consult-chat-with { font-size: 0.78rem; color: var(--text-light); }

.consult-chat-actions {
  display: flex;
  gap: 0.4rem;
}
.chat-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  color: var(--green-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 0.9rem;
}
.chat-action-btn:hover {
  background: var(--green-50);
  border-color: var(--green-300);
}

/* Patient info card */
.consult-patient-card {
  margin: 0.75rem;
  padding: 0.75rem;
  background: var(--green-50);
  border-radius: 10px;
  border: 1px solid var(--green-100);
  flex-shrink: 0;
}
.consult-patient-card h5 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--green-700);
}
.patient-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.patient-concern {
  grid-column: 1 / -1;
}

/* Waiting card */
.consult-waiting-card {
  margin: 1.5rem;
  padding: 2rem;
  text-align: center;
  background: #f8f9fa;
  border-radius: 12px;
  flex-shrink: 0;
}
.consult-waiting-card h4 {
  margin: 1rem 0 0.5rem;
  color: var(--text-primary);
}
.consult-waiting-card p {
  color: var(--text-light);
  font-size: 0.88rem;
  max-width: 360px;
  margin: 0 auto;
}
.waiting-animation {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.waiting-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green-400);
  animation: waitBounce 1.4s infinite ease-in-out;
}
.waiting-dot:nth-child(2) { animation-delay: 0.2s; }
.waiting-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes waitBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat messages */
.consult-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: #f8f9fa;
}

.chat-msg {
  display: flex;
  animation: msgFadeIn 0.25s ease;
}
.chat-msg-mine { justify-content: flex-end; }
.chat-msg-other { justify-content: flex-start; }

.chat-msg-bubble {
  max-width: 75%;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}
.chat-msg-mine .chat-msg-bubble {
  background: var(--green-600);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-other .chat-msg-bubble {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-bottom-left-radius: 4px;
}

.chat-msg-sender {
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.75;
  margin-bottom: 2px;
}
.chat-msg-time {
  font-size: 0.65rem;
  opacity: 0.6;
  text-align: right;
  margin-top: 2px;
}

.chat-msg-system {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-light);
  padding: 0.4rem 0;
  font-style: italic;
}

/* Typing indicator */
.consult-typing {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 1rem;
  font-size: 0.78rem;
  color: var(--text-light);
  font-style: italic;
}
.typing-dots span {
  animation: typingBlink 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBlink {
  0%, 60%, 100% { opacity: 0.2; }
  30% { opacity: 1; }
}

/* Chat input */
.consult-chat-input {
  display: flex;
  padding: 0.6rem;
  gap: 0.4rem;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: #fff;
}
.consult-chat-input input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 24px;
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.consult-chat-input input:focus {
  border-color: var(--green-400);
}
.consult-chat-input input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}
.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--green-600);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--green-700); }

/* Connection banner */
.consult-connection-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #fff3cd;
  color: #856404;
  font-size: 0.82rem;
  border-bottom: 1px solid #ffc107;
  flex-shrink: 0;
}
.consult-connection-banner i { font-size: 0.9rem; }

/* Jitsi close button */
.jitsi-close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.jitsi-close-btn:hover { background: rgba(0,0,0,0.7); }

/* Jitsi container iframe sizing */
#jitsiContainer iframe {
  border-radius: 0;
  border: none;
}

/* Responsive */
@media (max-width: 768px) {
  .consult-main { flex-direction: column; }
  .consult-chat-area.with-video {
    max-width: 100%;
    min-width: auto;
    max-height: 50vh;
  }
  .consult-video-area { max-height: 50vh; }
  .consult-topbar { padding: 0.4rem 0.75rem; }
  .consult-title { display: none; }
  .consult-separator { display: none; }
}
