:root {
  /* Colores para el modo claro */
  --background: #f8f9fa;
  --foreground: #0f1729;
  --card: #ffffff;
  --card-foreground: #0f1729;
  --primary: #1c60de;
  --primary-foreground: #ffffff;
  --secondary: #f2f4f7;
  --secondary-foreground: #1f2937;
  --border: #e5e7eb;
  --radius: 0.5rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --subtitle-color: #4b5563;
  --empty-state-color: #6b7280;
  --star-unfilled: #d1d5db;
}

/* Colores para el modo oscuro */
html[data-theme="dark"] {
  --background: #0f172a;
  --foreground: #e2e8f0;
  --card: #1e293b;
  --card-foreground: #e2e8f0;
  --primary: #60a5fa;
  --primary-foreground: #1e293b;
  --secondary: #334155;
  --secondary-foreground: #94a3b8;
  --border: #334155;
  --subtitle-color: #94a3b8;
  --empty-state-color: #94a3b8;
  --star-unfilled: #475569;
}

/* Detección automática de preferencia del sistema */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #0f172a;
    --foreground: #e2e8f0;
    --card: #1e293b;
    --card-foreground: #e2e8f0;
    --primary: #60a5fa;
    --primary-foreground: #1e293b;
    --secondary: #334155;
    --secondary-foreground: #94a3b8;
    --border: #334155;
    --subtitle-color: #94a3b8;
    --empty-state-color: #94a3b8;
    --star-unfilled: #475569;
  }
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s; /* Transición suave para el cambio de tema */
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem; /* Añadido padding para que el contenido no esté pegado a los bordes */
}

header {
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem; /* Padding para el header */
}

h1 {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--subtitle-color);
  margin-bottom: 1.5rem;
}

.card {
  background-color: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 2rem;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.form-container {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

form {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
}

@media (max-width: 768px) {
  form {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 0.5rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--card);
  color: var(--card-foreground);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.3s, background-color 0.3s, color 0.3s;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

button {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  margin-top: 1.5rem;
  width: 100%;
}

button:hover {
  background-color: #1551c0; /* Un tono más oscuro del primary original */
  /* Asegúrate de ajustar este hover para el modo oscuro también si es necesario */
  /* Ejemplo para modo oscuro: html[data-theme="dark"] button:hover { background-color: #4a87e0; } */
}

/* Estilo específico para el botón de tema */
#theme-toggle {
  width: auto; /* Ancho automático para el botón de tema */
  padding: 0.5rem; /* Padding para el botón de tema */
  margin-top: 0; /* Sin margin-top adicional */
  background: none;
  border: 1px solid var(--border);
  color: var(--foreground);
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-toggle:hover {
  background-color: var(--secondary);
}

#theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.table-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background-color: var(--secondary);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.3s;
}

th {
  text-align: left;
  padding: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--secondary-foreground);
  text-transform: uppercase;
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

tr.dragging {
  opacity: 0.3;
}

tr:not(.dragging):hover {
  background-color: var(--secondary);
}

tr.drag-over {
  border-top: 2px solid var(--primary);
}

tr {
  cursor: move;
}

.rating {
  display: flex;
  align-items: center;
}

.star {
  color: var(--star-unfilled);
  transition: color 0.3s;
}

.star.filled {
  color: #f59e0b; /* Amarillo para estrellas llenas, mantener constante */
}

.drag-handle {
  cursor: move;
  color: var(--subtitle-color); /* Ajustado para modo oscuro */
  margin-right: 0.5rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--subtitle-color); /* Ajustado para modo oscuro */
  margin: 0;
  padding: 0;
  transition: background-color 0.2s, color 0.2s;
}

.btn-icon:hover {
  background-color: var(--secondary);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--empty-state-color); /* Ajustado para modo oscuro */
  display: none; /* Oculto por defecto, se muestra con JS */
}

.empty-state p {
  margin-bottom: 1rem;
}

.status {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  background-color: var(--card);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s, background-color 0.3s, color 0.3s, box-shadow 0.3s;
}

.status.show {
  opacity: 1;
}

.status-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-connected {
  background-color: #22c55e;
}

.status-disconnected {
  background-color: #ef4444;
}

#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--background); /* Usa el color de fondo para que se adapte */
  opacity: 0.8;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: background-color 0.3s;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border); /* Usa el color del borde para el spinner */
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.setup-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel {
  background-color: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s, box-shadow 0.3s;
}

.panel h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.panel p {
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--subtitle-color);
}

/* Estilos para el slider */
.slider-container {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.noise-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: var(--border); /* Ajustado para modo oscuro */
  outline: none;
  transition: background-color 0.3s;
}

.noise-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: background-color 0.3s;
}

.noise-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: background-color 0.3s;
}

.noise-value {
  text-align: center;
  font-weight: bold;
  margin-top: 0.5rem;
}

.noise-level {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.noise-level-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #22c55e 0%, #facc15 50%, #ef4444 100%);
  flex-grow: 1;
  margin: 0 0.5rem;
}

.noise-level-value {
  font-weight: bold;
  min-width: 2rem;
  text-align: center;
}

/* Icono de volumen */
.volume-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  fill: currentColor; /* Asegura que el icono cambie de color con el texto */
}
