use colored::*;
use std::io::{self, Write};
use std::thread;
use std::time::Duration;
pub fn clear_screen() {
print!("{esc}c", esc = 27 as char);
let _ = io::stdout().flush();
}
pub fn log_status(message: &str, status: &str) {
let status_colored = match status.to_lowercase().as_str() {
"ok" => "SUCCESS".green().bold(),
"error" => "ERROR".red().bold(),
_ => "INFO".blue().bold(),
};
println!("[{}] {}", status_colored, message);
}
pub fn show_progress(current: u32, total: u32) {
let percentage = (current as f32 / total as f32) * 100.0;
print!("\rProgreso: [{:.1}%] ", percentage);
let _ = io::stdout().flush(); }
pub fn typewriter_print(text: &str, speed_ms: u64) {
for c in text.chars() {
print!("{}", c.to_string().cyan());
let _ = io::stdout().flush();
thread::sleep(Duration::from_millis(speed_ms));
}
println!();
}
pub fn print_banner(title: &str) {
println!("{}", "=".repeat(40).yellow());
println!("{:^40}", title.bright_magenta().bold());
println!("{}", "=".repeat(40).yellow());
}
pub fn get_input(prompt: &str) -> String {
print!("{} ", prompt.bright_white().italic());
let _ = io::stdout().flush();
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Error al leer entrada");
input.trim().to_string()
}
pub fn show_spinner(message: &str, duration_secs: u64) {
let symbols = ["|", "/", "-", "\\"];
let start = std::time::Instant::now();
let mut i = 0;
while start.elapsed().as_secs() < duration_secs {
print!("\r{} {}", symbols[i % 4].bright_cyan(), message);
let _ = std::io::stdout().flush();
std::thread::sleep(std::time::Duration::from_millis(100));
i += 1;
}
println!("\r{} {}", "✔".green(), message); }