/* Simple responsive Messages page */
.jvg-msgs { 
  display: grid; 
  grid-template-columns: 280px 1fr; 
  gap: 15px; 
  min-height: 70vh; 
  max-width: 100%;
}

.jvg-msgs-list { 
  background: #fff; 
  border: 1px solid #ddd; 
  border-radius: 8px; 
  overflow: hidden; 
  display: flex; 
  flex-direction: column;
}

.jvg-msgs-list-header { 
  padding: 12px; 
  border-bottom: 1px solid #eee; 
  display: flex; 
  gap: 8px; 
  align-items: center; 
}

.jvg-msgs-list-header h3 { 
  margin: 0; 
  flex: 1; 
  font-size: 16px; 
  font-weight: 600;
}

.jvg-new-msg-btn { 
  background: #0066cc; 
  color: #fff; 
  border: none; 
  padding: 6px 12px; 
  border-radius: 4px; 
  cursor: pointer; 
  font-weight: 600;
}

.jvg-new-msg-btn:hover { 
  background: #0052a3;
}

.jvg-msgs-list-items { 
  flex: 1; 
  overflow-y: auto; 
  padding: 0;
}

.jvg-conv-item { 
  padding: 10px 12px; 
  border: none;
  border-bottom: 1px solid #f0f0f0; 
  cursor: pointer; 
  background: #fff; 
  width: 100%; 
  text-align: left; 
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.jvg-conv-item:hover { 
  background: #f5f5f5;
}

.jvg-conv-item.active { 
  background: #e8f0ff; 
  border-left: 3px solid #0066cc;
}

.jvg-conv-name { 
  font-weight: 600; 
  font-size: 13px; 
  color: #222;
}

.jvg-conv-preview { 
  font-size: 12px; 
  color: #777; 
  margin-top: 4px; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis;
}

.jvg-msgs-thread { 
  background: #fff; 
  border: 1px solid #ddd; 
  border-radius: 8px; 
  overflow: hidden; 
  display: flex; 
  flex-direction: column;
}

.jvg-thread-header { 
  padding: 12px; 
  border-bottom: 1px solid #eee; 
  font-weight: 600; 
  color: #222;
}

.jvg-thread-messages { 
  flex: 1; 
  overflow-y: auto; 
  padding: 12px; 
  background: #fafbff;
}

.jvg-msg { 
  margin-bottom: 12px; 
  display: flex; 
  gap: 8px;
  align-items: flex-end;
}

.jvg-msg.mine { 
  flex-direction: row-reverse;
}

.jvg-msg-avatar { 
  width: 28px; 
  height: 28px; 
  border-radius: 50%; 
  background: #ddd; 
  flex-shrink: 0;
  object-fit: cover;
}

.jvg-msg-content {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  gap: 2px;
}

.jvg-msg-bubble { 
  background: #fff; 
  border: 1px solid #ddd; 
  padding: 8px 10px; 
  border-radius: 8px; 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.jvg-msg.mine .jvg-msg-bubble { 
  background: #e8f0ff; 
  border-color: #3b82f6;
}

.jvg-msg-timestamp { 
  font-size: 11px; 
  color: #999; 
  margin-top: 2px;
}

.jvg-thread-composer { 
  padding: 0; 
  border-top: 1px solid #eee; 
  display: flex;
  flex-direction: column;
}.jvg-thread-composer textarea { 
  flex: 1; 
  padding: 8px; 
  border: 1px solid #ddd; 
  border-radius: 4px; 
  resize: none;
  font-family: inherit;
}

.jvg-thread-composer button { 
  background: #0066cc; 
  color: #fff; 
  border: none; 
  padding: 8px 16px; 
  border-radius: 4px; 
  cursor: pointer; 
  font-weight: 600;
}

.jvg-thread-composer button:hover { 
  background: #0052a3;
}

.jvg-empty { 
  text-align: center; 
  color: #999; 
  padding: 40px 20px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .jvg-msgs-list, .jvg-msgs-thread { 
    background: #1a1a1a; 
    border-color: #333;
  }
  .jvg-msgs-list-header, .jvg-thread-header, .jvg-composer-tools { 
    border-bottom-color: #333;
  }
  .jvg-msgs-list-header h3, .jvg-thread-header, .jvg-conv-name { 
    color: #e5e5e5;
  }
  .jvg-conv-preview { 
    color: #999;
  }
  .jvg-conv-item { 
    background: #1a1a1a; 
    border-bottom-color: #2a2a2a;
  }
  .jvg-conv-item:hover { 
    background: #222;
  }
  .jvg-conv-item.active { 
    background: #0b2945;
  }
  .jvg-thread-messages { 
    background: #0f1419;
  }
  .jvg-msg-bubble { 
    background: #222; 
    border-color: #333; 
    color: #e5e5e5;
  }
  .jvg-msg.mine .jvg-msg-bubble { 
    background: #0b2945; 
    border-color: #1d4ed8;
  }
  .jvg-composer-input textarea,
  .jvg-tool-btn,
  .jvg-gif-search,
  .jvg-emoji-picker {
    background: #1a1a1a;
    color: #e5e5e5;
    border-color: #333;
  }
  .jvg-tool-btn:hover { 
    background: #222;
  }
  .jvg-gif-preview { 
    background: #222;
    border-bottom-color: #333;
  }
  .jvg-gif-picker,
  .jvg-gif-search {
    background: #1a1a1a;
    border-color: #333;
    color: #e5e5e5;
  }
  .jvg-gif-result {
    border-color: #333;
  }
  .jvg-gif-loading,
  .jvg-gif-empty {
    color: #999;
  }
  .jvg-emoji-item:hover { 
    background: #222;
  }
  .jvg-send-btn { 
    border-top-color: #333;
  }
  .jvg-empty { 
    color: #666;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .jvg-msgs { 
    grid-template-columns: 1fr;
  }
  .jvg-msgs-list { 
    display: none;
  }
  .jvg-msgs-list.active { 
    display: flex;
  }
  
  .jvg-emoji-picker {
    grid-template-columns: repeat(6, 1fr);
  }
  
  .jvg-gif-results {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
}

.jvg-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 10px;
  flex-shrink: 0;
}

.jvg-conv-text {
  flex: 1;
  min-width: 0;
}

/* Composer avec outils */
.jvg-composer-tools {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}

.jvg-tool-btn {
  background: transparent;
  border: 1px solid #ddd;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.jvg-tool-btn:hover {
  background: #f5f5f5;
}

.jvg-composer-input {
  padding: 0;
}

.jvg-composer-input textarea {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 0;
  resize: none;
  font-family: inherit;
  font-size: 14px;
}

/* GIF Preview */
.jvg-gif-preview {
  position: relative;
  padding: 8px 12px;
  background: #f9f9f9;
  border-bottom: 1px solid #eee;
}

.jvg-gif-preview img {
  max-width: 100%;
  max-height: 150px;
  border-radius: 4px;
}

.jvg-gif-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
}

.jvg-gif-remove:hover {
  background: rgba(0,0,0,0.7);
}

/* Send button */
.jvg-send-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: #0066cc;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.jvg-send-btn:hover {
  background: #0052a3;
}

