:root {
  --bg: #0b1220;
  --bg-alt: #6a994e;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.1);
  --text: #e6f1ff;
  --muted: #9fb3c8;
  --accent: #4cc9f0;
  --accent-2: #3a86ff;
  --ring: #7dd3fc;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial,
    sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -10%,
      #183257 0%,
      transparent 60%),
    radial-gradient(1000px 700px at 110% 20%, #0e2b3f 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
  background-attachment: fixed;
  line-height: 1.6;
  position: relative;
  z-index: 0;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(140%) blur(10px);
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.06),
      rgba(255, 255, 255, 0));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

header h1 {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 24px);
  font-size: clamp(1.2rem, 1.2rem + 1.2vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

header .robot {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 2px 8px rgba(76, 201, 240, 0.35));
  object-fit: contain;
  vertical-align: middle;
}

.container {
  max-width: 960px;
  margin: 28px auto;
  padding: 0 clamp(16px, 4vw, 24px);
  position: relative;
}

.chat-actions {
  position: absolute; 
  bottom: 4rem;       
  right: 30px;       
}

.chat-actions button {
  background: none; 
  border: none;  
  font-size: 1rem;
  cursor: pointer;
  padding: 8px 12px; 
}

.chat-actions button:hover {
 opacity: 0.7;
}

main#chat {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 42vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.mensagem {
  max-width: 80%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  animation: bubbleIn 0.18s ease-out;
  position: relative;
  padding-right: 40px;
}

.message-actions button {
 background: none;
 border: none;
 font-size: 0.7rem;
 cursor: pointer;
 padding: 5px;
}

.message-actions button:hover {
 opacity: 0.7;
}

.copy-btn {
 position: absolute;
 top: 5px;
 right: 5px; 
}

.delete-btn {
 position: absolute;
 bottom: 5px;
 right: 5px;
}

.mensagem.ia {
  align-self: flex-start;
  background: linear-gradient(180deg,
      rgba(76, 201, 240, 0.18),
      rgba(255, 255, 255, 0.05));
  border-left: 3px solid var(--accent);
  text-align: justify;
}

.mensagem.user {
  align-self: flex-end;
  background: linear-gradient(180deg,
      rgba(58, 134, 255, 0.2),
      rgba(255, 255, 255, 0.05));
  border-right: 3px solid var(--accent-2);
}

@keyframes bubbleIn {
  from {
    transform: translateY(4px);
    opacity: 0.6;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.label {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 8px;
}

.api-key,
.chat-input input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.api-key::placeholder,
.chat-input input::placeholder {
  color: #9fb3c8b0;
}

.api-key:focus,
.chat-input input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(125, 211, 252, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

.chat-input {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.chat-input button {
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #031022;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 22px rgba(58, 134, 255, 0.32);
}

.chat-input button:hover {
  filter: brightness(1.05);
}

.chat-input button:active {
  transform: translateY(1px);
}

.chat-input button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(125, 211, 252, 0.25),
    0 8px 22px rgba(58, 134, 255, 0.32);
}

main#chat::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

main#chat::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-radius: 8px;
}

main#chat::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}

footer {
  margin-top: 32px;
  padding: 24px 16px 40px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: saturate(120%) blur(6px);
  background: linear-gradient(180deg,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0));
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: url("ChatGPT Image 9_08_2025, 21_52_48.png") no-repeat center;
  background-size: contain;
  background-position: center calc(50% + 47px);
  opacity: 0.1;
  pointer-events: none;
  z-index: -1;
}

.alert {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  min-width: 300px;
  max-width: 400px;
  padding: 16px 20px;
  border-radius: 12px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  backdrop-filter: blur(6px);
}

.alert.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: shake 0.3s ease-in-out;
}

.alert.error {
  background-color: rgba(255, 77, 77, 0.9);
  color: white;
}

.alert.success {
  background-color: rgba(76, 175, 80, 0.9);
  color: white;
}

.alert.warning {
  background-color: rgba(255, 152, 0, 0.9);
  color: white;
}

.alert.hidden {
  display: none;
}

@keyframes shake {
  0% {
    transform: translateX(-50%) translateY(0);
  }

  25% {
    transform: translateX(calc(-50% - 5px)) translateY(0);
  }

  50% {
    transform: translateX(-50%) translateY(0);
  }

  75% {
    transform: translateX(calc(-50% + 5px)) translateY(0);
  }

  100% {
    transform: translateX(-50%) translateY(0);
  }
}