* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', sans-serif;
}

body {
  background: #f4f1fa;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  color: #333;
}

.app-container {
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 800px;
  border-radius: 25px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.header {
  background: linear-gradient(135deg, #e858ff, #8f54ff);
  color: white;
  padding: 20px;
  text-align: center;
  display: flex;
}

.header_content {
  text-align: center;
  width: 100%;
}

.chat-area {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.message.bot .text {
  background: #4e9fff;
  color: white;
}

.message.user {
  justify-content: flex-end;
  text-align: right;
}

.message.user .text {
  background: #e858ff;
  color: white;
}

.text {
  padding: clamp(10px, 1.5vw, 18px) clamp(14px, 2vw, 24px);
  border-radius: 20px;
  max-width: 70%;
  font-size: clamp(14px, 1.2vw, 18px);
  word-wrap: break-word;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #ddd;
  display: flex;
  justify-content: center;
  align-items: center;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.input-area {
  display: flex;
  padding: 10px 15px;
  border-top: 1px solid #ddd;
  background: #f9f9f9;
  gap: 8px;
}

.input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.input-group label {
  color: rgb(187, 71, 164);
  font-size: 14px;
  font-weight: 600;
}

.input-group input {
  padding: clamp(12px, 1.5vw, 18px) clamp(14px, 1.8vw, 20px);
  font-size: clamp(14px, 1.2vw, 18px);
  border: 2px solid #ddb6db;
  border-radius: 8px;
  background-color: #ecf0f1;
  color: #34495e;
  outline: none;
  transition: all 0.3s ease;
}

.input-group input:focus {
  border-color: #3498db;
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
  background-color: #ffffff;
}

.input-group input::placeholder {
  color: #ddb6db;
  font-style: italic;
}

.input-group select {
  padding: clamp(5px,  1.5vw, 5px) clamp(5px,  1.5vw, 20px);
    font-size: clamp(15px, 1.2vw, 15px);
  border: 2px solid #ddb6db;
  border-radius: 8px;
  background-color: #ecf0f1;
  color: #34495e;
  outline: none;
  transition: all 0.3s ease;
}

.input-group select:focus {
  border-color: #3498db;
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
  background-color: #ffffff;
}

.input-area input {
  flex: 1;
  padding: clamp(8px, 1vw, 12px) clamp(12px, 1.2vw, 15px);
  border: none;
  border-radius: 20px;
  background: #eae6f8;
  color: #333;
  font-size: clamp(14px, 1vw, 16px);
}

.input-area button {
  background: linear-gradient(135deg, #8f54ff, #4e9fff);
  border: none;
  color: white;
  padding: clamp(10px, 1.3vw, 16px) clamp(14px, 1.5vw, 20px);
  border-radius: 20px;
  cursor: pointer;
  font-size: clamp(14px, 1.1vw, 18px);
}

#copy {
  margin: 0 0 10px 0;
  text-align: center;
}

/* ========================= */
/* Botões do topo (agrupados)*/
/* ========================= */
.top-buttons {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  color: #fff;
}

.theme-toggle,
.export_btn,
.history_btn {
  position: static !important;
}

.top-buttons button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s ease, transform 0.1s ease;
  line-height: 0;
}

.top-buttons button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.top-buttons svg {
  width: 20px;
  height: 20px;
  display: block;
}

.top-buttons img {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
}

.copy-btn {
  background: none;
  border: none;
  font-size: 14px;
  margin-left: 10px;
  cursor: pointer;
  color: white;
  transition: transform 0.2s ease;
}

.copy-btn:hover {
  transform: scale(1.2);
}

#charCount {
  font-size: 12px;
  color: #888;
  margin-left: 10px;
  align-self: center;
}

/* ---------------------- */
/* Modal Histórico */
/* ---------------------- */
.history-modal {
  display: none; 
  position: fixed;
  z-index: 20;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background-color: rgba(0,0,0,0.6);
}

.history-content {
  background: #fff;
  margin: 60px auto;
  padding: 20px;
  border-radius: 15px;
  width: 90%;
  max-width: 600px;
  color: #333;
}

.close-history {
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.history-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-msg.user { color: #8f54ff; }
.history-msg.bot  { color: #4e9fff; }

/* Tema escuro */
body.dark-mode {
  background: #1e1e2f;
  color: #f0f0f0;
}

body.dark-mode .app-container {
  background: #2a2a3d;
}

body.dark-mode .header {
  background: linear-gradient(135deg, #8f54ff, #4e9fff);
}

body.dark-mode .message.bot .text {
  background: #4e9fff;
  color: white;
}

body.dark-mode .message.user .text {
  background: #e858ff;
  color: white;
}

body.dark-mode .input-area {
  background: #1e1e2f;
  border-top: 1px solid #444;
}

body.dark-mode .input-area input {
  background: #33354d;
  color: #f0f0f0;
}

body.dark-mode .input-area button {
  background: linear-gradient(135deg, #e858ff, #8f54ff);
}

body.dark-mode .history-content {
  background: #2a2a3d;
  color: #f0f0f0;
}

body.dark-mode #charCount {
  color: #f0f0f0;
  opacity: 0.7;
}

/* ========================= */
/* Responsividade Mobile e Fullscreen Desktop */
/* ========================= */

/* Mobile / Tablet */
@media (max-width: 1023px) {
  .app-container {
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .chat-area {
    padding: 10px;
    gap: 8px;
  }

  .text {
    font-size: clamp(13px, 3vw, 16px);
    max-width: 85%;
    word-wrap: break-word;
  }

  .input-area {
    padding: 8px 10px;
    gap: 6px;
  }

  .input-area input {
    font-size: clamp(13px, 3vw, 15px);
  }

  .input-area button {
    padding: 8px 12px;
    font-size: clamp(13px, 3vw, 15px);
    margin-left: 5px;
  }

  .top-buttons {
    top: 8px;
    right: 8px;
    gap: 6px;
  }

  .top-buttons button {
    padding: 5px;
    font-size: 18px;
  }
}

/* Desktop / Notebook Fullscreen */
@media (min-width: 1024px) {
  body, html {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
  }

  .app-container {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .chat-area {
    padding: 20px;
  }

  .input-area input {
    font-size: 16px;
  }

  .input-area button {
    font-size: 16px;
  }
}

