/* ── GenSpeak — Frontend Styles ── */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background: #121218;
  color: #e4e4e7;
  line-height: 1.6;
  min-height: 100vh;
  padding: 2rem 1rem;
}

/* ---------- Layout ---------- */
main {
  max-width: 600px;
  margin: 0 auto;
}

/* ---------- Typography ---------- */
h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f4f4f5;
  text-align: center;
  margin-bottom: 0.25rem;
}

.subtitle {
  text-align: center;
  color: #71717a;
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* ---------- Translator Card ---------- */
.translator {
  background: #1c1c24;
  border: 1px solid #27272a;
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---------- Textarea ---------- */
textarea#input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #e4e4e7;
  background: #09090b;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  resize: vertical;
  transition: border-color 0.2s ease;
}

textarea#input::placeholder {
  color: #52525b;
}

textarea#input:focus {
  outline: none;
  border-color: #6d5dfc;
  box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.15);
}

/* ---------- Character Count ---------- */
.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: #52525b;
  margin-top: -0.5rem;
}

.char-count .over-limit {
  color: #f87171;
  font-weight: 600;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

select#generation {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: #e4e4e7;
  background: #09090b;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8.825a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 1 1 .708-.708L6 7.617l3.646-3.646a.5.5 0 1 1 .708.708l-4 4A.5.5 0 0 1 6 8.825z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  transition: border-color 0.2s ease;
}

select#generation:focus {
  outline: none;
  border-color: #6d5dfc;
  box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.15);
}

/* ---------- Buttons ---------- */
.buttons {
  display: flex;
  gap: 0.5rem;
}

.buttons button {
  flex: 1;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.btn-translate {
  color: #fff;
  background: #6d5dfc;
}

.btn-translate:hover {
  background: #5b4ae0;
}

.btn-translate:active {
  background: #4c3dcf;
}

.btn-decode {
  color: #e4e4e7;
  background: #27272a;
  border: 1px solid #3f3f46 !important;
}

.btn-decode:hover {
  background: #3f3f46;
}

.btn-decode:active {
  background: #52525b;
}

/* Loading / disabled state */
.buttons button:disabled {
  background: #3f3f46;
  color: #71717a;
  cursor: not-allowed;
  opacity: 0.7;
}

.buttons button.loading {
  background: linear-gradient(270deg, #6d5dfc, #3f3f46, #6d5dfc);
  background-size: 400% 100%;
  animation: shimmer 2s ease infinite;
  color: #e4e4e7;
  opacity: 1;
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  50% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* ---------- Output Box ---------- */
.output {
  background: #18181f;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.output[hidden] {
  display: none;
}

#output-text {
  font-size: 1rem;
  line-height: 1.6;
  color: #d4d4d8;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ---------- Error Box ---------- */
.error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
}

.error[hidden] {
  display: none;
}

#error-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #fca5a5;
}

/* ---------- History ---------- */
.history-section {
  margin-top: 1.5rem;
}

.history-section[hidden] {
  display: none;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.history-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #71717a;
}

.btn-clear {
  background: none;
  border: 1px solid #3f3f46;
  color: #71717a;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-clear:hover {
  color: #f87171;
  border-color: #f87171;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  background: #1c1c24;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.history-mode {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.history-mode.translate {
  background: rgba(109, 93, 252, 0.15);
  color: #a78bfa;
}

.history-mode.decode {
  background: rgba(52, 211, 153, 0.15);
  color: #6ee7b7;
}

.history-gen {
  font-size: 0.75rem;
  color: #71717a;
}

.history-input {
  font-size: 0.85rem;
  color: #71717a;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.history-output {
  font-size: 0.85rem;
  color: #d4d4d8;
  line-height: 1.4;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  body {
    padding: 1.25rem 0.75rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .translator {
    padding: 1rem;
  }

  .buttons {
    flex-direction: column;
  }
}
