/**
 * ENHANCED MESSAGING FEATURES - CSS STYLES
 */

/* ==================== MESSAGE REACTIONS ==================== */

.message-reactions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.reaction-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 2px solid rgba(249, 115, 22, 0.3);
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.reaction-bubble:hover {
  transform: scale(1.1);
  border-color: rgba(249, 115, 22, 0.6);
}

.reaction-bubble.user-reacted {
  background: linear-gradient(145deg, #f97316, #ea580c);
  border-color: #f97316;
}

.reaction-emoji {
  font-size: 16px;
}

.reaction-count {
  font-size: 12px;
  font-weight: 600;
  color: #d1d5db;
}

.reaction-bubble.user-reacted .reaction-count {
  color: white;
}

.add-reaction-btn {
  padding: 4px 8px;
  border-radius: 12px;
  border: 2px dashed rgba(249, 115, 22, 0.4);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.add-reaction-btn:hover {
  border-color: rgba(249, 115, 22, 0.8);
  background: rgba(249, 115, 22, 0.1);
}

/* Reaction Picker Overlay */
.reaction-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.reaction-picker {
  background: linear-gradient(145deg, #4a4a4a, #2d2d2d);
  border: 2px solid #f97316;
  border-radius: 16px;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.reaction-option {
  font-size: 32px;
  padding: 12px;
  border: none;
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reaction-option:hover {
  transform: scale(1.2);
  background: linear-gradient(145deg, #f97316, #ea580c);
}

/* ==================== REPLY TO MESSAGES ==================== */

.reply-preview {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  border-left: 4px solid #f97316;
  border-radius: 8px;
  margin-bottom: 10px;
}

.reply-preview-text {
  flex: 1;
  font-size: 13px;
  color: #d1d5db;
}

.reply-preview-text strong {
  color: #f97316;
}

.reply-preview-message {
  opacity: 0.7;
  font-style: italic;
}

.reply-preview-close {
  background: rgba(249, 115, 22, 0.2);
  border: 1px solid #f97316;
  color: #f97316;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.replied-message {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  background: rgba(249, 115, 22, 0.1);
  border-left: 3px solid #f97316;
  border-radius: 6px;
  font-size: 13px;
}

.reply-line {
  width: 3px;
  background: #f97316;
  border-radius: 2px;
}

.reply-content {
  flex: 1;
}

.reply-content strong {
  color: #f97316;
  display: block;
  margin-bottom: 2px;
}

.reply-text {
  color: #999;
  font-style: italic;
  opacity: 0.8;
}

/* ==================== TYPING INDICATORS ==================== */

#typingIndicator {
  display: none;
  padding: 8px 15px;
  color: #f97316;
  font-size: 13px;
  font-style: italic;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==================== READ RECEIPTS ==================== */

.read-receipt {
  font-size: 10px;
  color: #4ade80;
  margin-left: 8px;
}

.delivery-status {
  font-size: 11px;
  margin-left: 5px;
}

.delivery-status.sent { color: #9ca3af; }
.delivery-status.delivered { color: #60a5fa; }
.delivery-status.read { color: #4ade80; }

/* ==================== MESSAGE SEARCH ==================== */

.message-search-bar {
  padding: 12px 15px;
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  border-bottom: 2px solid #f97316;
  display: flex;
  gap: 10px;
}

.message-search-input {
  flex: 1;
  padding: 10px 15px;
  background: #1a1a1a;
  border: 2px solid rgba(249, 115, 22, 0.4);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
}

.message-search-input:focus {
  outline: none;
  border-color: #f97316;
}

.search-results-container {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a1a;
  overflow-y: auto;
  z-index: 100;
  padding: 15px;
}

.search-result-item {
  padding: 12px;
  margin-bottom: 10px;
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  border: 2px solid rgba(249, 115, 22, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-result-item:hover {
  border-color: #f97316;
  transform: translateX(5px);
}

.search-result-sender {
  color: #f97316;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.search-result-content {
  color: #d1d5db;
  font-size: 14px;
  margin-bottom: 6px;
}

.search-result-date {
  color: #999;
  font-size: 11px;
}

.no-search-results {
  text-align: center;
  padding: 40px;
  color: #999;
  font-style: italic;
}

/* ==================== MESSAGE PINNING ==================== */

.pinned-messages-section {
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  border-bottom: 2px solid #f97316;
  padding: 12px 15px;
  max-height: 150px;
  overflow-y: auto;
}

.pinned-message-item {
  padding: 8px;
  margin-bottom: 8px;
  background: rgba(249, 115, 22, 0.1);
  border-left: 4px solid #f97316;
  border-radius: 6px;
  cursor: pointer;
}

.pinned-message-item:hover {
  background: rgba(249, 115, 22, 0.2);
}

.pin-indicator {
  display: inline-block;
  margin-left: 8px;
  color: #f97316;
  font-size: 12px;
}

.message.pinned .message-bubble {
  border: 2px solid #f97316;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
}

.pin-button {
  background: rgba(249, 115, 22, 0.2);
  border: 1px solid #f97316;
  color: #f97316;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  margin-top: 5px;
}

.pin-button:hover {
  background: rgba(249, 115, 22, 0.4);
}

/* ==================== PRIORITY/EMERGENCY MESSAGES ==================== */

.priority-indicator {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
  display: inline-block;
}

.priority-indicator.priority {
  background: rgba(251, 191, 36, 0.2);
  border: 2px solid #fbbf24;
  color: #fbbf24;
}

.priority-indicator.emergency {
  background: rgba(239, 68, 68, 0.2);
  border: 2px solid #ef4444;
  color: #ef4444;
  animation: emergencyPulse 1s ease-in-out infinite;
}

@keyframes emergencyPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

.message.priority .message-bubble {
  border: 2px solid #fbbf24;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
}

.message.emergency .message-bubble {
  border: 2px solid #ef4444;
  background: linear-gradient(145deg, #7f1d1d, #991b1b) !important;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
  animation: emergencyPulse 1s ease-in-out infinite;
}

.priority-selector {
  display: none;
  gap: 8px;
  margin-bottom: 10px;
}

.priority-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid rgba(249, 115, 22, 0.4);
  background: transparent;
  color: #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.priority-btn.active {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
}

.priority-btn.emergency.active {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* ==================== LINK PREVIEWS ==================== */

.link-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 12px;
  background: rgba(249, 115, 22, 0.1);
  border: 2px solid rgba(249, 115, 22, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.link-preview:hover {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.2);
}

.link-preview-icon {
  font-size: 32px;
}

.link-preview-text {
  flex: 1;
}

.link-preview-title {
  color: #f97316;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.link-preview-domain {
  color: #999;
  font-size: 12px;
}

/* ==================== PDF PREVIEW ==================== */

.pdf-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  border: 2px solid rgba(249, 115, 22, 0.4);
  border-radius: 10px;
  margin-top: 8px;
}

.pdf-icon {
  font-size: 40px;
}

.pdf-info {
  flex: 1;
}

.pdf-name {
  color: #d1d5db;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.pdf-view-btn {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.pdf-view-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

/* ==================== MESSAGE TEMPLATES ==================== */

.template-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.template-modal-content {
  background: linear-gradient(145deg, #4a4a4a, #2d2d2d);
  border: 2px solid #f97316;
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
}

.template-modal-content h3 {
  color: #f97316;
  margin-top: 0;
  margin-bottom: 20px;
}

#templateList {
  max-height: 400px;
  overflow-y: auto;
}

.template-item {
  padding: 12px;
  margin-bottom: 12px;
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
  border: 2px solid rgba(249, 115, 22, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-item:hover {
  border-color: #f97316;
  transform: translateX(5px);
}

.template-item strong {
  color: #f97316;
  display: block;
  margin-bottom: 6px;
}

.template-item p {
  color: #d1d5db;
  font-size: 13px;
  margin: 0;
}

/* ==================== VOICE MESSAGE WAVEFORM ==================== */

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 8px 0;
}

.waveform-bar {
  width: 3px;
  background: linear-gradient(to top, #f97316, #ea580c);
  border-radius: 2px;
  transition: height 0.2s ease;
  animation: waveAnimation 1s ease-in-out infinite;
}

.waveform-bar:nth-child(2n) {
  animation-delay: 0.1s;
}

.waveform-bar:nth-child(3n) {
  animation-delay: 0.2s;
}

@keyframes waveAnimation {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==================== CONTEXT MENU (Long Press Actions) ==================== */

.message-context-menu {
  position: absolute;
  background: linear-gradient(145deg, #4a4a4a, #2d2d2d);
  border: 2px solid #f97316;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  min-width: 180px;
}

.context-menu-item {
  padding: 10px 15px;
  color: #d1d5db;
  cursor: pointer;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.context-menu-item:hover {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
}

.context-menu-item-icon {
  font-size: 18px;
}

/* ==================== MOBILE RESPONSIVENESS ==================== */

@media (max-width: 768px) {
  .reaction-picker {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 15px;
  }

  .reaction-option {
    font-size: 28px;
    padding: 10px;
  }

  .template-modal-content {
    width: 95%;
    padding: 20px;
  }

  .search-results-container {
    top: 50px;
  }
}

/* ==================== DARK MODE OVERRIDES ==================== */

.dark-mode .message-reactions {
  /* Already dark by default */
}

.dark-mode .reaction-bubble {
  background: linear-gradient(145deg, #2a2a2a, #1d1d1d);
}

.dark-mode .template-modal-content {
  background: linear-gradient(145deg, #3a3a3a, #2d2d2d);
}
