/* ============================================
   MESSENGER ADVANCED FEATURES - CSS
   Media, Search, Settings
   ============================================ */

/* Media Preview Area */
.media-preview-area {
  padding: 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  overflow-x: auto;
}

.media-preview-area.hidden {
  display: none;
}

.media-preview-item {
  position: relative;
  min-width: 100px;
  max-width: 150px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary);
}

.media-preview-image,
.media-preview-video {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
}

.media-preview-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  height: 100px;
  background: var(--bg-secondary);
}

.media-preview-file .file-name {
  font-size: 12px;
  color: var(--text-primary);
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.media-preview-file .file-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.media-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.media-preview-remove:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Voice Recording UI */
.input-action-btn.recording {
  background: #ef4444;
  color: white;
  animation: pulse-record 1.5s ease-in-out infinite;
}

@keyframes pulse-record {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* Message Search Overlay */
.message-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.message-search-container {
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.3s ease;
}

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

.message-search-header {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.message-search-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
}

.message-search-input:focus {
  border-color: var(--msg-primary, #0891b2);
  background: var(--bg-primary);
}

.message-search-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.message-search-close:hover {
  background: var(--border-color);
}

.message-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.search-result-item {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.search-result-item:hover {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

.search-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.search-result-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.search-result-name {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.search-result-time {
  font-size: 12px;
  color: var(--text-muted);
}

.search-result-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 40px;
}

.search-result-content mark {
  background: #fef08a;
  color: #854d0e;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 500;
}

.highlight-message {
  animation: highlight-flash 2s ease;
}

@keyframes highlight-flash {
  0%, 100% { background: transparent; }
  50% { background: rgba(59, 130, 246, 0.1); }
}

/* Conversation Actions Menu */
.conversation-actions-menu {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  min-width: 160px;
  padding: 4px;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-50%) scale(0.95); }
  to { opacity: 1; transform: translateY(-50%) scale(1); }
}

.conversation-actions-menu button {
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  transition: all 0.2s;
}

.conversation-actions-menu button:hover {
  background: var(--bg-secondary);
}

.conversation-actions-menu button.danger {
  color: #ef4444;
}

.conversation-actions-menu button.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Messenger Settings Modal */
.messenger-settings-content {
  max-width: 600px;
  max-height: 90vh;
}

.settings-sections {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0;
}

.settings-section {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 16px;
}

.settings-item.clickable {
  cursor: pointer;
  padding: 12px;
  margin: 0 -12px;
  border-radius: 8px;
  transition: all 0.2s;
}

.settings-item.clickable:hover {
  background: var(--bg-secondary);
}

.settings-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-item-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-item-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* Toggle Switch - inherits from design system in styles.css */
/* Override checked color to match messenger theme */
.toggle-switch input:checked + .toggle-slider {
  background: var(--msg-primary, #0891b2);
}

/* Settings Select */
.settings-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.settings-select:focus {
  border-color: var(--msg-primary, #0891b2);
}

/* Color Input */
.settings-color-input {
  width: 60px;
  height: 36px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-color-input:hover {
  border-color: var(--msg-primary, #0891b2);
}

/* Blocked Users Modal */
.blocked-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
}

.blocked-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.blocked-user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.blocked-user-name {
  font-weight: 500;
  color: var(--text-primary);
}

.blocked-user-date {
  font-size: 13px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .message-search-overlay {
    padding-top: 20px;
  }

  .message-search-container {
    width: 95%;
    max-height: 85vh;
  }

  .messenger-settings-content {
    max-width: 95%;
    max-height: 85vh;
  }

  .settings-sections {
    max-height: 70vh;
  }
}
