/* ========================================
   SINGLE CHAT - CSS COMPLETO
   ======================================== */

.single-chat-root {
  max-width: 480px;
  margin: 0 auto;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-user-select: none;
  user-select: none;
}

.single-chat-loading {
  text-align: center;
  padding: 16px;
}

/* ========================================
   TELA DE BOAS-VINDAS
   ======================================== */

.sc-welcome {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
}

.sc-welcome-text {
  margin-bottom: 12px;
  font-size: 14px;
}

.sc-profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.sc-profile-card {
  width: calc(50% - 4px);
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sc-profile-card-selected {
  border-color: #0073aa;
  box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.sc-profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 4px;
}

.sc-profile-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eee;
  font-weight: 600;
}

.sc-profile-name {
  font-size: 12px;
  font-weight: 500;
}

.sc-enter-btn {
  width: 100%;
}

/* ========================================
   LAYOUT PRINCIPAL DO CHAT
   ======================================== */

.sc-layout {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px;
  background: #fff;
  display: flex;
  flex-direction: column;
  height: 70vh;
  max-height: 600px;
}

.sc-main {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sc-header {
  font-weight: 600;
  margin-bottom: 4px;
}

.sc-status {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

.sc-messages {
  flex: 1;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fafafa;
  margin-bottom: 6px;
}

.sc-empty {
  font-size: 12px;
  color: #777;
  text-align: center;
  padding: 8px;
}

/* ========================================
   MENSAGENS
   ======================================== */

.sc-message {
  margin-bottom: 4px;
  display: flex;
  position: relative;
  touch-action: pan-y;
  will-change: transform;
}

.sc-message-me {
  justify-content: flex-end;
}

.sc-message-them {
  justify-content: flex-start;
}

.sc-bubble {
  max-width: 80%;
  padding: 6px 8px;
  border-radius: 12px;
  word-wrap: break-word;
  position: relative;
}

.sc-bubble-content {
  white-space: pre-wrap;
}

.sc-message-me .sc-bubble {
  background: #dcf8c6;
  border-bottom-right-radius: 4px;
}

.sc-message-them .sc-bubble {
  background: #fff;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}

/* ========================================
   INDICADOR DE SWIPE
   ======================================== */

.sc-swipe-indicator {
  position: absolute;
  left: -40px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e0e0e0;
  font-size: 14px;
}

.sc-swipe-icon {
  display: none;
}

.sc-swipe-icon-single {
  color: #0073aa;
}

.sc-swipe-icon-double {
  color: #e65100;
}

/* Estados de swipe */
.sc-message.sc-swipe-single .sc-swipe-indicator,
.sc-message.sc-swipe-double .sc-swipe-indicator {
  opacity: 1;
}

.sc-message.sc-swipe-single .sc-swipe-indicator {
  background: #e3f2fd;
}

.sc-message.sc-swipe-single .sc-swipe-icon-single {
  display: block;
}

.sc-message.sc-swipe-double .sc-swipe-indicator {
  background: #fff3e0;
}

.sc-message.sc-swipe-double .sc-swipe-icon-double {
  display: block;
}

/* ========================================
   PREVIEW DE RESPOSTA (dentro da mensagem)
   ======================================== */

.sc-reply-preview {
  display: flex;
  align-items: stretch;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  padding: 4px 6px;
  margin-bottom: 4px;
  font-size: 11px;
  gap: 6px;
}

.sc-reply-preview-bar {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sc-reply-preview-me {
  background: #25D366;
}

.sc-reply-preview-them {
  background: #0073aa;
}

.sc-reply-preview-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.sc-reply-preview-name {
  font-weight: 600;
  color: #333;
}

.sc-reply-preview-text {
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================
   BARRA DE RESPOSTA (acima do input)
   ======================================== */

.sc-reply-bar,
.sc-block-reply-bar {
  display: flex;
  align-items: stretch;
  background: #f5f5f5;
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 6px;
  gap: 8px;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sc-reply-bar-indicator {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sc-reply-bar-me {
  background: #25D366;
}

.sc-reply-bar-them {
  background: #0073aa;
}

.sc-reply-bar-content {
  flex: 1;
  overflow: hidden;
}

.sc-reply-bar-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sc-reply-bar-name {
  font-weight: 600;
  font-size: 12px;
  color: #333;
}

.sc-reply-bar-scope {
  font-size: 10px;
  color: #888;
  background: #e0e0e0;
  padding: 1px 4px;
  border-radius: 3px;
}

.sc-reply-bar-text {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-reply-bar-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.sc-reply-bar-close:hover {
  color: #333;
}

/* Reply bar dentro do bloco */
.sc-block-reply-bar {
  margin-bottom: 4px;
  padding: 4px 6px;
  font-size: 11px;
}

.sc-block-reply-bar .sc-reply-bar-name {
  font-size: 11px;
}

.sc-block-reply-bar .sc-reply-bar-text {
  font-size: 11px;
}

/* ========================================
   ÁREA DE INPUT
   ======================================== */

.sc-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sc-input-wrap > .sc-reply-bar + .sc-input,
.sc-input-wrap > .sc-reply-bar + .sc-actions {
  /* Ajusta quando tem reply bar */
}

.sc-input-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 6px;
}

.sc-input {
  flex: 1;
  resize: none;
  border-radius: 6px;
  border: 1px solid #ccc;
  padding: 6px 8px;
  font-size: 14px;
  font-family: inherit;
  min-height: 36px;
}

.sc-input:focus {
  outline: none;
  border-color: #0073aa;
}

.sc-actions {
  display: flex;
  flex-direction: row;
  gap: 4px;
  align-items: center;
}

/* ========================================
   BOTÕES
   ======================================== */

.sc-btn {
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}

.sc-btn:active {
  opacity: 0.8;
}

.sc-btn-primary {
  background: #0073aa;
  color: #fff;
}

.sc-btn-primary:hover {
  background: #005a87;
}

.sc-btn-ghost {
  background: #f7f7f7;
  color: #333;
}

.sc-btn-ghost:hover {
  background: #e7e7e7;
}

.sc-btn-small {
  padding: 4px 8px;
  font-size: 11px;
}

.sc-icon-btn {
  border: none;
  background: #f7f7f7;
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 16px;
}

.sc-icon-btn:hover {
  background: #e7e7e7;
}

/* ========================================
   BLOCOS DE MENSAGENS
   ======================================== */

.sc-block {
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  background: #f0f7ff;
  border: 1px solid #c5ddff;
}

.sc-block-me {
  background: #f0fff4;
  border-color: #b8e6c5;
}

.sc-block-them {
  background: #f0f7ff;
  border-color: #c5ddff;
}

.sc-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  cursor: grab;
  touch-action: pan-y;
}

.sc-block-header:active {
  cursor: grabbing;
}

.sc-block-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sc-block-sender {
  font-weight: 600;
  font-size: 13px;
  color: #333;
}

.sc-block-count {
  font-size: 11px;
  color: #666;
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 6px;
  border-radius: 10px;
}

.sc-block-replies-count {
  font-size: 11px;
  color: #0073aa;
}

.sc-block-controls {
  display: flex;
  gap: 4px;
}

.sc-block-body {
  padding-left: 8px;
  border-left: 3px solid rgba(0, 115, 170, 0.3);
  margin-bottom: 8px;
}

.sc-block-me .sc-block-body {
  border-left-color: rgba(37, 211, 102, 0.4);
}

/* ========================================
   THREAD DENTRO DO BLOCO
   ======================================== */

.sc-block-thread {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  padding: 6px;
  margin-top: 6px;
}

.sc-block-thread-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  margin-bottom: 6px;
}

.sc-thread-title {
  font-size: 11px;
  color: #666;
  font-weight: 500;
}

.sc-block-thread-messages {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 6px;
}

.sc-block-thread-messages .sc-message {
  margin-bottom: 3px;
}

.sc-block-thread-messages .sc-bubble {
  padding: 4px 6px;
  font-size: 13px;
}

.sc-thread-empty {
  font-size: 11px;
  color: #999;
  text-align: center;
  padding: 12px 8px;
  font-style: italic;
}

.sc-block-thread-input {
  display: flex;
  gap: 4px;
  flex-direction: column;
}

.sc-block-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}

.sc-block-input:focus {
  outline: none;
  border-color: #0073aa;
}

.sc-block-thread-input > .sc-btn {
  align-self: flex-end;
}

/* ========================================
   ANIMAÇÕES
   ======================================== */

.sc-message {
  animation: fadeInUp 0.2s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sc-block {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ========================================
   RESPONSIVO
   ======================================== */

@media (max-width: 480px) {
  .single-chat-root {
    max-width: 100%;
  }

  .sc-layout {
    height: 75vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .sc-bubble {
    max-width: 85%;
  }

  .sc-swipe-indicator {
    left: -35px;
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .sc-block-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .sc-block-controls {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ========================================
   SCROLLBAR CUSTOMIZADA
   ======================================== */

.sc-messages::-webkit-scrollbar,
.sc-block-thread-messages::-webkit-scrollbar {
  width: 6px;
}

.sc-messages::-webkit-scrollbar-track,
.sc-block-thread-messages::-webkit-scrollbar-track {
  background: transparent;
}

.sc-messages::-webkit-scrollbar-thumb,
.sc-block-thread-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.sc-messages::-webkit-scrollbar-thumb:hover,
.sc-block-thread-messages::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ========================================
   DICAS VISUAIS DE SWIPE
   ======================================== */

.sc-message::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: transparent;
  border-radius: 2px;
  transition: background 0.2s;
}

.sc-message.sc-swipe-single::before {
  background: #0073aa;
}

.sc-message.sc-swipe-double::before {
  background: #e65100;
}

/* ========================================
   ESTADO DE CONEXÃO
   ======================================== */

.sc-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sc-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffc107;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}