/* RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f3f6f9;
  color: #2c3e50;
  min-height: 100vh;
  padding: 20px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* DARK MODE */
body.dark-mode {
  background-color: #121212;
  color: #e0e0e0;
}

body.dark-mode input,
body.dark-mode select {
  background-color: #1f1f1f;
  color: #e0e0e0;
  border-color: #555;
}

body.dark-mode .form,
body.dark-mode .results-container,
body.dark-mode .tips {
  background-color: #1f1f1f;
  border-color: #333;
}

body.dark-mode .btn {
  background-color: #2a73e8;
}

body.dark-mode .btn:hover {
  background-color: #155ab6;
}

body.dark-mode .form h2 {
  color: #4a9eff;
  border-color: #555;
}

body.dark-mode label {
  color: #e0e0e0;
}

body.dark-mode .note {
  color: #aaa;
}

body.dark-mode .results {
  color: #e0e0e0;
}

body.dark-mode .tips {
  color: #ccc;
  background-color: #2a2a2a;
}

body.dark-mode .bar-bg {
  background-color: #333;
}

body.dark-mode .error-message {
  color: #ff6b6b;
}

body.dark-mode header h1 {
  color: #4a9eff;
}

body.dark-mode #dark-mode-toggle {
  color: #e0e0e0;
}

body.dark-mode .form {
  background-color: #1f1f1f;
  color: #e0e0e0;
}

body.dark-mode .form-group {
  color: #e0e0e0;
}

body.dark-mode small {
  color: #aaa;
}

body.dark-mode .bar-container label {
  color: #e0e0e0;
}

body.dark-mode .history-section {
  background-color: #1f1f1f;
}

body.dark-mode .history-section h3 {
  color: #4a9eff;
}

body.dark-mode .history-item {
  background-color: #2a2a2a;
  border-left-color: #4a9eff;
}

body.dark-mode .history-item:hover {
  background-color: #333;
}

body.dark-mode .history-header {
  color: #e0e0e0;
}

body.dark-mode .history-date {
  color: #aaa;
}

body.dark-mode .history-details {
  color: #ccc;
}

body.dark-mode .icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* HEADER */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 720px;
  margin: 0 auto 20px;
}

header h1 {
  color: #1a73e8;
  font-size: 1.9rem;
}

.header-controls {
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.7rem;
  cursor: pointer;
  transition: transform 0.3s ease;
  padding: 5px;
  border-radius: 50%;
}

.icon-btn:hover {
  transform: scale(1.1);
  background-color: rgba(0, 0, 0, 0.1);
}

/* CONTENEDOR PRINCIPAL */
.container {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 30px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* HISTORIAL */
.history-section {
  width: 100%;
  background-color: #ffffff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
  animation: fadeInSlide 0.6s ease;
}

.history-section h3 {
  color: #1a73e8;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.history-container {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  background-color: #f8f9fa;
  padding: 12px 15px;
  margin-bottom: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-left: 4px solid #1a73e8;
}

.history-item:hover {
  background-color: #e3f2fd;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #2c3e50;
}

.history-date {
  font-size: 0.85rem;
  color: #666;
  font-weight: normal;
}

.history-details {
  font-size: 0.9rem;
  color: #555;
  margin-top: 4px;
}

/* Estados ocultos */
.hidden {
  display: none;
}

/* FORMULARIO */
.form {
  flex: 1 1 320px;
  background-color: #ffffff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.3s ease;
  min-width: 280px;
}

.form:hover {
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.08);
}

.form h2 {
  margin-bottom: 20px;
  color: #1a73e8;
  font-size: 1.4rem;
  border-bottom: 2px solid #d0d8e4;
  padding-bottom: 5px;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

input[type="number"],
select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccd6dd;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: #1a73e8;
}

/* Estados de validación */
input.error {
  border-color: #e74c3c;
  background-color: #fdf2f2;
}

body.dark-mode input.error {
  border-color: #ff6b6b;
  background-color: #2d1b1b;
}

/* Notas informativas */
.note {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-top: 6px;
}

/* BOTÓN */
.btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background-color: #1a73e8;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.25s ease;
  user-select: none;
}

.btn:hover,
.btn:focus {
  background-color: #155ab6;
  outline: none;
}

/* MENSAJES DE ERROR */
.error-message {
  color: #e74c3c;
  margin-top: 10px;
  font-weight: 600;
  min-height: 1.2em;
  text-align: center;
}

/* RESULTADOS */
.results-container {
  flex: 1 1 320px;
  min-width: 280px;
  background-color: #ffffff;
  padding: 30px 25px 30px 25px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: box-shadow 0.3s ease;
}

.results-container:hover {
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.08);
}

.results {
  font-size: 1rem;
  line-height: 1.6;
  color: #2c3e50;
  animation: fadeInSlide 0.6s ease;
}

.results p {
  margin-bottom: 12px;
}

.bar-container {
  margin-top: 6px;
}

.bar-bg {
  background-color: #e0e5eb;
  width: 100%;
  height: 20px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 6px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.bar-fill {
  background-color: #1a73e8;
  height: 100%;
  width: 0;
  transition: width 0.8s ease;
  border-radius: 12px 0 0 12px;
}

.tips {
  font-style: italic;
  color: #555;
  background-color: #f1f5f9;
  padding: 15px 18px;
  border-radius: 8px;
  box-shadow: inset 0 0 10px #d0d8e4;
  animation: fadeInSlide 0.6s ease;
  line-height: 1.4;
  font-size: 0.95rem;
  min-height: 60px;
}

/* Animación */
@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loader/spinner */
.loader {
  display: none;
  margin: 0 auto 18px auto;
  border: 4px solid #e0e0e0;
  border-top: 4px solid #1a73e8;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Fade-in para resultados y consejos */
.results, .tips {
  transition: opacity 0.5s ease;
}

/* Mejor feedback visual en botones */
.btn, .icon-btn {
  box-shadow: 0 2px 8px rgba(26,115,232,0.08);
  border-radius: 8px;
}
.btn:active, .icon-btn:active {
  transform: scale(0.97);
}

/* Sombra y bordes suaves en contenedores */
.form, .results-container, .history-section {
  box-shadow: 0 6px 32px rgba(26,115,232,0.08);
  border-radius: 16px;
}

/* RESPONSIVE */
@media (max-width: 720px) {
  .container {
    flex-direction: column;
  }

  .form, .results-container {
    min-width: 100%;
  }
}
