/* ====== Reset básico ====== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #fafafa;
  color: #222;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ====== Header ====== */
.header {
  background: #f5f5f5;
  padding: 0.5rem 1rem;
  display: flex;
  /*flex-direction: column;*/
  justify-content: space-between;
  align-items: center;   /* centra verticalmente */
  gap: 0.5rem;
  border-bottom: 1px solid #ddd;
}

.header h1 {
  text-align: left;
  font-size: 1.4rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#msg {
  flex: 1;
  text-align: right;
  font-size: 0.8rem;
}

.icon-btn {
  font-size: 1.4rem;
  background: none;
  border: none;
  cursor: pointer;
}

/* ====== Main / Input ====== */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  gap: 0.5rem;
}

#inputText {
  width: 95%;
  height: 20vh;
  margin: 0 auto;
  padding: 0.5rem;
  resize: none;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

/* ====== Controles ====== */
.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.controls button {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: #0077cc;
  color: white;
  transition: background 0.2s;
}

.controls button:hover {
  background: #005fa3;
}

.hidden {
  display: none !important;
}

/* Switch (Simple/Full) */
.switch {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.4rem 0.8rem;   /* igual que los botones */
  border-radius: 5px;      /* mismo redondeado */
  background: transparent;  /* fondo limpio */
  color: #333;
}

.switch:hover {
  background: #f5f5f5;      /* gris clarito al pasar el ratón */
}

.switch input {
  display: none;
}

.switch .slider {
  width: 40px;
  height: 20px;
  background: #ccc;
  border-radius: 20px;
  position: relative;
  cursor: pointer;
}

.switch .slider::after {
  content: "";
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: 0.3s;
}

.switch input:checked + .slider::after {
  transform: translateX(20px);
}

.switch input:checked + .slider {
  background: #28a745; /* verde */
}

/* ====== Output ====== */
.output {
  flex: 1;
  width: 95%;
  margin: 0 auto;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: white;
  overflow-y: auto;
  white-space: pre-wrap;
  font-size: 1rem;
}

/* Separación entre líneas de análisis */
.output-line {
  margin-bottom: 0.25em; /* Mitad del tamaño de fuente actual */
  line-height: 1.4;
  padding: 2px 0;
}

.output .highlight {
  color: #a61403;
  font-weight: bold;
}

/* ====== Modal ====== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  min-width: 300px;
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);

  /* estructura flexible */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 👈 ya no scrollea todo el box */
}

/* Cabecera del modal (título + botón cerrar) */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  /* 👇 se queda fija arriba */
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;

  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

/* Botón cerrar */
.close-btn {
  background: #d9534f; /* rojo */
  color: white;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: #b52b27;
}

/* Contenedor con scroll para la lista */
.modal-content {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0; /* 👈 necesario para que el flex haga scroll */
  padding-top: 0.5rem;
}

/* Lista de radicales */
.radical-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0; /* ya controlamos en .modal-content */
}

.radical-list button {
  padding: 0.5rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f0f0f0;
  cursor: pointer;
  font-size: 1rem;
}

.radical-list button:hover {
  background: #ddd;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
  #inputText {
    height: 25vh;
    font-size: 1.1rem;
  }

  .controls button {
    /*flex: 1 1 45%;*/
    flex: 0 0 auto;   /* 👈 solo ocupa lo necesario */
    padding: 1rem;
    font-size: 1.1rem;
  }

  .output {
    font-size: 1.1rem;
  }
}
/* En pantallas más altas que anchas (móvil en vertical): 
   los radicales en columna, un botón por línea */
@media (max-aspect-ratio: 9/16) {
    .radical-list {
      flex-direction: column;
      align-items: center;   /* 👈 centra horizontalmente los botones */
      gap: 0.3rem;
    }
  
    .radical-list button {
      width: 85%;            /* 👈 ocupa el 90% */
      font-size: 0.9rem;
      padding: 0.4rem 0.6rem;
    }
  }


/* BOTONES */
/* Contenedor opcional para alinear */
.download-buttons {
  display: flex;
  gap: 10px; /* separación entre botones */
  margin-top: 15px;
}

/* Estilo base */
.download-buttons button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: white;
  transition: transform 0.15s ease, background 0.3s ease;
}

/* Hover efecto */
.download-buttons button:hover {
  transform: translateY(-2px);
}

/* 🎨 color para líneas de análisis */
.from-local { color: #222; }
.from-api   { color: #a61403; font-weight: 600; }
.notfound   { color: #a61403; font-style: italic; }

/* ===== Settings modal ===== */
.settings-box {
  min-width: 300px;
  max-width: 700px; 
  width: 80%;
}

.settings-box h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #0077cc;
}
 
.settings-box .modal-header {
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.setting-group label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #333;
}

.setting-group select {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 1rem;
}

.setting-actions {
  text-align: center;
  margin-top: 1rem;
}

.output.loading::after {
  content: "⏳ Analizando...";
  display: block;
  color: #666;
  font-style: italic;
  animation: blink 1s infinite;
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

.save-btn {
  background: #28a745;   /* verde */
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: background 0.2s;
}

.save-btn:hover {
  background: #218838;   /* verde más oscuro */
}

.radical-btn {
  display: block;
  margin: 4px 0;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f9f9f9;
  text-align: left;
  cursor: pointer;
}

.radical-symbol {
  font-weight: bold;
  font-size: 1.2em;
  margin-right: 4px;
}

.radical-variants {
  color: #666;
  font-size: 0.9em;
  margin-right: 6px;
}

.radical-pinyin {
  color: #333;
  margin-right: 6px;
}

.radical-meaning {
  color: #00b8cc;
  font-style: italic;
}

/* LINEA DE ANALISIS */
.pinyin {
  color: #615959;
  font-size: 0.95em;
}

.meaning {
  color: #008c9c;
  font-size: 0.9em;
  font-style: italic;
}

/* Opcional: si quieres que se vea mejor en modo oscuro */
.mainCharPinyin {
  color: #883333; /* Color granate */
  /*font-weight: bold;*/
}

/* Opcional: si quieres que se vea mejor en modo oscuro */
@media (prefers-color-scheme: dark) {
  .mainCharMeaning {
    color: #ff6b6b; /* Un rojo más claro para modo oscuro */
  }
}

/* Estilo para el texto de copyright */
.brand-footer {
  text-align: center;
  margin: 1.5rem 0;
}

.brand-text {
  font-size: 0.9rem;
  color: #7f8c8d; /* Gris medio */
  font-weight: 500;
}

.brand-text .panda {
  display: inline-block;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { 
    transform: translateY(0); 
  }
  50% { 
    transform: translateY(-5px); 
  }
}
