* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 100vh;
  height: 100dvh;
  padding: 20px;
  overflow: hidden;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  body {
    padding: 0;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }
}

/* Desktop: garantir que não há scroll no body */
@media (min-width: 769px) {
  body {
    overflow: hidden;
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  
  .chat-container {
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
  }
}

.container {
  max-width: 500px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 40px;
  margin-top: 10vh;
}

.login-box h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 28px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button[type="submit"]:active {
  transform: translateY(0);
}

.error {
  background: #fee;
  color: #c33;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  border-left: 4px solid #c33;
}

.info {
  text-align: center;
  color: #666;
  margin-top: 20px;
  font-size: 14px;
}

.chat-container {
  max-width: 900px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .chat-container {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
  }
  
  html, body {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh;
  }
}

.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .chat-header {
    padding: 15px;
    gap: 10px;
  }
  
  .chat-header h1 {
    font-size: 18px;
  }
}

.chat-header h1 {
  font-size: 24px;
  margin: 0;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.participants {
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
}

.leave-form {
  margin: 0;
}

.leave-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.3s;
}

.leave-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: #f5f5f5;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .chat-messages {
    padding: 15px 10px;
  }
}

.message {
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 12px;
  max-width: 70%;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

@media (max-width: 768px) {
  .message {
    max-width: 85%;
    padding: 10px;
    margin-bottom: 12px;
  }
}

.message.own {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  margin-left: auto;
}

.message.other {
  background: white;
  color: #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  opacity: 0.8;
}

.user-id {
  font-weight: 600;
}

.timestamp {
  font-size: 11px;
}

.message-content {
  line-height: 1.5;
}

.file-content {
  margin: 10px 0;
}

.file-preview {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
}

.file-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.file-preview video,
.file-preview audio {
  width: 100%;
  border-radius: 8px;
}

.file-download {
  padding: 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  margin-top: 8px;
}

.download-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-link:hover {
  text-decoration: underline;
}

.chat-input {
  padding: 10px 15px;
  background: #f0f0f0;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
  transition: background-color 0.2s, border-color 0.2s;
}

.chat-input.drag-over {
  background: #e3f2fd;
  border-top: 2px dashed #667eea;
}

@media (max-width: 768px) {
  .chat-input {
    padding: 8px 10px;
  }
}

.chat-input form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border-radius: 25px;
  padding: 5px 10px;
  border: 1px solid #e0e0e0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

@media (max-width: 768px) {
  .chat-input form {
    gap: 6px;
    padding: 4px 8px;
  }
}

.attach-btn {
  cursor: pointer;
  font-size: 24px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: color 0.2s;
  user-select: none;
  -webkit-user-select: none;
}

.attach-btn:hover {
  color: #667eea;
}

.chat-input input[type="text"] {
  flex: 1;
  padding: 10px 15px;
  border: none;
  border-radius: 0;
  font-size: 15px;
  background: transparent;
  outline: none;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

@media (max-width: 768px) {
  .chat-input input[type="text"] {
    padding: 8px 12px;
    font-size: 14px;
  }
}

.chat-input input[type="text"]::placeholder {
  color: #999;
}

.send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  min-height: 40px;
  max-height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
  overflow: hidden;
}

.send-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.send-btn:active {
  transform: scale(0.95);
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Área de preview de arquivos */
.file-preview-area {
  padding: 10px 15px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  max-height: 200px;
  overflow-y: auto;
}

.file-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.file-preview-item {
  position: relative;
  width: 100px;
  height: 100px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-preview-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.file-icon {
  font-size: 32px;
  margin-bottom: 5px;
}

.file-name {
  font-size: 10px;
  text-align: center;
  padding: 2px 4px;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 30px;
  color: #666;
}

.remove-file-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.remove-file-btn:hover {
  background: rgba(255, 0, 0, 1);
}

.clear-files-btn {
  width: 100%;
  padding: 8px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  transition: background 0.2s;
}

.clear-files-btn:hover {
  background: #e0e0e0;
}

/* Barra de progresso de upload */
.file-preview-item.uploading {
  border-color: #667eea;
  opacity: 0.8;
}

.upload-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px;
  border-radius: 0 0 6px 6px;
}

.upload-progress-bar {
  height: 4px;
  background: #667eea;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.upload-progress-text {
  color: white;
  font-size: 10px;
  text-align: center;
  margin-top: 2px;
  font-weight: 600;
}

@media (max-width: 768px) {
  .file-preview-item {
    width: 80px;
    height: 80px;
  }
  
  .file-preview-area {
    padding: 8px 10px;
    max-height: 150px;
  }
}