/* Emoji picker */
.jvg-emoji-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  max-height: 250px;
  overflow-y: auto;
  margin: 8px 12px;
}

.jvg-emoji-item {
  cursor: pointer;
  font-size: 24px;
  padding: 4px;
  border-radius: 4px;
  text-align: center;
}

.jvg-emoji-item:hover {
  background: #f0f0f0;
}

/* GIF picker */
.jvg-gif-picker {
  border: 1px solid #ddd;
  border-radius: 4px;
  margin: 8px 12px;
  background: #fff;
  display: none;
  flex-direction: column;
  max-height: 350px;
}

.jvg-gif-search {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid #ddd;
  border-radius: 4px 4px 0 0;
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
}

.jvg-gif-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.jvg-gif-result {
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #ddd;
  transition: transform 0.2s, border-color 0.2s;
  aspect-ratio: 1;
}

.jvg-gif-result img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.jvg-gif-result:hover {
  transform: scale(1.05);
  border-color: #0066cc;
}

.jvg-gif-loading,
.jvg-gif-empty,
.jvg-gif-fallback {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

.jvg-gif-fallback input {
  box-sizing: border-box;
}

.jvg-gif-fallback button {
  box-sizing: border-box;
}

/* HTML content in messages (GIFs and links) */
.jvg-msg-bubble {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.jvg-msg-bubble img {
  max-width: 100%;
  border-radius: 4px;
  margin-top: 4px;
}

.jvg-msg-bubble a {
  color: #0066cc;
  text-decoration: none;
}

.jvg-msg-bubble a:hover {
  text-decoration: underline;
}
