/* ============================================
   VARIAVEIS E RESET
   ============================================ */

:root {
  --bg-primary: #0a0a0f;
  --bg-card: #12121a;
  --bg-input: #1a1a2e;
  --bg-hover: #1e1e32;
  --border: #2a2a3e;
  --border-focus: #6366f1;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.2);
  --success: #22c55e;
  --error: #ef4444;
  --gradient: linear-gradient(135deg, #6366f1, #a855f7);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  -webkit-font-smoothing: antialiased;
}

/* Fundo sutil com grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(168, 85, 247, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

.app {
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 1;
}

/* ============================================
   HEADER
   ============================================ */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 0 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-light);
  background: var(--accent-glow);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* ============================================
   CARD CONVERSOR
   ============================================ */

.converter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ============================================
   SELETOR DE MODO
   ============================================ */

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}

.mode-btn {
  padding: 10px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.mode-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.mode-btn.active {
  color: #fff;
  background: var(--gradient);
  border-color: transparent;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ============================================
   INPUT
   ============================================ */

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

.input-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-field {
  width: 100%;
  padding: 14px 48px 14px 16px;
  font-size: 1.25rem;
  font-weight: 600;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition);
}

.input-field::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-glow);
}

.input-field.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.btn-clear {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-clear:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.input-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
  transition: color var(--transition);
}

.input-hint.error {
  color: var(--error);
}

/* ============================================
   RESULTADO
   ============================================ */

.result-area {
  position: relative;
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(168, 85, 247, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.result-area.has-value {
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.08);
}

.result-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-value {
  font-size: 2.2rem;
  font-weight: 700;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
  transition: all 0.3s ease;
  word-break: break-all;
}

.result-unit {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.btn-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-copy:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

.btn-copy.copied {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.08);
}

/* ============================================
   BOTAO CONVERTER
   ============================================ */

.btn-convert {
  width: 100%;
  padding: 13px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: var(--gradient);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btn-convert:hover {
  opacity: 0.9;
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-convert:active {
  transform: translateY(0);
}

/* ============================================
   HISTORICO
   ============================================ */

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.history-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-clear-history {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition);
}

.btn-clear-history:hover {
  color: var(--error);
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

/* Scrollbar estilizada */
.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  animation: slideIn 0.25s ease;
}

.history-item .from {
  color: var(--text-secondary);
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

.history-item .arrow {
  color: var(--text-muted);
  margin: 0 8px;
  flex-shrink: 0;
}

.history-item .to {
  color: var(--accent-light);
  font-weight: 700;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

.history-item .mode-tag {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 20px 0;
}

/* ============================================
   ANIMACOES
   ============================================ */

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============================================
   RESPONSIVO
   ============================================ */

@media (max-width: 480px) {
  body {
    padding: 16px 12px;
  }

  .converter-card {
    padding: 18px;
  }

  .mode-selector {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .mode-btn {
    font-size: 0.73rem;
    padding: 9px 6px;
  }

  .result-value {
    font-size: 1.8rem;
  }

  .input-field {
    font-size: 1.1rem;
    padding: 12px 44px 12px 14px;
  }
}
